mirror of
https://github.com/bitwarden/help
synced 2025-12-06 00:03:30 +00:00
added stretched master key. bootstrap 4.
This commit is contained in:
81
crypto.html
81
crypto.html
@@ -8,34 +8,21 @@
|
|||||||
|
|
||||||
<title>Bitwarden Crypto</title>
|
<title>Bitwarden Crypto</title>
|
||||||
|
|
||||||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,300italic,400italic,600italic"
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,300italic,400italic,600italic"
|
||||||
rel="stylesheet">
|
rel="stylesheet">
|
||||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
|
||||||
<script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
padding: 50px 0;
|
padding-bottom: 50px;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6 {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 32px;
|
border-bottom: 2px solid #ced4da;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
margin-top: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
@@ -46,9 +33,18 @@
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 {
|
pre {
|
||||||
font-size: 14px;
|
padding: 9.5px;
|
||||||
font-weight: bold;
|
line-height: 1.42857143;
|
||||||
|
word-break: break-all;
|
||||||
|
word-wrap: break-word;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
border: 1px solid #ced4da;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
margin-bottom: 50px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@@ -80,12 +76,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<section>
|
||||||
<h2>Master Key</h2>
|
<h2>Master Key</h2>
|
||||||
<pre>{{masterKey.b64}}</pre>
|
<pre>{{masterKey.b64}}</pre>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
<h2>Master Password Hash</h2>
|
<h2>Master Password Hash</h2>
|
||||||
<pre>{{masterKeyHash.b64}}</pre>
|
<pre>{{masterKeyHash.b64}}</pre>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Stretched Master Key</h2>
|
||||||
|
<pre>{{stretchedMasterKey.key.b64}}</pre>
|
||||||
|
<h3>Encryption Key</h3>
|
||||||
|
<pre>{{stretchedMasterKey.encKey.b64}}</pre>
|
||||||
|
<h3>MAC Key</h3>
|
||||||
|
<pre>{{stretchedMasterKey.macKey.b64}}</pre>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
<h2>Generated Symmetric Key</h2>
|
<h2>Generated Symmetric Key</h2>
|
||||||
<pre>{{symKey.key.b64}}</pre>
|
<pre>{{symKey.key.b64}}</pre>
|
||||||
<h3>Encryption Key</h3>
|
<h3>Encryption Key</h3>
|
||||||
@@ -94,21 +104,22 @@
|
|||||||
<pre>{{symKey.macKey.b64}}</pre>
|
<pre>{{symKey.macKey.b64}}</pre>
|
||||||
<h3>Protected Symmetric Key</h3>
|
<h3>Protected Symmetric Key</h3>
|
||||||
<pre>{{protectedSymKey.string}}</pre>
|
<pre>{{protectedSymKey.string}}</pre>
|
||||||
|
</section>
|
||||||
|
|
||||||
<h2>Generated RSA Keypair</h2>
|
<section>
|
||||||
|
<h2>Generated RSA Key Pair</h2>
|
||||||
<h3>Public Key</h3>
|
<h3>Public Key</h3>
|
||||||
<pre>{{publicKey.b64}}</pre>
|
<pre>{{publicKey.b64}}</pre>
|
||||||
<h3>Private Key</h3>
|
<h3>Private Key</h3>
|
||||||
<pre>{{privateKey.b64}}</pre>
|
<pre>{{privateKey.b64}}</pre>
|
||||||
<h3>Protected Private Key</h3>
|
<h3>Protected Private Key</h3>
|
||||||
<pre>{{protectedPrivateKey.string}}</pre>
|
<pre>{{protectedPrivateKey.string}}</pre>
|
||||||
|
</section>
|
||||||
|
|
||||||
<button type="button" id="deriveKeys" class="btn btn-primary" v-on:click="generateKeys">
|
<button type="button" id="deriveKeys" class="btn btn-primary" v-on:click="generateKeys">
|
||||||
<i class="fa fa-refresh"></i> Regenerate Keys
|
<i class="fa fa-refresh"></i> Regenerate Keys
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<h1>Encryption</h1>
|
<h1>Encryption</h1>
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
@@ -368,7 +379,7 @@
|
|||||||
return dataForMac;
|
return dataForMac;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateRsaKeypair() {
|
async function generateRsaKeyPair() {
|
||||||
const rsaOptions = {
|
const rsaOptions = {
|
||||||
name: 'RSA-OAEP',
|
name: 'RSA-OAEP',
|
||||||
modulusLength: 2048,
|
modulusLength: 2048,
|
||||||
@@ -429,6 +440,7 @@
|
|||||||
|
|
||||||
masterKey: new ByteData(),
|
masterKey: new ByteData(),
|
||||||
masterKeyHash: new ByteData(),
|
masterKeyHash: new ByteData(),
|
||||||
|
stretchedMasterKey: new SymmetricCryptoKey(),
|
||||||
|
|
||||||
symKey: new SymmetricCryptoKey(),
|
symKey: new SymmetricCryptoKey(),
|
||||||
protectedSymKey: new Cipher(),
|
protectedSymKey: new Cipher(),
|
||||||
@@ -462,6 +474,7 @@
|
|||||||
return new ByteData();
|
return new ByteData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.stretchedMasterKey = await stretchKey(newValue.arr.buffer);
|
||||||
self.masterKeyHash = await pbkdf2(newValue.arr.buffer, self.masterPasswordBuffer, 1, 256);
|
self.masterKeyHash = await pbkdf2(newValue.arr.buffer, self.masterPasswordBuffer, 1, 256);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -473,7 +486,7 @@
|
|||||||
window.crypto.getRandomValues(symKey);
|
window.crypto.getRandomValues(symKey);
|
||||||
self.symKey = new SymmetricCryptoKey(symKey);
|
self.symKey = new SymmetricCryptoKey(symKey);
|
||||||
|
|
||||||
const keyPair = await generateRsaKeypair();
|
const keyPair = await generateRsaKeyPair();
|
||||||
self.publicKey = keyPair.publicKey;
|
self.publicKey = keyPair.publicKey;
|
||||||
self.privateKey = keyPair.privateKey;
|
self.privateKey = keyPair.privateKey;
|
||||||
}
|
}
|
||||||
@@ -514,17 +527,21 @@
|
|||||||
|
|
||||||
vm.$watch(() => {
|
vm.$watch(() => {
|
||||||
return {
|
return {
|
||||||
masterKey: vm.masterKey,
|
stretchedMasterKey: vm.stretchedMasterKey,
|
||||||
symKey: vm.symKey
|
symKey: vm.symKey
|
||||||
};
|
};
|
||||||
}, async (newVal, oldVal) => {
|
}, async (newVal, oldVal) => {
|
||||||
if (!newVal.masterKey || !newVal.masterKey.arr || !newVal.symKey || !newVal.symKey.key) {
|
if (!newVal.stretchedMasterKey || !newVal.stretchedMasterKey.key ||
|
||||||
|
!newVal.stretchedMasterKey.key.arr || !newVal.symKey || !newVal.symKey.key ||
|
||||||
|
!newVal.symKey.key.arr) {
|
||||||
vm.protectedSymKey = new Cipher();
|
vm.protectedSymKey = new Cipher();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.protectedSymKey = await aesEncrypt(newVal.symKey.key.arr, newVal.masterKey, null);
|
vm.protectedSymKey = await aesEncrypt(newVal.symKey.key.arr, newVal.stretchedMasterKey.encKey,
|
||||||
const unprotectedSymKey = await aesDecrypt(vm.protectedSymKey, newVal.masterKey, null);
|
newVal.stretchedMasterKey.macKey);
|
||||||
|
const unprotectedSymKey = await aesDecrypt(vm.protectedSymKey, newVal.stretchedMasterKey.encKey,
|
||||||
|
newVal.stretchedMasterKey.macKey);
|
||||||
vm.unprotectedSymKey = new ByteData(unprotectedSymKey);
|
vm.unprotectedSymKey = new ByteData(unprotectedSymKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user