tls: handle large RSA exponents in X.509 cert

If the exponent does not fit into a single word, previous versions of
Node.js would report an incorrect value or, recently, return `null`.
Change `GetExponentString()` to handle arbitrarily large RSA public
exponents properly.

Signed-off-by: Tobias Nießen <tniessen@tnie.de>
PR-URL: https://github.com/nodejs/node/pull/64093
Refs: https://github.com/nodejs/node/pull/63895
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Tobias Nießen authored and Antoine du Hamel committed 2026-07-30 13:51:42 +02:00
1 parent e392e1f791
commit a653e9bb57
1 file changed
+3 -3
+3 -3
View File
@@ -689,12 +689,12 @@ MaybeLocal<Value> GetModulusString(Environment* env, const BIGNUM* n) {
}
MaybeLocal<Value> GetExponentString(Environment* env, const BIGNUM* e) {
auto exponent_word = BignumPointer::GetWord(e);
if (!exponent_word) return Null(env->isolate());
if (e == nullptr) return Null(env->isolate());
auto bio = BIOPointer::NewMem();
if (!bio) [[unlikely]]
return {};
BIO_printf(bio.get(), "0x%" PRIx64, static_cast<uint64_t>(*exponent_word));
BIO_puts(bio.get(), "0x");
BN_print(bio.get(), e);
return ToV8Value(env->context(), bio);
}