Skip to content

Commit

Permalink
test: cover publicExponent validation in OpenSSL
Browse files Browse the repository at this point in the history
Add a test case for public exponents that are invalid according to some
internal OpenSSL validation logic, but which are accepted by node's own
validation logic.

PR-URL: #46632
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
  • Loading branch information
tniessen authored and MylesBorins committed Feb 20, 2023
1 parent f390841 commit c4ca98e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-crypto-keygen.js
Expand Up @@ -1200,6 +1200,17 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
code: 'ERR_OUT_OF_RANGE',
});
}

// Test invalid exponents. (caught by OpenSSL)
for (const publicExponent of [1, 1 + 0x10001]) {
generateKeyPair('rsa', {
modulusLength: 4096,
publicExponent
}, common.mustCall((err) => {
assert.strictEqual(err.name, 'Error');
assert.match(err.message, common.hasOpenSSL3 ? /exponent/ : /bad e value/);
}));
}
}

// Test DSA parameters.
Expand Down

0 comments on commit c4ca98e

Please sign in to comment.