Skip to content

Commit a2707d0

Browse files
tniessenruyadorno
authored andcommitted
test: add coverage for invalid RSA-PSS digests
PR-URL: #44271 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 8cf6499 commit a2707d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/parallel/test-crypto-keygen.js

+18
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,24 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
16541654
}
16551655
);
16561656
}
1657+
1658+
assert.throws(() => generateKeyPair('rsa-pss', {
1659+
modulusLength: 512,
1660+
hashAlgorithm: 'sha2',
1661+
}, common.mustNotCall()), {
1662+
name: 'TypeError',
1663+
code: 'ERR_CRYPTO_INVALID_DIGEST',
1664+
message: 'md specifies an invalid digest'
1665+
});
1666+
1667+
assert.throws(() => generateKeyPair('rsa-pss', {
1668+
modulusLength: 512,
1669+
mgf1HashAlgorithm: 'sha2',
1670+
}, common.mustNotCall()), {
1671+
name: 'TypeError',
1672+
code: 'ERR_CRYPTO_INVALID_DIGEST',
1673+
message: 'mgf1_md specifies an invalid digest'
1674+
});
16571675
}
16581676

16591677
// Passing an empty passphrase string should not cause OpenSSL's default

0 commit comments

Comments
 (0)