mirror of
https://github.com/bitwarden/help
synced 2026-01-21 11:53:27 +00:00
formatting
This commit is contained in:
44
crypto.html
44
crypto.html
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@@ -38,7 +38,9 @@
|
||||
<input type="number" id="pbkdf2Iterations" class="form-control" v-model="pbkdf2Iterations">
|
||||
</div>
|
||||
<button type="button" id="deriveKeys" class="btn btn-default"
|
||||
v-on:click="deriveKeys">Derive Keys</button>
|
||||
v-on:click="deriveKeys">
|
||||
Derive Keys
|
||||
</button>
|
||||
</form>
|
||||
<hr>
|
||||
<h2>Private Key</h2>
|
||||
@@ -67,20 +69,20 @@
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
(function(){
|
||||
var CipherString = function(type, iv, ct, mac) {
|
||||
(function () {
|
||||
var CipherString = function (type, iv, ct, mac) {
|
||||
this.type = type;
|
||||
this.iv = iv;
|
||||
this.ct = ct;
|
||||
this.mac = mac;
|
||||
this.string = type + '.' + iv.b64 + '|' + ct.b64;
|
||||
if(mac) {
|
||||
if (mac) {
|
||||
this.string += ('|' + mac.b64);
|
||||
}
|
||||
}
|
||||
|
||||
var ByteData = function(buf) {
|
||||
if(!buf) {
|
||||
var ByteData = function (buf) {
|
||||
if (!buf) {
|
||||
return;
|
||||
}
|
||||
this.buf = buf;
|
||||
@@ -88,26 +90,24 @@
|
||||
}
|
||||
|
||||
function pbkdf2(password, salt, iterations, length) {
|
||||
console.log('pbkdf2');
|
||||
|
||||
return window.crypto.subtle.importKey('raw', password, { name: 'PBKDF2' },
|
||||
return window.crypto.subtle.importKey('raw', password, { name: 'PBKDF2' },
|
||||
false, ['deriveKey', 'deriveBits']).then(function (importedKey) {
|
||||
return window.crypto.subtle.deriveKey({
|
||||
return window.crypto.subtle.deriveKey({
|
||||
'name': 'PBKDF2',
|
||||
salt: salt,
|
||||
iterations: iterations,
|
||||
hash: { name: 'SHA-256' }
|
||||
}, importedKey, {
|
||||
name: 'AES-CBC',
|
||||
length: 256
|
||||
}, true, ['encrypt', 'decrypt']);
|
||||
}).then(function (derivedKey) {
|
||||
return window.crypto.subtle.exportKey('raw', derivedKey);
|
||||
}).then(function (exportedKey) {
|
||||
return new ByteData(exportedKey);
|
||||
}).catch(function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
name: 'AES-CBC',
|
||||
length: 256
|
||||
}, true, ['encrypt', 'decrypt']);
|
||||
}).then(function (derivedKey) {
|
||||
return window.crypto.subtle.exportKey('raw', derivedKey);
|
||||
}).then(function (exportedKey) {
|
||||
return new ByteData(exportedKey);
|
||||
}).catch(function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
function fromUtf8(str) {
|
||||
@@ -169,7 +169,7 @@
|
||||
password = fromUtf8(this.masterPassword),
|
||||
salt = fromUtf8(this.email);
|
||||
|
||||
pbkdf2(password, salt, this.pbkdf2Iterations, 256).then(function(key) {
|
||||
pbkdf2(password, salt, this.pbkdf2Iterations, 256).then(function (key) {
|
||||
self.key = key;
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user