diff options
Diffstat (limited to 'src/openssl.c')
-rw-r--r-- | src/openssl.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 8fadb02..4da28ef 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -1819,6 +1819,12 @@ static int bn__mod(lua_State *L) { | |||
1819 | if (!BN_mod(r, a, b, getctx(L))) | 1819 | if (!BN_mod(r, a, b, getctx(L))) |
1820 | return auxL_error(L, auxL_EOPENSSL, "bignum:__mod"); | 1820 | return auxL_error(L, auxL_EOPENSSL, "bignum:__mod"); |
1821 | 1821 | ||
1822 | /* lua has different rounding behaviour for mod than C */ | ||
1823 | if (!BN_is_zero(r) && (BN_is_negative(a) ^ BN_is_negative(b))) { | ||
1824 | if (!BN_add(r, r, b)) | ||
1825 | return auxL_error(L, auxL_EOPENSSL, "bignum:__mod"); | ||
1826 | } | ||
1827 | |||
1822 | return 1; | 1828 | return 1; |
1823 | } /* bn__mod() */ | 1829 | } /* bn__mod() */ |
1824 | 1830 | ||