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: fix Argon2 validation errors · nodejs/node@c36bb1d

File tree

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

‎lib/internal/crypto/argon2.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/argon2.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ function check(algorithm, parameters) {
169169
if (parameters.secret === undefined) {
170170
secret = new Uint8Array(0);
171171
} else {
172-
secret = getArrayBufferOrView(parameters.secret);
172+
secret = getArrayBufferOrView(parameters.secret, 'parameters.secret');
173173
validateInteger(secret.byteLength, 'parameters.secret.byteLength', 0, MAX_POSITIVE_UINT_32);
174174
}
175175

176176
let associatedData;
177177
if (parameters.associatedData === undefined) {
178178
associatedData = new Uint8Array(0);
179179
} else {
180-
associatedData = getArrayBufferOrView(parameters.associatedData);
180+
associatedData = getArrayBufferOrView(parameters.associatedData, 'parameters.associatedData');
181181
validateInteger(associatedData.byteLength, 'parameters.associatedData.byteLength', 0, MAX_POSITIVE_UINT_32);
182182
}
183183

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-argon2.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ for (const key of Object.keys(defaults)) {
140140
assert.throws(() => crypto.argon2Sync('argon2id', parameters), expected);
141141
}
142142

143+
for (const key of ['secret', 'associatedData']) {
144+
const expected = {
145+
code: 'ERR_INVALID_ARG_TYPE',
146+
message: new RegExp(`"parameters\\.${key}"`),
147+
};
148+
for (const value of [123, null, true, {}, []]) {
149+
const parameters = { ...defaults, [key]: value };
150+
assert.throws(() => crypto.argon2('argon2id', parameters, () => {}), expected);
151+
assert.throws(() => crypto.argon2Sync('argon2id', parameters), expected);
152+
}
153+
}
154+
143155
{
144156
const expected = { code: 'ERR_INVALID_ARG_TYPE' };
145157
assert.throws(() => crypto.argon2(), expected);

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.