diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-10-01 15:09:49 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 11:39:49 +0200 |
commit | 5065c7bcd9973056b9b0d9df71d139da83596acc (patch) | |
tree | 9188d8d4ea205ced64bce070e631fff0996fd283 /cli/tests | |
parent | b354eaa2475a16f66e99efc82bebf5bd620406e4 (diff) |
feat(ext/crypto): implement wrapKey (#12125)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/webcrypto_test.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index 56a23bfb5..493cf9517 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -499,3 +499,40 @@ unitTest(async function testHkdfDeriveBits() { ); assertEquals(result.byteLength, 128 / 8); }); + +unitTest(async function testWrapKey() { + // Test wrapKey + const key = await crypto.subtle.generateKey( + { + name: "RSA-OAEP", + modulusLength: 4096, + publicExponent: new Uint8Array([1, 0, 1]), + hash: "SHA-256", + }, + true, + ["wrapKey", "unwrapKey"], + ); + + const hmacKey = await crypto.subtle.generateKey( + { + name: "HMAC", + hash: "SHA-256", + length: 128, + }, + true, + ["sign"], + ); + + const wrappedKey = await crypto.subtle.wrapKey( + "raw", + hmacKey, + key.publicKey, + { + name: "RSA-OAEP", + label: new Uint8Array(8), + }, + ); + + assert(wrappedKey instanceof ArrayBuffer); + assertEquals(wrappedKey.byteLength, 512); +}); |