Skip to content

Commit 652d033

Browse files
authored
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: #64093 Refs: #63895 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 6bda0ab commit 652d033

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/crypto/crypto_x509.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,12 @@ MaybeLocal<Value> GetModulusString(Environment* env, const BIGNUM* n) {
689689
}
690690

691691
MaybeLocal<Value> GetExponentString(Environment* env, const BIGNUM* e) {
692-
auto exponent_word = BignumPointer::GetWord(e);
693-
if (!exponent_word) return Null(env->isolate());
692+
if (e == nullptr) return Null(env->isolate());
694693
auto bio = BIOPointer::NewMem();
695694
if (!bio) [[unlikely]]
696695
return {};
697-
BIO_printf(bio.get(), "0x%" PRIx64, static_cast<uint64_t>(*exponent_word));
696+
BIO_puts(bio.get(), "0x");
697+
BN_print(bio.get(), e);
698698
return ToV8Value(env->context(), bio);
699699
}
700700

0 commit comments

Comments
 (0)