diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-09-13 02:32:49 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-12 23:02:49 +0200 |
commit | 0520ae62dd2f4e61287315bbfcd548864d46da45 (patch) | |
tree | 41c9ad4bc75d3444051beddbb574579dd6e1fd3d /cli/tests | |
parent | 13991e5995a5bc8a11bcf2bd7d23168a15536c83 (diff) |
fix(ext/crypto): add HkdfParams and Pkdf2Params types (#11991)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/webcrypto_test.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index a5de9fa36..57ab051d1 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -356,3 +356,27 @@ unitTest(async function subtleCryptoHmacImportExport() { const exportedKey2 = await crypto.subtle.exportKey("jwk", key2); assertEquals(exportedKey2, jwk); }); + +unitTest(async function testHkdfDeriveBits() { + const rawKey = await crypto.getRandomValues(new Uint8Array(16)); + const key = await crypto.subtle.importKey( + "raw", + rawKey, + { name: "HKDF", hash: "SHA-256" }, + false, + ["deriveBits"], + ); + const salt = await crypto.getRandomValues(new Uint8Array(16)); + const info = await crypto.getRandomValues(new Uint8Array(16)); + const result = await crypto.subtle.deriveBits( + { + name: "HKDF", + hash: "SHA-256", + salt: salt, + info: info, + }, + key, + 128, + ); + assertEquals(result.byteLength, 128 / 8); +}); |