Skip to content

Commit

Permalink
crypto: show exponent in decimal and hex
Browse files Browse the repository at this point in the history
The exponent value was already in hex, but missing the 0x prefix which
could be confusing.

PR-URL: #2320
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
iamthechad authored and bnoordhuis committed Aug 11, 2015
1 parent ad7f744 commit 847459c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,9 @@ static Local<Object> 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,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-foafssl.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ process.on('exit', function() {
'FDA7DE954ED56DC7AD9A47EEBC37D771A366FC60A5BCB72373BEC180649B3EFA0E90' +
'92707210B41B90032BB18BC91F2046EBDAF1191F4A4E26D71879C4C7867B62FCD508' +
'E8CE66E82D128A71E915809FCF44E8DE774067F1DE5D70B9C03687');
assert.equal(exponent, '10001');
assert.equal(exponent, '0x10001');
});
1 change: 1 addition & 0 deletions test/parallel/test-tls-peer-certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/' ]);

Expand Down

0 comments on commit 847459c

Please sign in to comment.