From 847459c29b365a5b5928d42a5d4f60e9f9fc156a Mon Sep 17 00:00:00 2001 From: Chad Johnston Date: Thu, 6 Aug 2015 20:42:10 -0600 Subject: [PATCH] crypto: show exponent in decimal and hex The exponent value was already in hex, but missing the 0x prefix which could be confusing. PR-URL: https://github.com/nodejs/io.js/pull/2320 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/node_crypto.cc | 4 +++- test/parallel/test-https-foafssl.js | 2 +- test/parallel/test-tls-peer-certificate.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index e33b249242e3e5..b5e83f9fa16496 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1371,7 +1371,9 @@ static Local X509ToObject(Environment* env, X509* cert) { String::kNormalString, mem->length)); (void) BIO_reset(bio); - BN_print(bio, rsa->e); + unsigned long exponent_word = BN_get_word(rsa->e); + BIO_printf(bio, "0x%lx", exponent_word); + BIO_get_mem_ptr(bio, &mem); info->Set(env->exponent_string(), String::NewFromUtf8(env->isolate(), mem->data, diff --git a/test/parallel/test-https-foafssl.js b/test/parallel/test-https-foafssl.js index d6df5189896298..5e480bf6adc1e5 100644 --- a/test/parallel/test-https-foafssl.js +++ b/test/parallel/test-https-foafssl.js @@ -83,5 +83,5 @@ process.on('exit', function() { 'FDA7DE954ED56DC7AD9A47EEBC37D771A366FC60A5BCB72373BEC180649B3EFA0E90' + '92707210B41B90032BB18BC91F2046EBDAF1191F4A4E26D71879C4C7867B62FCD508' + 'E8CE66E82D128A71E915809FCF44E8DE774067F1DE5D70B9C03687'); - assert.equal(exponent, '10001'); + assert.equal(exponent, '0x10001'); }); diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js index 4fa1beb6ac644c..3c25af19c87e88 100644 --- a/test/parallel/test-tls-peer-certificate.js +++ b/test/parallel/test-tls-peer-certificate.js @@ -38,6 +38,7 @@ server.listen(common.PORT, function() { common.debug(util.inspect(peerCert)); assert.equal(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); assert.equal(peerCert.serialNumber, '9A84ABCFB8A72AC0'); + assert.equal(peerCert.exponent, '0x10001'); assert.deepEqual(peerCert.infoAccess['OCSP - URI'], [ 'http://ocsp.nodejs.org/' ]);