test: add test case for checking typeof mgf1Hash
add test case to cover uncovered test mgf1Hash param of generateKeyPair, check typeof PR-URL: https://github.com/nodejs/node/pull/27892 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
parent
b323658b64
commit
12f5e0f8f8
@ -987,3 +987,39 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
// Test RSA-PSS.
|
||||
common.expectsError(
|
||||
() => {
|
||||
generateKeyPair('rsa-pss', {
|
||||
modulusLength: 512,
|
||||
saltLength: 16,
|
||||
hash: 'sha256',
|
||||
mgf1Hash: undefined
|
||||
});
|
||||
},
|
||||
{
|
||||
type: TypeError,
|
||||
code: 'ERR_INVALID_CALLBACK',
|
||||
message: 'Callback must be a function. Received undefined'
|
||||
}
|
||||
);
|
||||
|
||||
for (const mgf1Hash of [null, 0, false, {}, []]) {
|
||||
common.expectsError(
|
||||
() => {
|
||||
generateKeyPair('rsa-pss', {
|
||||
modulusLength: 512,
|
||||
saltLength: 16,
|
||||
hash: 'sha256',
|
||||
mgf1Hash
|
||||
});
|
||||
},
|
||||
{
|
||||
type: TypeError,
|
||||
code: 'ERR_INVALID_OPT_VALUE',
|
||||
message: `The value "${mgf1Hash}" is invalid for option "mgf1Hash"`
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user