1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

polyfill sha512 hmac on ie

This commit is contained in:
Kyle Spearrin 2018-08-22 08:53:52 -04:00
parent 2bc7c42733
commit a67ea2422f

View File

@ -60,6 +60,15 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
}
async hmac(value: ArrayBuffer, key: ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512'): Promise<ArrayBuffer> {
if (this.isIE && algorithm === 'sha512') {
const hmac = (forge as any).hmac.create();
const keyBytes = this.toByteString(key);
const valueBytes = this.toByteString(value);
hmac.start(algorithm, keyBytes);
hmac.update(valueBytes, 'raw');
return Utils.fromByteStringToArray(hmac.digest().data).buffer;
}
const signingAlgorithm = {
name: 'HMAC',
hash: { name: this.toWebCryptoAlgorithm(algorithm) },