Skip to content

Commit d50e1a2

Browse files
Lekotniessen
authored andcommitted
test: increase pbkdf2 test coverage
PR-URL: #17730 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Jon Moss <me@jonathanmoss.me>
1 parent a3497b3 commit d50e1a2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/parallel/test-crypto-pbkdf2.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ common.expectsError(
6565
}
6666
);
6767

68+
common.expectsError(
69+
() => crypto.pbkdf2Sync('password', 'salt', -1, 20, null),
70+
{
71+
code: 'ERR_OUT_OF_RANGE',
72+
type: RangeError,
73+
message: 'The "iterations" argument is out of range'
74+
}
75+
);
76+
77+
['str', null, undefined, [], {}].forEach((notNumber) => {
78+
common.expectsError(
79+
() => {
80+
crypto.pbkdf2Sync('password', 'salt', 1, notNumber, 'sha256');
81+
}, {
82+
code: 'ERR_INVALID_ARG_TYPE',
83+
type: TypeError,
84+
message: 'The "keylen" argument must be of type number'
85+
});
86+
});
87+
6888
[Infinity, -Infinity, NaN, -1, 4073741824, INT_MAX + 1].forEach((i) => {
6989
common.expectsError(
7090
() => {

0 commit comments

Comments
 (0)