1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

Fix building on OpenSSL 1.0.1 and earlier due to missing EC crypto

This commit is contained in:
dmiller
2016-07-27 20:28:46 +00:00
parent 85dd7e6ac1
commit 3611aa0a6e

View File

@@ -424,7 +424,7 @@ static const char *pkey_type_to_string(int type)
return "dsa"; return "dsa";
case EVP_PKEY_DH: case EVP_PKEY_DH:
return "dh"; return "dh";
#ifdef EVP_PKEY_EC #if OPENSSL_VERSION_NUMBER >= 0x10002000L
case EVP_PKEY_EC: case EVP_PKEY_EC:
return "ec"; return "ec";
#endif #endif
@@ -434,7 +434,7 @@ static const char *pkey_type_to_string(int type)
} }
int lua_push_ecdhparams(lua_State *L, EVP_PKEY *pubkey) { int lua_push_ecdhparams(lua_State *L, EVP_PKEY *pubkey) {
#ifdef EVP_PKEY_EC #if OPENSSL_VERSION_NUMBER >= 0x10002000L
EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(pubkey); EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(pubkey);
const EC_GROUP *group = EC_KEY_get0_group(ec_key); const EC_GROUP *group = EC_KEY_get0_group(ec_key);
int nid; int nid;
@@ -546,11 +546,14 @@ static int parse_ssl_cert(lua_State *L, X509 *cert)
pubkey = X509_get_pubkey(cert); pubkey = X509_get_pubkey(cert);
lua_newtable(L); lua_newtable(L);
pkey_type = EVP_PKEY_type(pubkey->type); pkey_type = EVP_PKEY_type(pubkey->type);
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
if (pkey_type == EVP_PKEY_EC) { if (pkey_type == EVP_PKEY_EC) {
lua_push_ecdhparams(L, pubkey); lua_push_ecdhparams(L, pubkey);
lua_setfield(L, -2, "ecdhparams"); lua_setfield(L, -2, "ecdhparams");
} }
else if (pkey_type == EVP_PKEY_RSA) { else
#endif
if (pkey_type == EVP_PKEY_RSA) {
RSA *rsa = EVP_PKEY_get1_RSA(pubkey); RSA *rsa = EVP_PKEY_get1_RSA(pubkey);
bignum_data_t * data = (bignum_data_t *) lua_newuserdata( L, sizeof(bignum_data_t)); bignum_data_t * data = (bignum_data_t *) lua_newuserdata( L, sizeof(bignum_data_t));
luaL_getmetatable( L, "BIGNUM" ); luaL_getmetatable( L, "BIGNUM" );