From 00045d7cb02b9e7991217aad94c12e717e284ffa Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 30 Dec 2017 14:15:11 +0000 Subject: [PATCH] CryptoManager: Add an option to load an already derived key. --- src/api/Crypto.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/Crypto.ts b/src/api/Crypto.ts index 72ea122..75c8d2c 100644 --- a/src/api/Crypto.ts +++ b/src/api/Crypto.ts @@ -39,6 +39,14 @@ export class CryptoManager { cipherWords = 4; + static fromDerivedKey(key: byte[], version: number = Constants.CURRENT_VERSION) { + // FIXME: Cleanup this hack + const ret = new CryptoManager('', '', version); + ret.key = sjcl.codec.bytes.toBits(key); + ret._updateDerivedKeys(); + return ret; + } + constructor(_keyBase64: base64, salt: string, version: number = Constants.CURRENT_VERSION) { this.version = version; let key = sjcl.codec.base64.toBits(_keyBase64);