Fix CDS fetches; use proper hashing mechanism

This commit is contained in:
Scott Nonnenberg 2021-04-07 14:27:40 -07:00 committed by GitHub
parent e4db9358cf
commit a1c534ec0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View file

@ -5,12 +5,21 @@ import { assert } from 'chai';
import crypto from 'crypto';
import { typedArrayToArrayBuffer as toArrayBuffer } from '../../Crypto';
import { hash, sign, encrypt, decrypt } from '../../util/synchronousCrypto';
import {
HashType,
hash,
sign,
encrypt,
decrypt,
} from '../../util/synchronousCrypto';
describe('synchronousCrypto', () => {
describe('hash', () => {
it('returns SHA512 hash of the input', () => {
const result = hash(toArrayBuffer(Buffer.from('signal')));
const result = hash(
HashType.size512,
toArrayBuffer(Buffer.from('signal'))
);
assert.strictEqual(
Buffer.from(result).toString('base64'),
'WxneQjrfSlY95Bi+SAzDAr2cf3mxUXePeNYn6DILN4a8NFr9VelTbP5tGHdthi+' +