2016-10-21 17:20:36 +00:00
|
|
|
import HKDF from 'hkdf';
|
2017-02-16 17:10:12 +00:00
|
|
|
import srp from 'srp-js';
|
2019-04-18 00:50:03 +00:00
|
|
|
import forge from 'node-forge';
|
2016-10-21 17:20:36 +00:00
|
|
|
|
|
|
|
const DEFAULT_BYTE_LENGTH = 32;
|
2018-06-25 17:42:50 +00:00
|
|
|
const DEFAULT_PBKDF2_ITERATIONS = 1e5; // 100,000
|
2016-10-21 17:20:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate hex signing key used for AES encryption
|
|
|
|
*
|
|
|
|
* @param pass
|
|
|
|
* @param email
|
|
|
|
* @param salt
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function deriveKey(pass, email, salt) {
|
2016-10-21 17:20:36 +00:00
|
|
|
const combinedSalt = await _hkdfSalt(salt, email);
|
|
|
|
return _pbkdf2Passphrase(pass, combinedSalt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encrypt with RSA256 public key
|
|
|
|
*
|
|
|
|
* @param publicKeyJWK
|
|
|
|
* @param plaintext
|
|
|
|
* @return String
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export function encryptRSAWithJWK(publicKeyJWK, plaintext) {
|
2016-10-21 17:20:36 +00:00
|
|
|
if (publicKeyJWK.alg !== 'RSA-OAEP-256') {
|
|
|
|
throw new Error('Public key algorithm was not RSA-OAEP-256');
|
|
|
|
} else if (publicKeyJWK.kty !== 'RSA') {
|
|
|
|
throw new Error('Public key type was not RSA');
|
|
|
|
} else if (!publicKeyJWK.key_ops.find(o => o === 'encrypt')) {
|
|
|
|
throw new Error('Public key does not have "encrypt" op');
|
|
|
|
}
|
|
|
|
|
|
|
|
const encodedPlaintext = encodeURIComponent(plaintext);
|
|
|
|
|
|
|
|
const n = _b64UrlToBigInt(publicKeyJWK.n);
|
|
|
|
const e = _b64UrlToBigInt(publicKeyJWK.e);
|
|
|
|
const publicKey = forge.rsa.setPublicKey(n, e);
|
|
|
|
|
|
|
|
const encrypted = publicKey.encrypt(encodedPlaintext, 'RSA-OAEP', {
|
2018-12-12 17:36:11 +00:00
|
|
|
md: forge.md.sha256.create(),
|
2016-10-21 17:20:36 +00:00
|
|
|
});
|
|
|
|
return forge.util.bytesToHex(encrypted);
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
export function decryptRSAWithJWK(privateJWK, encryptedBlob) {
|
2016-10-21 17:20:36 +00:00
|
|
|
const n = _b64UrlToBigInt(privateJWK.n);
|
|
|
|
const e = _b64UrlToBigInt(privateJWK.e);
|
|
|
|
const d = _b64UrlToBigInt(privateJWK.d);
|
|
|
|
const p = _b64UrlToBigInt(privateJWK.p);
|
|
|
|
const q = _b64UrlToBigInt(privateJWK.q);
|
|
|
|
const dP = _b64UrlToBigInt(privateJWK.dp);
|
|
|
|
const dQ = _b64UrlToBigInt(privateJWK.dq);
|
|
|
|
const qInv = _b64UrlToBigInt(privateJWK.qi);
|
|
|
|
|
|
|
|
const privateKey = forge.rsa.setPrivateKey(n, e, d, p, q, dP, dQ, qInv);
|
|
|
|
const bytes = forge.util.hexToBytes(encryptedBlob);
|
|
|
|
const decrypted = privateKey.decrypt(bytes, 'RSA-OAEP', {
|
2018-12-12 17:36:11 +00:00
|
|
|
md: forge.md.sha256.create(),
|
2016-10-21 17:20:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return decodeURIComponent(decrypted);
|
|
|
|
}
|
|
|
|
|
2019-04-18 00:50:03 +00:00
|
|
|
/**
|
|
|
|
* Encrypt data using symmetric key
|
|
|
|
*
|
|
|
|
* @param jwkOrKey JWK or string representing symmetric key
|
|
|
|
* @param buff data to encrypt
|
|
|
|
* @param additionalData any additional public data to attach
|
|
|
|
* @returns {{iv, t, d, ad}}
|
|
|
|
*/
|
|
|
|
export function encryptAESBuffer(jwkOrKey, buff, additionalData = '') {
|
|
|
|
// TODO: Add assertion checks for JWK
|
|
|
|
const rawKey = typeof jwkOrKey === 'string' ? jwkOrKey : _b64UrlToHex(jwkOrKey.k);
|
|
|
|
const key = forge.util.hexToBytes(rawKey);
|
|
|
|
|
|
|
|
const iv = forge.random.getBytesSync(12);
|
|
|
|
const cipher = forge.cipher.createCipher('AES-GCM', key);
|
|
|
|
|
|
|
|
cipher.start({ additionalData, iv, tagLength: 128 });
|
|
|
|
cipher.update(forge.util.createBuffer(buff));
|
|
|
|
cipher.finish();
|
|
|
|
|
|
|
|
return {
|
|
|
|
iv: forge.util.bytesToHex(iv),
|
|
|
|
t: forge.util.bytesToHex(cipher.mode.tag),
|
|
|
|
ad: forge.util.bytesToHex(additionalData),
|
|
|
|
d: forge.util.bytesToHex(cipher.output),
|
|
|
|
};
|
2017-01-11 03:18:15 +00:00
|
|
|
}
|
2016-10-21 17:20:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Encrypt data using symmetric key
|
|
|
|
*
|
|
|
|
* @param jwkOrKey JWK or string representing symmetric key
|
|
|
|
* @param plaintext string of data to encrypt
|
|
|
|
* @param additionalData any additional public data to attach
|
|
|
|
* @returns {{iv, t, d, ad}}
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export function encryptAES(jwkOrKey, plaintext, additionalData = '') {
|
2016-10-21 17:20:36 +00:00
|
|
|
// TODO: Add assertion checks for JWK
|
2018-10-17 16:42:33 +00:00
|
|
|
const rawKey = typeof jwkOrKey === 'string' ? jwkOrKey : _b64UrlToHex(jwkOrKey.k);
|
2016-10-21 17:20:36 +00:00
|
|
|
const key = forge.util.hexToBytes(rawKey);
|
|
|
|
|
|
|
|
const iv = forge.random.getBytesSync(12);
|
|
|
|
const cipher = forge.cipher.createCipher('AES-GCM', key);
|
|
|
|
|
|
|
|
// Plaintext could contain weird unicode, so we have to encode that
|
|
|
|
const encodedPlaintext = encodeURIComponent(plaintext);
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
cipher.start({ additionalData, iv, tagLength: 128 });
|
2016-10-21 17:20:36 +00:00
|
|
|
cipher.update(forge.util.createBuffer(encodedPlaintext));
|
|
|
|
cipher.finish();
|
|
|
|
|
|
|
|
return {
|
|
|
|
iv: forge.util.bytesToHex(iv),
|
|
|
|
t: forge.util.bytesToHex(cipher.mode.tag),
|
2018-12-12 17:36:11 +00:00
|
|
|
ad: forge.util.bytesToHex(additionalData),
|
2019-04-18 00:50:03 +00:00
|
|
|
d: forge.util.bytesToHex(cipher.output),
|
2016-10-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decrypt AES using a key
|
|
|
|
*
|
|
|
|
* @param jwkOrKey JWK or string representing symmetric key
|
2019-04-18 00:50:03 +00:00
|
|
|
* @param encryptedResult encryption data
|
2016-10-21 17:20:36 +00:00
|
|
|
* @returns String
|
|
|
|
*/
|
2019-04-18 00:50:03 +00:00
|
|
|
export function decryptAES(jwkOrKey, encryptedResult) {
|
2016-10-21 17:20:36 +00:00
|
|
|
// TODO: Add assertion checks for JWK
|
2018-10-17 16:42:33 +00:00
|
|
|
const rawKey = typeof jwkOrKey === 'string' ? jwkOrKey : _b64UrlToHex(jwkOrKey.k);
|
2016-10-21 17:20:36 +00:00
|
|
|
const key = forge.util.hexToBytes(rawKey);
|
|
|
|
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~ //
|
|
|
|
// Decrypt with AES-GCM //
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~ //
|
|
|
|
|
|
|
|
const decipher = forge.cipher.createDecipher('AES-GCM', key);
|
|
|
|
decipher.start({
|
2019-04-18 00:50:03 +00:00
|
|
|
iv: forge.util.hexToBytes(encryptedResult.iv),
|
|
|
|
tagLength: encryptedResult.t.length * 4,
|
|
|
|
tag: forge.util.hexToBytes(encryptedResult.t),
|
|
|
|
additionalData: forge.util.hexToBytes(encryptedResult.ad),
|
2016-10-21 17:20:36 +00:00
|
|
|
});
|
|
|
|
|
2019-04-18 00:50:03 +00:00
|
|
|
decipher.update(forge.util.createBuffer(forge.util.hexToBytes(encryptedResult.d)));
|
2016-10-21 17:20:36 +00:00
|
|
|
|
|
|
|
if (decipher.finish()) {
|
2017-03-03 20:09:08 +00:00
|
|
|
return decodeURIComponent(decipher.output.toString());
|
2016-10-21 17:20:36 +00:00
|
|
|
} else {
|
2017-03-03 20:09:08 +00:00
|
|
|
throw new Error('Failed to decrypt data');
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-18 00:50:03 +00:00
|
|
|
* Decrypts AES using a key to buffer
|
|
|
|
* @param jwkOrKey
|
|
|
|
* @param encryptedResult
|
2016-10-21 17:20:36 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2019-04-18 00:50:03 +00:00
|
|
|
export function decryptAESToBuffer(jwkOrKey, encryptedResult) {
|
|
|
|
// TODO: Add assertion checks for JWK
|
|
|
|
const rawKey = typeof jwkOrKey === 'string' ? jwkOrKey : _b64UrlToHex(jwkOrKey.k);
|
|
|
|
const key = forge.util.hexToBytes(rawKey);
|
2016-10-21 17:20:36 +00:00
|
|
|
|
2019-04-18 00:50:03 +00:00
|
|
|
// ~~~~~~~~~~~~~~~~~~~~ //
|
|
|
|
// Decrypt with AES-GCM //
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~ //
|
|
|
|
|
|
|
|
const decipher = forge.cipher.createDecipher('AES-GCM', key);
|
|
|
|
decipher.start({
|
|
|
|
iv: forge.util.hexToBytes(encryptedResult.iv),
|
|
|
|
tagLength: encryptedResult.t.length * 4,
|
|
|
|
tag: forge.util.hexToBytes(encryptedResult.t),
|
|
|
|
additionalData: forge.util.hexToBytes(encryptedResult.ad),
|
|
|
|
});
|
|
|
|
|
|
|
|
decipher.update(forge.util.createBuffer(forge.util.hexToBytes(encryptedResult.d)));
|
|
|
|
|
|
|
|
if (decipher.finish()) {
|
|
|
|
return Buffer.from(forge.util.bytesToHex(decipher.output), 'hex');
|
|
|
|
} else {
|
|
|
|
throw new Error('Failed to decrypt data');
|
|
|
|
}
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a random key
|
|
|
|
*
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export function srpGenKey() {
|
2016-10-21 17:20:36 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
srp.genKey((err, secret1Buffer) => {
|
|
|
|
if (err) {
|
|
|
|
reject(err);
|
|
|
|
} else {
|
2017-03-03 20:09:08 +00:00
|
|
|
resolve(secret1Buffer.toString('hex'));
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
});
|
2017-03-03 20:09:08 +00:00
|
|
|
});
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a random AES256 key for use with symmetric encryption
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function generateAES256Key() {
|
2016-10-21 17:20:36 +00:00
|
|
|
const c = window.crypto;
|
|
|
|
const subtle = c ? c.subtle || c.webkitSubtle : null;
|
|
|
|
|
|
|
|
if (subtle) {
|
2017-11-22 00:07:28 +00:00
|
|
|
console.log('[crypt] Using Native AES Key Generation');
|
2018-10-17 16:42:33 +00:00
|
|
|
const key = await subtle.generateKey({ name: 'AES-GCM', length: 256 }, true, [
|
|
|
|
'encrypt',
|
2018-12-12 17:36:11 +00:00
|
|
|
'decrypt',
|
2018-10-17 16:42:33 +00:00
|
|
|
]);
|
2016-10-21 17:20:36 +00:00
|
|
|
return subtle.exportKey('jwk', key);
|
|
|
|
} else {
|
2017-11-22 00:07:28 +00:00
|
|
|
console.log('[crypt] Using Fallback Forge AES Key Generation');
|
2016-10-21 17:20:36 +00:00
|
|
|
const key = forge.util.bytesToHex(forge.random.getBytesSync(32));
|
|
|
|
return {
|
|
|
|
kty: 'oct',
|
|
|
|
alg: 'A256GCM',
|
|
|
|
ext: true,
|
|
|
|
key_ops: ['encrypt', 'decrypt'],
|
2018-12-12 17:36:11 +00:00
|
|
|
k: _hexToB64Url(key),
|
2016-10-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate RSA keypair JWK with 2048 bits and exponent 0x10001
|
|
|
|
*
|
|
|
|
* @returns Object
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function generateKeyPairJWK() {
|
2016-12-21 23:37:48 +00:00
|
|
|
// NOTE: Safari has crypto.webkitSubtle, but it does not support RSA-OAEP-SHA256
|
2016-10-21 17:20:36 +00:00
|
|
|
const subtle = window.crypto && window.crypto.subtle;
|
|
|
|
|
|
|
|
if (subtle) {
|
2017-11-22 00:07:28 +00:00
|
|
|
console.log('[crypt] Using Native RSA Generation');
|
2016-10-21 17:20:36 +00:00
|
|
|
|
2017-03-12 09:03:57 +00:00
|
|
|
const pair = await subtle.generateKey(
|
|
|
|
{
|
|
|
|
name: 'RSA-OAEP',
|
|
|
|
publicExponent: new Uint8Array([1, 0, 1]),
|
|
|
|
modulusLength: 2048,
|
2018-12-12 17:36:11 +00:00
|
|
|
hash: 'SHA-256',
|
2017-03-12 09:03:57 +00:00
|
|
|
},
|
2016-10-21 17:20:36 +00:00
|
|
|
true,
|
2018-12-12 17:36:11 +00:00
|
|
|
['encrypt', 'decrypt'],
|
2016-10-21 17:20:36 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
publicKey: await subtle.exportKey('jwk', pair.publicKey),
|
2018-12-12 17:36:11 +00:00
|
|
|
privateKey: await subtle.exportKey('jwk', pair.privateKey),
|
2016-10-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
} else {
|
2017-11-22 00:07:28 +00:00
|
|
|
console.log('[crypt] Using Forge RSA Generation');
|
2016-10-21 17:20:36 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
const pair = forge.pki.rsa.generateKeyPair({ bits: 2048, e: 0x10001 });
|
2016-10-21 17:20:36 +00:00
|
|
|
const privateKey = {
|
|
|
|
alg: 'RSA-OAEP-256',
|
|
|
|
kty: 'RSA',
|
|
|
|
key_ops: ['decrypt'],
|
|
|
|
ext: true,
|
|
|
|
d: _bigIntToB64Url(pair.privateKey.d),
|
|
|
|
dp: _bigIntToB64Url(pair.privateKey.dP),
|
|
|
|
dq: _bigIntToB64Url(pair.privateKey.dQ),
|
|
|
|
e: _bigIntToB64Url(pair.privateKey.e),
|
|
|
|
n: _bigIntToB64Url(pair.privateKey.n),
|
|
|
|
p: _bigIntToB64Url(pair.privateKey.p),
|
|
|
|
q: _bigIntToB64Url(pair.privateKey.q),
|
2018-12-12 17:36:11 +00:00
|
|
|
qi: _bigIntToB64Url(pair.privateKey.qInv),
|
2016-10-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const publicKey = {
|
|
|
|
alg: 'RSA-OAEP-256',
|
|
|
|
kty: 'RSA',
|
|
|
|
key_ops: ['encrypt'],
|
|
|
|
e: _bigIntToB64Url(pair.publicKey.e),
|
2018-12-12 17:36:11 +00:00
|
|
|
n: _bigIntToB64Url(pair.publicKey.n),
|
2016-10-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
return { privateKey, publicKey };
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ~~~~~~~~~~~~~~~~ //
|
|
|
|
// Helper Functions //
|
|
|
|
// ~~~~~~~~~~~~~~~~ //
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Combine email and raw salt into usable salt
|
|
|
|
*
|
|
|
|
* @param rawSalt
|
|
|
|
* @param rawEmail
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2019-04-18 00:50:03 +00:00
|
|
|
async function _hkdfSalt(rawSalt, rawEmail) {
|
2016-10-21 17:20:36 +00:00
|
|
|
return new Promise(resolve => {
|
|
|
|
const hkdf = new HKDF('sha256', rawSalt, rawEmail);
|
2018-10-17 16:42:33 +00:00
|
|
|
hkdf.derive('', DEFAULT_BYTE_LENGTH, buffer => resolve(buffer.toString('hex')));
|
2017-03-03 20:09:08 +00:00
|
|
|
});
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a JSBN BigInteger to a URL-safe version of base64 encoding. This
|
|
|
|
* should only be used for encoding JWKs
|
|
|
|
*
|
|
|
|
* @param n BigInteger
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
function _bigIntToB64Url(n) {
|
2016-10-21 17:20:36 +00:00
|
|
|
return _hexToB64Url(n.toString(16));
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
function _hexToB64Url(h) {
|
2016-10-21 17:20:36 +00:00
|
|
|
const bytes = forge.util.hexToBytes(h);
|
2018-06-25 17:42:50 +00:00
|
|
|
return window
|
|
|
|
.btoa(bytes)
|
2016-10-21 17:20:36 +00:00
|
|
|
.replace(/=/g, '')
|
|
|
|
.replace(/\+/g, '-')
|
|
|
|
.replace(/\//g, '_');
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
function _b64UrlToBigInt(s) {
|
2016-10-21 17:20:36 +00:00
|
|
|
return new forge.jsbn.BigInteger(_b64UrlToHex(s), 16);
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
function _b64UrlToHex(s) {
|
2016-10-21 17:20:36 +00:00
|
|
|
const b64 = s.replace(/-/g, '+').replace(/_/g, '/');
|
2017-03-03 20:09:08 +00:00
|
|
|
return forge.util.bytesToHex(window.atob(b64));
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Derive key from password
|
|
|
|
*
|
|
|
|
* @param passphrase
|
|
|
|
* @param salt hex representation of salt
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
async function _pbkdf2Passphrase(passphrase, salt) {
|
2016-10-21 17:20:36 +00:00
|
|
|
if (window.crypto && window.crypto.subtle) {
|
2017-11-22 00:07:28 +00:00
|
|
|
console.log('[crypt] Using native PBKDF2');
|
2016-10-21 17:20:36 +00:00
|
|
|
|
|
|
|
const k = await window.crypto.subtle.importKey(
|
|
|
|
'raw',
|
|
|
|
Buffer.from(passphrase, 'utf8'),
|
2018-06-25 17:42:50 +00:00
|
|
|
{ name: 'PBKDF2' },
|
2017-03-12 09:03:57 +00:00
|
|
|
false,
|
2018-12-12 17:36:11 +00:00
|
|
|
['deriveBits'],
|
2016-10-21 17:20:36 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const algo = {
|
|
|
|
name: 'PBKDF2',
|
2017-11-20 16:07:36 +00:00
|
|
|
salt: Buffer.from(salt, 'hex'),
|
2016-10-21 17:20:36 +00:00
|
|
|
iterations: DEFAULT_PBKDF2_ITERATIONS,
|
2018-12-12 17:36:11 +00:00
|
|
|
hash: 'SHA-256',
|
2016-10-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
|
2018-10-17 16:42:33 +00:00
|
|
|
const derivedKeyRaw = await window.crypto.subtle.deriveBits(algo, k, DEFAULT_BYTE_LENGTH * 8);
|
2017-11-20 16:07:36 +00:00
|
|
|
return Buffer.from(derivedKeyRaw).toString('hex');
|
2016-10-21 17:20:36 +00:00
|
|
|
} else {
|
2017-11-22 00:07:28 +00:00
|
|
|
console.log('[crypt] Using Forge PBKDF2');
|
2016-12-21 23:37:48 +00:00
|
|
|
const derivedKeyRaw = forge.pkcs5.pbkdf2(
|
2016-10-21 17:20:36 +00:00
|
|
|
passphrase,
|
2016-12-21 23:37:48 +00:00
|
|
|
forge.util.hexToBytes(salt),
|
2016-10-21 17:20:36 +00:00
|
|
|
DEFAULT_PBKDF2_ITERATIONS,
|
2016-12-21 23:37:48 +00:00
|
|
|
DEFAULT_BYTE_LENGTH,
|
2018-12-12 17:36:11 +00:00
|
|
|
forge.md.sha256.create(),
|
2016-10-21 17:20:36 +00:00
|
|
|
);
|
|
|
|
|
2016-12-21 23:37:48 +00:00
|
|
|
return forge.util.bytesToHex(derivedKeyRaw);
|
2016-10-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
}
|