Crypto: Add function to get cryptomanager's encryption key.

master
Tom Hacohen 2019-05-28 15:29:27 +01:00
parent 34e6fc3668
commit d0c9a9c559
1 changed files with 5 additions and 0 deletions

View File

@ -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));
}