mirror of
https://github.com/nmap/nmap.git
synced 2026-01-19 12:49:02 +00:00
Return RSA exponent from parsed SSL certificates, as a bignum
This commit is contained in:
@@ -128,6 +128,7 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/ssl.h>
|
||||
@@ -146,6 +147,12 @@ struct cert_userdata {
|
||||
int attributes_table;
|
||||
};
|
||||
|
||||
/* from nse_openssl.cc */
|
||||
typedef struct bignum_data {
|
||||
BIGNUM * bn;
|
||||
} bignum_data_t;
|
||||
|
||||
|
||||
SSL *nse_nsock_get_ssl(lua_State *L);
|
||||
|
||||
/* This is a reference to a table that will be used as the metatable for
|
||||
@@ -546,6 +553,14 @@ static int parse_ssl_cert(lua_State *L, X509 *cert)
|
||||
if (pkey_type == EVP_PKEY_EC) {
|
||||
lua_push_ecdhparams(L, pubkey);
|
||||
}
|
||||
else if (pkey_type == EVP_PKEY_RSA) {
|
||||
RSA *rsa = EVP_PKEY_get1_RSA(pubkey);
|
||||
bignum_data_t * data = (bignum_data_t *) lua_newuserdata( L, sizeof(bignum_data_t));
|
||||
luaL_getmetatable( L, "BIGNUM" );
|
||||
lua_setmetatable( L, -2 );
|
||||
data->bn = rsa->e;
|
||||
lua_setfield(L, -2, "exponent");
|
||||
}
|
||||
lua_pushstring(L, pkey_type_to_string(pkey_type));
|
||||
lua_setfield(L, -2, "type");
|
||||
lua_pushnumber(L, EVP_PKEY_bits(pubkey));
|
||||
|
||||
Reference in New Issue
Block a user