mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: add typeerror test for EC crypto keygen
PR-URL: https://github.com/nodejs/node/pull/24400 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -625,6 +625,22 @@ function convertDERToPEM(label, der) {
|
||||
message: 'Invalid ECDH curve name'
|
||||
});
|
||||
|
||||
// Test error type when curve is not a string
|
||||
for (const namedCurve of [true, {}, [], 123]) {
|
||||
common.expectsError(() => {
|
||||
generateKeyPairSync('ec', {
|
||||
namedCurve,
|
||||
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
||||
privateKeyEncoding: { type: 'sec1', format: 'pem' }
|
||||
});
|
||||
}, {
|
||||
type: TypeError,
|
||||
code: 'ERR_INVALID_OPT_VALUE',
|
||||
message: `The value "${namedCurve}" is invalid for option ` +
|
||||
'"namedCurve"'
|
||||
});
|
||||
}
|
||||
|
||||
// It should recognize both NIST and standard curve names.
|
||||
generateKeyPair('ec', {
|
||||
namedCurve: 'P-192',
|
||||
|
||||
Reference in New Issue
Block a user