aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-12-18 16:00:39 +1100
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-12-18 16:05:00 +1100
commita44ab92ae547eb103af7f47cbdf4045bbb61e101 (patch)
treedc85ba61d2bdad308fe1632dd85de473d2c808f6 /src
parent71225b77a843d3eeb6bf2fe5123c1a192f6fdabb (diff)
downloadluaossl-a44ab92ae547eb103af7f47cbdf4045bbb61e101.tar.gz
luaossl-a44ab92ae547eb103af7f47cbdf4045bbb61e101.tar.bz2
luaossl-a44ab92ae547eb103af7f47cbdf4045bbb61e101.zip
src/openssl.c: Add bn:mod_{add,sub,mul} functions
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index ba6e9b6..38d5e8d 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -2960,6 +2960,45 @@ static int bn_nnmod(lua_State *L) {
} /* bn_nnmod() */
+static int bn_mod_add(lua_State *L) {
+ BIGNUM *r, *a, *b, *c;
+
+ lua_settop(L, 3);
+ bn_preptop(L, &r, &a, &b, &c);
+
+ if (!BN_mod_add(r, a, b, c, getctx(L)))
+ return auxL_error(L, auxL_EOPENSSL, "bignum:mod_add");
+
+ return 1;
+} /* bn_mod_add() */
+
+
+static int bn_mod_sub(lua_State *L) {
+ BIGNUM *r, *a, *b, *c;
+
+ lua_settop(L, 3);
+ bn_preptop(L, &r, &a, &b, &c);
+
+ if (!BN_mod_sub(r, a, b, c, getctx(L)))
+ return auxL_error(L, auxL_EOPENSSL, "bignum:mod_sub");
+
+ return 1;
+} /* bn_mod_sub() */
+
+
+static int bn_mod_mul(lua_State *L) {
+ BIGNUM *r, *a, *b, *c;
+
+ lua_settop(L, 3);
+ bn_preptop(L, &r, &a, &b, &c);
+
+ if (!BN_mod_mul(r, a, b, c, getctx(L)))
+ return auxL_error(L, auxL_EOPENSSL, "bignum:mod_mul");
+
+ return 1;
+} /* bn_mod_mul() */
+
+
static int bn__pow(lua_State *L) {
BIGNUM *r, *a, *b;
@@ -3179,6 +3218,9 @@ static const auxL_Reg bn_methods[] = {
{ "idiv", &bn__idiv },
{ "mod", &bn__mod },
{ "nnmod", &bn_nnmod },
+ { "mod_add", &bn_mod_add },
+ { "mod_sub", &bn_mod_sub },
+ { "mod_mul", &bn_mod_mul },
{ "exp", &bn__pow },
{ "mod_exp", &bn_mod_exp },
{ "gcd", &bn_gcd },