Skip to content

Commit 35feddb

Browse files
committed
Fix verify with options without secret
1 parent ebc6ed7 commit 35feddb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

argon2.cjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,7 @@ module.exports.needsRehash = needsRehash;
154154
* @param {Buffer} [options.secret]
155155
* @returns {Promise<boolean>} `true` if the digest parameters matches the hash generated from `plain`, otherwise `false`
156156
*/
157-
async function verify(
158-
digest,
159-
password,
160-
{ secret } = { secret: Buffer.alloc(0) },
161-
) {
157+
async function verify(digest, password, options = {}) {
162158
const { id, ...rest } = deserialize(digest);
163159
if (!(id in types)) {
164160
return false;
@@ -171,6 +167,8 @@ async function verify(
171167
hash,
172168
} = rest;
173169

170+
const { secret = Buffer.alloc(0) } = options;
171+
174172
return timingSafeEqual(
175173
await bindingsHash({
176174
password: Buffer.from(password),

test.cjs

+7
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ describe("verify", () => {
255255
);
256256
});
257257

258+
it("verify with options without secret", async () => {
259+
// https://github.com/ranisalt/node-argon2/issues/407
260+
await assert.doesNotReject(
261+
argon2.verify(await argon2.hash(password, { secret }), "password", {}),
262+
);
263+
});
264+
258265
it("verify argon2d correct password", async () => {
259266
assert(
260267
await argon2.verify(

0 commit comments

Comments
 (0)