summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Ahern <william@25thandClement.com>2015-12-17 15:42:11 +0800
committerWilliam Ahern <william@25thandClement.com>2015-12-17 15:42:11 +0800
commit0bb54ebc3779461101daa6d10ec24f53be540663 (patch)
tree1602edef5399d3ac20b9d0fa22002b0434aa0330
parent739031aea27fa166771c76153db12c009677601b (diff)
parentfb08628f17893280da43c70f0919687feca09265 (diff)
downloadluaossl-0bb54ebc3779461101daa6d10ec24f53be540663.tar.gz
luaossl-0bb54ebc3779461101daa6d10ec24f53be540663.tar.bz2
luaossl-0bb54ebc3779461101daa6d10ec24f53be540663.zip
Merge branch '19-bignum-modulo' of git://github.com/daurnimator/luaossl into daurnimator-19-bignum-modulo
-rw-r--r--src/openssl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 9dbcda7..69115ce 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -1809,6 +1809,12 @@ static int bn__mod(lua_State *L) {
1809 if (!BN_mod(r, a, b, getctx(L))) 1809 if (!BN_mod(r, a, b, getctx(L)))
1810 return auxL_error(L, auxL_EOPENSSL, "bignum:__mod"); 1810 return auxL_error(L, auxL_EOPENSSL, "bignum:__mod");
1811 1811
1812 /* lua has different rounding behaviour for mod than C */
1813 if (!BN_is_zero(r) && (BN_is_negative(a) ^ BN_is_negative(b))) {
1814 if (!BN_add(r, r, b))
1815 return auxL_error(L, auxL_EOPENSSL, "bignum:__mod");
1816 }
1817
1812 return 1; 1818 return 1;
1813} /* bn__mod() */ 1819} /* bn__mod() */
1814 1820