polyfill sha512 hmac on ie

This commit is contained in:
Kyle Spearrin 2018-08-22 08:53:52 -04:00
parent 2bc7c42733
commit a67ea2422f
1 changed files with 9 additions and 0 deletions

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) },