Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94553b2

Browse filesBrowse 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
Copy full SHA for 94553b2

File tree

Expand file treeCollapse file tree

1 file changed

+16
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-0
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-keygen.js
+16Lines 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 (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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.