Skip to content

Commit 6d15185

Browse files
LekoMylesBorins
authored andcommitted
test: increase pbkdf2 test coverage
PR-URL: #17730 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Jon Moss <[email protected]>
1 parent 74a5bba commit 6d15185

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/parallel/test-crypto-pbkdf2.js

+20
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)