GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: crypto-rsa-dsa testing for dynamic openssl · nodejs/node@30a35ae

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-crypto-rsa-dsa.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.