Bug 1410861 - Support for `unwrapKey` of ECDH/ECDSA keys r=keeler

Differential Revision: https://phabricator.services.mozilla.com/D97711
This commit is contained in:
Christoph Walcher 2021-02-22 22:15:57 +00:00
Родитель e83b8b7220
Коммит 0a52b7c0ad
4 изменённых файлов: 51 добавлений и 242 удалений

Просмотреть файл

@ -3201,6 +3201,11 @@ WebCryptoTask* WebCryptoTask::CreateUnwrapKeyTask(
importTask = importTask =
new ImportRsaKeyTask(aGlobal, aCx, aFormat, aUnwrappedKeyAlgorithm, new ImportRsaKeyTask(aGlobal, aCx, aFormat, aUnwrappedKeyAlgorithm,
aExtractable, aKeyUsages); aExtractable, aKeyUsages);
} else if (keyAlgName.EqualsLiteral(WEBCRYPTO_ALG_ECDH) ||
keyAlgName.EqualsLiteral(WEBCRYPTO_ALG_ECDSA)) {
importTask =
new ImportEcKeyTask(aGlobal, aCx, aFormat, aUnwrappedKeyAlgorithm,
aExtractable, aKeyUsages);
} else { } else {
return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
} }

Просмотреть файл

@ -179,7 +179,7 @@ TestArray.addTest(
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TestArray.addTest( TestArray.addTest(
"JWK wrap/unwrap round-trip, with AES-GCM", "HMAC JWK wrap/unwrap round-trip, with AES-GCM",
function() { function() {
var that = this; var that = this;
var genAlg = { name: "HMAC", hash: "SHA-384", length: 512 }; 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( TestArray.addTest(
"AES-KW known answer", "AES-KW known answer",

Просмотреть файл

@ -16,39 +16,9 @@
[Can unwrap AES-KW non-extractable keys using jwk and AES-CBC] [Can unwrap AES-KW non-extractable keys using jwk and AES-CBC]
expected: FAIL 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] [Could not run all tests]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-GCM]
expected: FAIL expected: FAIL
@ -64,36 +34,6 @@
[Can unwrap AES-KW non-extractable keys using jwk and AES-GCM] [Can unwrap AES-KW non-extractable keys using jwk and AES-GCM]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-CTR]
expected: FAIL expected: FAIL
@ -109,36 +49,6 @@
[Can unwrap AES-KW non-extractable keys using jwk and AES-CTR] [Can unwrap AES-KW non-extractable keys using jwk and AES-CTR]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-KW]
expected: FAIL expected: FAIL
@ -160,33 +70,3 @@
[Can unwrap AES-KW non-extractable keys using jwk and RSA-OAEP] [Can unwrap AES-KW non-extractable keys using jwk and RSA-OAEP]
expected: FAIL 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

Просмотреть файл

@ -2,24 +2,9 @@ implementation-status: backlog
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922 bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1631922
[wrapKey_unwrapKey.https.worker.html] [wrapKey_unwrapKey.https.worker.html]
expected: TIMEOUT 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] [Could not run all tests]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-CTR]
expected: FAIL 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] [Can unwrap AES-KW non-extractable keys using jwk and AES-CTR]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-CBC]
expected: FAIL 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] [Can unwrap AES-KW non-extractable keys using jwk and AES-CBC]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-GCM]
expected: FAIL 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] [Can unwrap AES-KW non-extractable keys using jwk and AES-GCM]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and AES-KW]
expected: FAIL expected: FAIL
[Can wrap and unwrap AES-KW keys as non-extractable using raw and AES-KW] [Can wrap and unwrap AES-KW keys as non-extractable using raw and AES-KW]
expected: FAIL 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] [Can wrap and unwrap AES-KW keys using raw and RSA-OAEP]
expected: FAIL 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] [Can unwrap AES-KW non-extractable keys using jwk and RSA-OAEP]
expected: FAIL 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