Skip to content

Commit e9abf42

Browse files
teorossi82rvagg
authored andcommitted
test: add typeerror test for EC crypto keygen
PR-URL: #24400 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 237e479 commit e9abf42

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/parallel/test-crypto-keygen.js

+16
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,22 @@ function convertDERToPEM(label, der) {
625625
message: 'Invalid ECDH curve name'
626626
});
627627

628+
// Test error type when curve is not a string
629+
for (const namedCurve of [true, {}, [], 123]) {
630+
common.expectsError(() => {
631+
generateKeyPairSync('ec', {
632+
namedCurve,
633+
publicKeyEncoding: { type: 'spki', format: 'pem' },
634+
privateKeyEncoding: { type: 'sec1', format: 'pem' }
635+
});
636+
}, {
637+
type: TypeError,
638+
code: 'ERR_INVALID_OPT_VALUE',
639+
message: `The value "${namedCurve}" is invalid for option ` +
640+
'"namedCurve"'
641+
});
642+
}
643+
628644
// It should recognize both NIST and standard curve names.
629645
generateKeyPair('ec', {
630646
namedCurve: 'P-192',

0 commit comments

Comments
 (0)