diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-02-08 18:48:28 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-08 18:48:28 +0530 |
commit | e218d567d5af0f778541c4b81f171d4fb1427db1 (patch) | |
tree | c782c1c564d36cebaebd5c97d3fca28fc5470998 /cli/tests/unit/webcrypto_test.ts | |
parent | 4799aaac15285833341d1e0471a2559bd325982f (diff) |
fix(ext/crypto): support EC p256 private key material in exportKey (#13547)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'cli/tests/unit/webcrypto_test.ts')
-rw-r--r-- | cli/tests/unit/webcrypto_test.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index ba6aaa327..0e7e2829a 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -1668,3 +1668,19 @@ Deno.test(async function testAesGcmTagLength() { ); }); }); + +Deno.test(async function ecPrivateKeyMaterialExportSpki() { + // `generateKey` generates a key pair internally stored as "private" key. + const keys = await crypto.subtle.generateKey( + { name: "ECDSA", namedCurve: "P-256" }, + true, + ["sign", "verify"], + ); + + assert(keys.privateKey instanceof CryptoKey); + assert(keys.publicKey instanceof CryptoKey); + + // `exportKey` should be able to perform necessary conversion to export spki. + const spki = await crypto.subtle.exportKey("spki", keys.publicKey); + assert(spki instanceof ArrayBuffer); +}); |