Skip to content

Commit 29482d8

Browse files
committed
fixup! crypto: optimize private EC JWK import
1 parent 4b09a2f commit 29482d8

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,10 @@ KeyObjectData ImportJWKEcKey(Environment* env, Local<Object> jwk) {
764764

765765
auto pkey = EVPKeyPointer::New();
766766
if (!pkey) return {};
767-
CHECK(pkey.set(ec));
767+
if (!pkey.set(ec)) {
768+
THROW_ERR_CRYPTO_INVALID_JWK(env, "Invalid JWK EC key");
769+
return {};
770+
}
768771

769772
return KeyObjectData::CreateAsymmetric(type, std::move(pkey));
770773
}

‎test/parallel/test-crypto-key-objects-ec-jwk-private.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
createECDH,
1010
createPrivateKey,
1111
createPublicKey,
12+
getCurves,
1213
getFips,
1314
sign,
1415
verify,
@@ -24,7 +25,7 @@ const curves = [
2425
'01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' +
2526
'fa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409'],
2627
];
27-
if (!getFips()) {
28+
if (!getFips() && getCurves().includes('secp256k1')) {
2829
curves.push(['secp256k1', 'secp256k1', 32,
2930
'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141']);
3031
}

0 commit comments

Comments
 (0)