Skip to content

Commit 98552f3

Browse files
tniessenBethGriggs
authored andcommitted
crypto: allow undefined for saltLength and padding
PR-URL: #26921 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent a821a96 commit 98552f3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/internal/crypto/sig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ function getSaltLength(options) {
6060
}
6161

6262
function getIntOption(name, defaultValue, options) {
63-
if (options.hasOwnProperty(name)) {
64-
const value = options[name];
63+
const value = options[name];
64+
if (value !== undefined) {
6565
if (value === value >> 0) {
6666
return value;
6767
} else {

test/parallel/test-crypto-sign-verify.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ const modSize = 1024;
3232
common.expectsError(
3333
() => crypto.createVerify('SHA256').verify({
3434
key: certPem,
35-
padding: undefined,
35+
padding: null,
3636
}, ''),
3737
{
3838
code: 'ERR_INVALID_OPT_VALUE',
3939
type: TypeError,
40-
message: 'The value "undefined" is invalid for option "padding"'
40+
message: 'The value "null" is invalid for option "padding"'
4141
});
4242

4343
common.expectsError(
4444
() => crypto.createVerify('SHA256').verify({
4545
key: certPem,
46-
saltLength: undefined,
46+
saltLength: null,
4747
}, ''),
4848
{
4949
code: 'ERR_INVALID_OPT_VALUE',
5050
type: TypeError,
51-
message: 'The value "undefined" is invalid for option "saltLength"'
51+
message: 'The value "null" is invalid for option "saltLength"'
5252
});
5353

5454
// Test signing and verifying
@@ -233,7 +233,7 @@ common.expectsError(
233233

234234
// Test exceptions for invalid `padding` and `saltLength` values
235235
{
236-
[null, undefined, NaN, 'boom', {}, [], true, false]
236+
[null, NaN, 'boom', {}, [], true, false]
237237
.forEach((invalidValue) => {
238238
common.expectsError(() => {
239239
crypto.createSign('SHA256')

0 commit comments

Comments
 (0)