From d0c9a9c55924e0967d83f92313beba0c18e4cfe4 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 28 May 2019 15:29:27 +0100 Subject: [PATCH] Crypto: Add function to get cryptomanager's encryption key. --- src/api/Crypto.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/Crypto.ts b/src/api/Crypto.ts index 0fb80bc..d80f8e7 100644 --- a/src/api/Crypto.ts +++ b/src/api/Crypto.ts @@ -105,6 +105,11 @@ export class CryptoManager { return sjcl.codec.utf8String.fromBits(this.decryptBits(content)); } + public getEncryptedKey(keyPair: AsymmetricKeyPair, publicKey: byte[]) { + const cryptoManager = new AsymmetricCryptoManager(keyPair); + return cryptoManager.encryptBytes(publicKey, sjcl.codec.bytes.fromBits(this.key)); + } + public hmac(content: byte[]): byte[] { return sjcl.codec.bytes.fromBits(this.hmacBase(content)); }