mirror of
https://github.com/nmap/nmap.git
synced 2025-12-16 04:39:03 +00:00
Add BN_div function binding
This commit is contained in:
@@ -107,6 +107,20 @@ static int l_bignum_mod_exp( lua_State *L ) /** bignum_mod_exp( BIGNUM a, BIGNUM
|
||||
return nse_pushbn(L, result);
|
||||
}
|
||||
|
||||
static int l_bignum_div( lua_State *L ) /* bignum_div( BIGNUM a, BIGNUM d ) */
|
||||
{
|
||||
bignum_data_t * a = (bignum_data_t *) luaL_checkudata(L, 1, "BIGNUM");
|
||||
bignum_data_t * d = (bignum_data_t *) luaL_checkudata(L, 2, "BIGNUM");
|
||||
BIGNUM * dv = BN_new();
|
||||
BIGNUM * rem = BN_new();
|
||||
BN_CTX * ctx = BN_CTX_new();
|
||||
BN_div(dv, rem, a->bn, d->bn, ctx);
|
||||
BN_CTX_free( ctx );
|
||||
nse_pushbn(L, dv);
|
||||
nse_pushbn(L, rem);
|
||||
return 2;
|
||||
}
|
||||
|
||||
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");
|
||||
@@ -582,6 +596,7 @@ static const struct luaL_Reg openssllib[] = {
|
||||
{ "bignum_bn2hex", l_bignum_bn2hex },
|
||||
{ "bignum_add", l_bignum_add },
|
||||
{ "bignum_mod_exp", l_bignum_mod_exp },
|
||||
{ "bignum_div", l_bignum_div },
|
||||
{ "rand_bytes", l_rand_bytes },
|
||||
{ "rand_pseudo_bytes", l_rand_pseudo_bytes },
|
||||
{ "md4", l_md4 },
|
||||
|
||||
@@ -115,6 +115,13 @@ function bignum_pseudo_rand(bits)
|
||||
-- @return bignum.
|
||||
function bignum_mod_exp(a, p, m)
|
||||
|
||||
--- Returns the bignums which are the result and remainder of <code>a/b</code>
|
||||
-- @param a bignum
|
||||
-- @param b bignum
|
||||
-- @return bignum quotient
|
||||
-- @return bignum remainder (modulo)
|
||||
function bignum_div(a, b)
|
||||
|
||||
--- Returns the bignum which is the result of <code>a+b</code>
|
||||
-- @param a bignum
|
||||
-- @param b bignum
|
||||
|
||||
Reference in New Issue
Block a user