mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
polyfill sha512 hmac on ie
This commit is contained in:
@@ -60,6 +60,15 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async hmac(value: ArrayBuffer, key: ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512'): Promise<ArrayBuffer> {
|
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 = {
|
const signingAlgorithm = {
|
||||||
name: 'HMAC',
|
name: 'HMAC',
|
||||||
hash: { name: this.toWebCryptoAlgorithm(algorithm) },
|
hash: { name: this.toWebCryptoAlgorithm(algorithm) },
|
||||||
|
|||||||
Reference in New Issue
Block a user