Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/parallel/test-crypto-pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ common.expectsError(
}
);

common.expectsError(
() => crypto.pbkdf2Sync('password', 'salt', -1, 20, null),
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "iterations" argument is out of range'
}
);

['str', null, undefined, [], {}].forEach((i) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit: please use a more descriptive variable name than i.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review.
I renamed i to notNumber.

common.expectsError(
() => {
crypto.pbkdf2Sync('password', 'salt', 1, i, 'sha256');
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "keylen" argument must be of type number'
});
});

[Infinity, -Infinity, NaN, -1, 4073741824, INT_MAX + 1].forEach((i) => {
common.expectsError(
() => {
Expand Down