From 91399851809b2c1585b318d496e81f9683cd270b Mon Sep 17 00:00:00 2001 From: Sean Michael Wykes <8363933+SeanWykes@users.noreply.github.com> Date: Wed, 19 Jan 2022 03:44:35 -0300 Subject: feat(ext/crypto): implement pkcs8/JWK for P-384 curves (#13154) --- cli/tests/unit/webcrypto_test.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'cli') diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index a318e730d..84cf7d4ca 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -1200,10 +1200,7 @@ Deno.test(async function testImportExportEcDsaJwk() { for ( const [_key, keyData] of Object.entries(jwtECKeys) ) { - const { size, publicJWK, privateJWK, algo } = keyData; - if (size != 256) { - continue; - } + const { publicJWK, privateJWK, algo } = keyData; // 1. Test import EcDsa const privateKeyECDSA = await subtle.importKey( @@ -1268,9 +1265,6 @@ Deno.test(async function testImportEcDhJwk() { const [_key, jwkData] of Object.entries(jwtECKeys) ) { const { size, publicJWK, privateJWK } = jwkData; - if (size != 256) { - continue; - } // 1. Test import EcDsa const privateKeyECDH = await subtle.importKey( @@ -1308,6 +1302,11 @@ Deno.test(async function testImportEcDhJwk() { ); assert(equalJwk(publicJWK, expPublicKeyJWK as JWK)); + // deriveBits still not implemented for P384 + if (size != 256) { + continue; + } + const derivedKey = await subtle.deriveBits( { name: "ECDH", @@ -1406,6 +1405,13 @@ Deno.test(async function testImportEcSpkiPkcs8() { for ( const hash of [/*"SHA-1", */ "SHA-256", "SHA-384" /*"SHA-512"*/] ) { + if ( + (hash == "SHA-256" && namedCurve != "P-256") || + (hash == "SHA-384" && namedCurve != "P-384") + ) { + continue; + } + const signatureECDSA = await subtle.sign( { name: "ECDSA", hash }, privateKeyECDSA, -- cgit v1.2.3