1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 20:51:30 +00:00

o Added the function bignum_add to the nse_openssl library to support BIGNUM

addition [Patrik]
This commit is contained in:
patrik
2010-03-09 20:54:01 +00:00
parent 2a44a941af
commit 16e0a8449f
3 changed files with 23 additions and 0 deletions

View File

@@ -2,6 +2,9 @@
[NOT YET RELEASED] [NOT YET RELEASED]
o Added the function bignum_add to the nse_openssl library to support BIGNUM
addition [Patrik]
o [NSE] Added checks for missing OpenSSL to MySQL scripts and library [Patrik] o [NSE] Added checks for missing OpenSSL to MySQL scripts and library [Patrik]
o Made --resume work with recent changes to normal output. [jlanthea] o Made --resume work with recent changes to normal output. [jlanthea]

View File

@@ -107,6 +107,19 @@ static int l_bignum_mod_exp( lua_State *L ) /** bignum_mod_exp( BIGNUM a, BIGNUM
return 1; return 1;
} }
static int l_bignum_add( lua_State *L ) /** bignum_add( BIGNUM a, BIGNUM b ) */
{
bignum_data_t * a = (bignum_data_t *) luaL_checkudata(L, 1, "BIGNUM");
bignum_data_t * b = (bignum_data_t *) luaL_checkudata(L, 2, "BIGNUM");
BIGNUM * result = BN_new();
BN_add( result, a->bn, b->bn );
bignum_data_t * data = (bignum_data_t *) lua_newuserdata( L, sizeof(bignum_data_t));
luaL_getmetatable( L, "BIGNUM" );
lua_setmetatable( L, -2 );
data->bn = result;
return 1;
}
static int l_bignum_num_bits( lua_State *L ) /** bignum_num_bits( BIGNUM bn ) */ static int l_bignum_num_bits( lua_State *L ) /** bignum_num_bits( BIGNUM bn ) */
{ {
bignum_data_t * userdata = (bignum_data_t *) luaL_checkudata(L, 1, "BIGNUM"); bignum_data_t * userdata = (bignum_data_t *) luaL_checkudata(L, 1, "BIGNUM");
@@ -466,6 +479,7 @@ static const struct luaL_reg openssllib[] = {
{ "bignum_bn2bin", l_bignum_bn2bin }, { "bignum_bn2bin", l_bignum_bn2bin },
{ "bignum_bn2dec", l_bignum_bn2dec }, { "bignum_bn2dec", l_bignum_bn2dec },
{ "bignum_bn2hex", l_bignum_bn2hex }, { "bignum_bn2hex", l_bignum_bn2hex },
{ "bignum_add", l_bignum_add },
{ "bignum_mod_exp", l_bignum_mod_exp }, { "bignum_mod_exp", l_bignum_mod_exp },
{ "rand_bytes", l_rand_bytes }, { "rand_bytes", l_rand_bytes },
{ "rand_pseudo_bytes", l_rand_pseudo_bytes }, { "rand_pseudo_bytes", l_rand_pseudo_bytes },

View File

@@ -95,6 +95,12 @@ function bignum_pseudo_rand(bits)
-- @return bignum. -- @return bignum.
function bignum_mod_exp(a, p, m) function bignum_mod_exp(a, p, m)
--- Returns the bignum which is the result of <code>a+b</code>
-- @param a bignum
-- @param b bignum
-- @return bignum
function bignum_add(a, b)
--- Returns a string containing random data. --- Returns a string containing random data.
-- @param bytes Length of the returned string in bytes. -- @param bytes Length of the returned string in bytes.
-- @return Random string. -- @return Random string.