★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/e9abf42751Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
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>
  • Loading branch information
teorossi82 authored and rvagg committed Nov 28, 2018
1 parent 237e479 commit e9abf4275107ee4ab7a2c861220b4d4a73a6f027
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/parallel/test-crypto-keygen.js
@@ -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',

0 comments on commit e9abf42

Please sign in to comment.