Skip to content

Commit 67b692b

Browse files
Nievltargos
authored andcommitted
test: add test case for checking typeof mgf1Hash
add test case to cover uncovered test mgf1Hash param of generateKeyPair, check typeof PR-URL: #27892 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 2a509d4 commit 67b692b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/parallel/test-crypto-keygen.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,3 +987,39 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
987987
});
988988
}
989989
}
990+
{
991+
// Test RSA-PSS.
992+
common.expectsError(
993+
() => {
994+
generateKeyPair('rsa-pss', {
995+
modulusLength: 512,
996+
saltLength: 16,
997+
hash: 'sha256',
998+
mgf1Hash: undefined
999+
});
1000+
},
1001+
{
1002+
type: TypeError,
1003+
code: 'ERR_INVALID_CALLBACK',
1004+
message: 'Callback must be a function. Received undefined'
1005+
}
1006+
);
1007+
1008+
for (const mgf1Hash of [null, 0, false, {}, []]) {
1009+
common.expectsError(
1010+
() => {
1011+
generateKeyPair('rsa-pss', {
1012+
modulusLength: 512,
1013+
saltLength: 16,
1014+
hash: 'sha256',
1015+
mgf1Hash
1016+
});
1017+
},
1018+
{
1019+
type: TypeError,
1020+
code: 'ERR_INVALID_OPT_VALUE',
1021+
message: `The value "${mgf1Hash}" is invalid for option "mgf1Hash"`
1022+
}
1023+
);
1024+
}
1025+
}

0 commit comments

Comments
 (0)