From c72e3ac0d9353925323decd0bf814fa987b231c8 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 18 Oct 2017 20:26:38 +0000 Subject: [PATCH] Extract RSA modulus along with exponent --- nse_ssl_cert.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nse_ssl_cert.cc b/nse_ssl_cert.cc index f334f461d..55aa78c1b 100644 --- a/nse_ssl_cert.cc +++ b/nse_ssl_cert.cc @@ -648,17 +648,28 @@ static int parse_ssl_cert(lua_State *L, X509 *cert) #endif if (pkey_type == EVP_PKEY_RSA) { RSA *rsa = EVP_PKEY_get1_RSA(pubkey); + /* exponent */ bignum_data_t * data = (bignum_data_t *) lua_newuserdata( L, sizeof(bignum_data_t)); luaL_getmetatable( L, "BIGNUM" ); lua_setmetatable( L, -2 ); #if HAVE_OPAQUE_STRUCTS - const BIGNUM *n, *e, *d; - RSA_get0_key(rsa, &n, &e, &d); + const BIGNUM *n, *e; + RSA_get0_key(rsa, &n, &e, NULL); data->bn = (BIGNUM*) e; #else data->bn = rsa->e; #endif lua_setfield(L, -2, "exponent"); + /* modulus */ + data = (bignum_data_t *) lua_newuserdata( L, sizeof(bignum_data_t)); + luaL_getmetatable( L, "BIGNUM" ); + lua_setmetatable( L, -2 ); + #if HAVE_OPAQUE_STRUCTS + data->bn = (BIGNUM*) n; + #else + data->bn = rsa->n; + #endif + lua_setfield(L, -2, "modulus"); } lua_pushstring(L, pkey_type_to_string(pkey_type)); lua_setfield(L, -2, "type");