diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp index afe9fb75525c..93c41a7746d0 100644 --- a/dom/crypto/WebCryptoTask.cpp +++ b/dom/crypto/WebCryptoTask.cpp @@ -3201,6 +3201,11 @@ WebCryptoTask* WebCryptoTask::CreateUnwrapKeyTask( importTask = new ImportRsaKeyTask(aGlobal, aCx, aFormat, aUnwrappedKeyAlgorithm, aExtractable, aKeyUsages); + } else if (keyAlgName.EqualsLiteral(WEBCRYPTO_ALG_ECDH) || + keyAlgName.EqualsLiteral(WEBCRYPTO_ALG_ECDSA)) { + importTask = + new ImportEcKeyTask(aGlobal, aCx, aFormat, aUnwrappedKeyAlgorithm, + aExtractable, aKeyUsages); } else { return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR); } diff --git a/dom/crypto/test/test_WebCrypto_Wrap_Unwrap.html b/dom/crypto/test/test_WebCrypto_Wrap_Unwrap.html index 09eb1432dfaa..8741d5f264c8 100644 --- a/dom/crypto/test/test_WebCrypto_Wrap_Unwrap.html +++ b/dom/crypto/test/test_WebCrypto_Wrap_Unwrap.html @@ -179,7 +179,7 @@ TestArray.addTest( // ----------------------------------------------------------------------------- TestArray.addTest( - "JWK wrap/unwrap round-trip, with AES-GCM", + "HMAC JWK wrap/unwrap round-trip, with AES-GCM", function() { var that = this; var genAlg = { name: "HMAC", hash: "SHA-384", length: 512 }; @@ -219,6 +219,51 @@ TestArray.addTest( } ); +// ----------------------------------------------------------------------------- +TestArray.addTest( + "ECDSA private JWK wrap/unwrap round-trip, with AES-GCM", + function() { + var that = this; + var genAlg = { name: "ECDSA", namedCurve: "P-256" }; + var wrapAlg = { name: "AES-GCM", iv: tv.aes_gcm_enc.iv }; + var wrapKey, originalKey, originalKeyJwk; + + function doExport(k) { + return crypto.subtle.exportKey("jwk", k); + } + function doWrap() { + return crypto.subtle.wrapKey("jwk", originalKey, wrapKey, wrapAlg); + } + function doUnwrap(wrappedKey) { + return crypto.subtle.unwrapKey("jwk", wrappedKey, wrapKey, wrapAlg, + genAlg, true, ["sign"]); + } + + Promise.all([ + crypto.subtle.importKey("jwk", tv.aes_gcm_enc.key_jwk, + "AES-GCM", false, ["wrapKey", "unwrapKey"]) + .then(function(x) { wrapKey = x; }), + crypto.subtle.generateKey(genAlg, true, ["sign", "verify"]) + .then(function(x) { originalKey = x.privateKey; return x.privateKey; }) + .then(doExport) + .then(function(x) { originalKeyJwk = x; }), + ]) + .then(doWrap) + .then(doUnwrap) + .then(doExport) + .then( + complete(that, function(x) { + return (x.kty == originalKeyJwk.kty) && + (x.crv == originalKeyJwk.crv) && + (x.d == originalKeyJwk.d) && + (x.x == originalKeyJwk.x) && + (x.y == originalKeyJwk.y); + }), + error(that) + ); + } +); + // ----------------------------------------------------------------------------- TestArray.addTest( "AES-KW known answer", diff --git a/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html.ini b/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html.ini index 6955e051497d..327d6209d833 100644 --- a/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html.ini +++ b/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html.ini @@ -16,39 +16,9 @@ [Can unwrap AES-KW non-extractable keys using jwk and AES-CBC] expected: FAIL - [Can wrap and unwrap ECDH public key keys using spki and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and AES-CBC] - expected: FAIL - [Could not run all tests] expected: FAIL - [Can wrap and unwrap ECDH private key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and AES-CBC] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using spki and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and AES-CBC] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and AES-CBC] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-GCM] expected: FAIL @@ -64,36 +34,6 @@ [Can unwrap AES-KW non-extractable keys using jwk and AES-GCM] expected: FAIL - [Can wrap and unwrap ECDH public key keys using spki and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and AES-GCM] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using spki and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and AES-GCM] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and AES-GCM] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-CTR] expected: FAIL @@ -109,36 +49,6 @@ [Can unwrap AES-KW non-extractable keys using jwk and AES-CTR] expected: FAIL - [Can wrap and unwrap ECDH public key keys using spki and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and AES-CTR] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using spki and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and AES-CTR] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and AES-CTR] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-KW] expected: FAIL @@ -160,33 +70,3 @@ [Can unwrap AES-KW non-extractable keys using jwk and RSA-OAEP] expected: FAIL - [Can wrap and unwrap ECDH public key keys using spki and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and RSA-OAEP] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using spki and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and RSA-OAEP] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and RSA-OAEP] - expected: FAIL - diff --git a/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.worker.js.ini b/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.worker.js.ini index 7b975d51115c..7ab0e909160a 100644 --- a/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.worker.js.ini +++ b/testing/web-platform/meta/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.worker.js.ini @@ -2,24 +2,9 @@ implementation-status: backlog bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922 [wrapKey_unwrapKey.https.worker.html] expected: TIMEOUT - [Can wrap and unwrap ECDH public key keys using spki and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and AES-CTR] - expected: FAIL - [Could not run all tests] expected: FAIL - [Can wrap and unwrap ECDH private key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and AES-CTR] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and AES-CTR] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-CTR] expected: FAIL @@ -35,36 +20,6 @@ bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922 [Can unwrap AES-KW non-extractable keys using jwk and AES-CTR] expected: FAIL - [Can wrap and unwrap ECDSA public key keys using spki and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and AES-CTR] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and AES-CTR] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using spki and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and AES-CBC] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and AES-CBC] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-CBC] expected: FAIL @@ -80,36 +35,6 @@ bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922 [Can unwrap AES-KW non-extractable keys using jwk and AES-CBC] expected: FAIL - [Can wrap and unwrap ECDSA public key keys using spki and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and AES-CBC] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and AES-CBC] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using spki and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and AES-GCM] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and AES-GCM] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-GCM] expected: FAIL @@ -125,42 +50,12 @@ bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922 [Can unwrap AES-KW non-extractable keys using jwk and AES-GCM] expected: FAIL - [Can wrap and unwrap ECDSA public key keys using spki and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and AES-GCM] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and AES-GCM] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and AES-GCM] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and AES-KW] expected: FAIL [Can wrap and unwrap AES-KW keys as non-extractable using raw and AES-KW] expected: FAIL - [Can wrap and unwrap ECDH public key keys using spki and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDH public key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDH private key keys as non-extractable using jwk and RSA-OAEP] - expected: FAIL - - [Can unwrap ECDH private key non-extractable keys using jwk and RSA-OAEP] - expected: FAIL - [Can wrap and unwrap AES-KW keys using raw and RSA-OAEP] expected: FAIL @@ -175,19 +70,3 @@ bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922 [Can unwrap AES-KW non-extractable keys using jwk and RSA-OAEP] expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using spki and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA public key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys using jwk and RSA-OAEP] - expected: FAIL - - [Can wrap and unwrap ECDSA private key keys as non-extractable using jwk and RSA-OAEP] - expected: FAIL - - [Can unwrap ECDSA private key non-extractable keys using jwk and RSA-OAEP] - expected: FAIL -