Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 30a35ae

Browse filesBrowse files
mhdawsontargos
authored andcommitted
test: crypto-rsa-dsa testing for dynamic openssl
Fixes: #52537 Signed-off-by: Michael Dawson <midawson@redhat.com> PR-URL: #52781 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f1bc994 commit 30a35ae
Copy full SHA for 30a35ae

File tree

Expand file treeCollapse file tree

1 file changed

+49
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+49
-2
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-crypto-rsa-dsa.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-rsa-dsa.js
+49-2Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
223223

224224

225225
if (padding === constants.RSA_PKCS1_PADDING) {
226-
// TODO(richardlau): see if it's possible to determine implicit rejection
227-
// support when dynamically linked against OpenSSL.
228226
if (!process.config.variables.node_shared_openssl) {
229227
assert.throws(() => {
230228
crypto.privateDecrypt({
@@ -240,6 +238,55 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
240238
oaepHash: decryptOaepHash
241239
}, encryptedBuffer);
242240
}, { code: 'ERR_INVALID_ARG_VALUE' });
241+
} else {
242+
// The version of a linked against OpenSSL. May
243+
// or may not support implicit rejection. Figuring
244+
// this out in the test is not feasible but we
245+
// require that it pass based on one of the two
246+
// cases of supporting it or not.
247+
try {
248+
// The expected exceptions should be thrown if implicit rejection
249+
// is not supported
250+
assert.throws(() => {
251+
crypto.privateDecrypt({
252+
key: rsaKeyPem,
253+
padding: padding,
254+
oaepHash: decryptOaepHash
255+
}, encryptedBuffer);
256+
}, { code: 'ERR_INVALID_ARG_VALUE' });
257+
assert.throws(() => {
258+
crypto.privateDecrypt({
259+
key: rsaPkcs8KeyPem,
260+
padding: padding,
261+
oaepHash: decryptOaepHash
262+
}, encryptedBuffer);
263+
}, { code: 'ERR_INVALID_ARG_VALUE' });
264+
} catch (e) {
265+
if (e.toString() ===
266+
'AssertionError [ERR_ASSERTION]: Missing expected exception.') {
267+
// Implicit rejection must be supported since
268+
// we did not get the exceptions that are thrown
269+
// when it is not, we should be able to decrypt
270+
let decryptedBuffer = crypto.privateDecrypt({
271+
key: rsaKeyPem,
272+
padding: padding,
273+
oaepHash: decryptOaepHash
274+
}, encryptedBuffer);
275+
assert.deepStrictEqual(decryptedBuffer, input);
276+
277+
decryptedBuffer = crypto.privateDecrypt({
278+
key: rsaPkcs8KeyPem,
279+
padding: padding,
280+
oaepHash: decryptOaepHash
281+
}, encryptedBuffer);
282+
assert.deepStrictEqual(decryptedBuffer, input);
283+
} else {
284+
// There was an exception but it is not the one we expect if implicit
285+
// rejection is not supported so there was some other failure,
286+
// re-throw it so the test fails
287+
throw e;
288+
}
289+
}
243290
}
244291
} else {
245292
let decryptedBuffer = crypto.privateDecrypt({

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.