Bug 1410403 - Use id-ecPublicKey for ECDH key export from WebCrypto r=keeler

id-ecPublicKey is defined as the OID {iso(1) member-body(2) us(840)
ansi-x962(10045) keyType(2) ecPublicKey(1)}, and is the NSS default, so
remove the override code from CryptoKey.cpp that forced it to the legacy
id-ecDH code.

Differential Revision: https://phabricator.services.mozilla.com/D52570

--HG--
extra : moz-landing-system : lando
This commit is contained in:
J.C. Jones 2019-11-11 21:25:40 +00:00
Родитель 9c614370ec
Коммит 529346ab71
2 изменённых файлов: 2 добавлений и 13 удалений

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

@ -450,7 +450,7 @@ UniqueSECKEYPublicKey CryptoKey::PublicKeyFromSpki(CryptoBuffer& aKeyData) {
bool isECDHAlgorithm =
SECITEM_ItemsAreEqual(&SEC_OID_DATA_EC_DH, &spki->algorithm.algorithm);
// Check for |id-ecDH|. Per the WebCrypto spec we must
// Check for |id-ecDH|. Per old versions of the WebCrypto spec we must
// support this OID but NSS does unfortunately not know it. Let's
// change the algorithm to |id-ecPublicKey| to make NSS happy.
if (isECDHAlgorithm) {
@ -497,17 +497,6 @@ nsresult CryptoKey::PublicKeyToSpki(SECKEYPublicKey* aPubKey,
return NS_ERROR_DOM_OPERATION_ERR;
}
// Per WebCrypto spec we must export ECDH SPKIs with the algorithm OID
// id-ecDH (1.3.132.112). NSS doesn't know about this OID and there is
// no way to specify the algorithm to use when exporting a public key.
if (aPubKey->keyType == ecKey) {
SECStatus rv = SECITEM_CopyItem(spki->arena, &spki->algorithm.algorithm,
&SEC_OID_DATA_EC_DH);
if (rv != SECSuccess) {
return NS_ERROR_DOM_OPERATION_ERR;
}
}
const SEC_ASN1Template* tpl = SEC_ASN1_GET(CERT_SubjectPublicKeyInfoTemplate);
UniqueSECItem spkiItem(SEC_ASN1EncodeItem(nullptr, nullptr, spki.get(), tpl));

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

@ -394,7 +394,7 @@ TestArray.addTest(
var derived = imported.then(doExport);
return derived.then(function(x) {
if (!util.memcmp(x, tv.ecdh_p256.spki)) {
if (!util.memcmp(x, tv.ecdh_p256.spki_id_ecpk)) {
throw new Error("exported key is invalid");
}