GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: validate key generation options · nodejs/node@ac954d2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/crypto
    • keygen.js
  • test/parallel
    • test-crypto-keygen.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/keygen.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/keygen.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ const nidOnlyKeyPairs = {
209209
function createJob(mode, type, options) {
210210
validateString(type, 'type');
211211

212-
const encoding = new SafeArrayIterator(parseKeyEncoding(type, options));
213-
214212
if (options !== undefined)
215213
validateObject(options, 'options');
216214

215+
const encoding = new SafeArrayIterator(parseKeyEncoding(type, options));
216+
217217
switch (type) {
218218
case 'rsa':
219219
case 'rsa-pss':
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-keygen.js
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ const isBoringSSL = process.features.openssl_is_boringssl;
8989
message: 'The "options" argument must be of type object. ' +
9090
'Received type number (0)'
9191
});
92+
93+
for (const type of ['rsa', 'ed25519']) {
94+
assert.throws(() => generateKeyPairSync(type, null), {
95+
name: 'TypeError',
96+
code: 'ERR_INVALID_ARG_TYPE',
97+
message: 'The "options" argument must be of type object. ' +
98+
'Received null'
99+
});
100+
assert.throws(() => generateKeyPair(type, null, common.mustNotCall()), {
101+
name: 'TypeError',
102+
code: 'ERR_INVALID_ARG_TYPE',
103+
message: 'The "options" argument must be of type object. ' +
104+
'Received null'
105+
});
106+
}
92107
}
93108

94109
{

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.