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 <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>
  • Loading branch information
Nievl authored and targos committed May 31, 2019
1 parent 2a509d4 commit 67b692b
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 67b692b

Please sign in to comment.