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 danielleadams committed Apr 3, 2023
1 parent ea411d6 commit d7b995c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
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 d7b995c

Please sign in to comment.