Skip to content
Closed
Changes from all 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
test: add test case for checking typeof mgf1Hash
add test case to cover uncovered test mgf1Hash param of generateKeyPair,
check typeof
  • Loading branch information
Nievl committed May 26, 2019
commit 093fceca58649e890206ee184ed02699eb9c0e9f
36 changes: 36 additions & 0 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
);
}
}