From a67ea2422f082c6b884a3c7187e17a318048f7f5 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 22 Aug 2018 08:53:52 -0400 Subject: [PATCH] polyfill sha512 hmac on ie --- src/services/webCryptoFunction.service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/webCryptoFunction.service.ts b/src/services/webCryptoFunction.service.ts index aa8d3f47ae..1706603ef7 100644 --- a/src/services/webCryptoFunction.service.ts +++ b/src/services/webCryptoFunction.service.ts @@ -60,6 +60,15 @@ export class WebCryptoFunctionService implements CryptoFunctionService { } async hmac(value: ArrayBuffer, key: ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512'): Promise { + 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) },