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:
parent
2bc7c42733
commit
a67ea2422f
@ -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) },
|
||||
|
Loading…
Reference in New Issue
Block a user