test: add secp224k1 check in crypto-dh-stateless

This commit adds a check to test-crypto-dh-statless to avoid an error if
the curve secp224k1 is not present. This could occur if node was
configured with shared-openssl.

The use case for this was building on RHEL 8.1 which only has the
following curves:
$ openssl ecparam -list_curves
secp224r1 : NIST/SECG curve over a 224 bit prime field
secp256k1 : SECG curve over a 256 bit prime field
secp384r1 : NIST/SECG curve over a 384 bit prime field
secp521r1 : NIST/SECG curve over a 521 bit prime field
prime256v1: X9.62/SECG curve over a 256 bit prime field

PR-URL: https://github.com/nodejs/node/pull/31715
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Daniel Bevenius authored and Michaël Zasso committed 2020-04-28 16:00:47 +02:00
1 parent 6348fae690
commit d1d22fa86e
1 file changed
+2 -1
+2 -1
View File
@@ -196,9 +196,10 @@ for (const [params1, params2] of [
test(crypto.generateKeyPairSync('ec', { namedCurve: 'secp256k1' }),
crypto.generateKeyPairSync('ec', { namedCurve: 'secp256k1' }));
const not256k1 = crypto.getCurves().find((c) => /^sec.*(224|384|512)/.test(c));
assert.throws(() => {
test(crypto.generateKeyPairSync('ec', { namedCurve: 'secp256k1' }),
crypto.generateKeyPairSync('ec', { namedCurve: 'secp224k1' }));
crypto.generateKeyPairSync('ec', { namedCurve: not256k1 }));
}, {
name: 'Error',
code: 'ERR_OSSL_EVP_DIFFERENT_PARAMETERS'