crypto: fix scrypt keylen validation
Fixes: https://github.com/nodejs/node/issues/38381 PR-URL: https://github.com/nodejs/node/pull/38385 Reviewed-By: Nitzan Uziely <linkgoron@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
parent
59db84aba1
commit
27beb386a8
@ -16,6 +16,7 @@ const {
|
||||
const {
|
||||
validateCallback,
|
||||
validateInteger,
|
||||
validateInt32,
|
||||
validateUint32,
|
||||
} = require('internal/validators');
|
||||
|
||||
@ -90,7 +91,7 @@ function check(password, salt, keylen, options) {
|
||||
|
||||
password = getArrayBufferOrView(password, 'password');
|
||||
salt = getArrayBufferOrView(salt, 'salt');
|
||||
validateUint32(keylen, 'keylen');
|
||||
validateInt32(keylen, 'keylen', 0);
|
||||
|
||||
let { N, r, p, maxmem } = defaults;
|
||||
if (options && options !== defaults) {
|
||||
|
@ -143,6 +143,10 @@ const badargs = [
|
||||
args: ['', '', -42],
|
||||
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||
},
|
||||
{
|
||||
args: ['', '', 2147485780],
|
||||
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||
},
|
||||
];
|
||||
|
||||
for (const options of good) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user