Skip to content

Commit 94553b2

Browse files
teorossi82codebytere
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 4425926 commit 94553b2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎test/parallel/test-crypto-keygen.js‎

Lines changed: 16 additions & 0 deletions
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(constnamedCurveof[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)