aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-12-18 16:00:50 +1100
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-12-18 16:05:01 +1100
commit09402eb482df069d21b07a0c8468824a5efff30a (patch)
tree8d7ab50461eeff9830768ad978b559a2b9e0c454
parenta44ab92ae547eb103af7f47cbdf4045bbb61e101 (diff)
downloadluaossl-09402eb482df069d21b07a0c8468824a5efff30a.tar.gz
luaossl-09402eb482df069d21b07a0c8468824a5efff30a.tar.bz2
luaossl-09402eb482df069d21b07a0c8468824a5efff30a.zip
src/openssl.c: Add bn:mod_sqr function
-rw-r--r--src/openssl.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 38d5e8d..5bec55a 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -2999,6 +2999,19 @@ static int bn_mod_mul(lua_State *L) {
} /* bn_mod_mul() */
+static int bn_mod_sqr(lua_State *L) {
+ BIGNUM *r, *a, *b;
+
+ lua_settop(L, 2);
+ bn_prepbop(L, &r, &a, &b, 0);
+
+ if (!BN_mod_sqr(r, a, b, getctx(L)))
+ return auxL_error(L, auxL_EOPENSSL, "bignum:mod_sqr");
+
+ return 1;
+} /* bn_mod_sqr() */
+
+
static int bn__pow(lua_State *L) {
BIGNUM *r, *a, *b;
@@ -3221,6 +3234,7 @@ static const auxL_Reg bn_methods[] = {
{ "mod_add", &bn_mod_add },
{ "mod_sub", &bn_mod_sub },
{ "mod_mul", &bn_mod_mul },
+ { "mod_sqr", &bn_mod_sqr },
{ "exp", &bn__pow },
{ "mod_exp", &bn_mod_exp },
{ "gcd", &bn_gcd },