Skip to content

Commit

Permalink
test: add test case for checking typeof mgf1Hash
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Nievl authored and danbev committed May 29, 2019
1 parent b323658 commit 12f5e0f
Showing 1 changed file with 36 additions and 0 deletions.
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"`
}
);
}
}

0 comments on commit 12f5e0f

Please sign in to comment.