diff options
author | daurnimator <quae@daurnimator.com> | 2018-05-30 17:19:25 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-05-30 17:19:25 +1000 |
commit | 77d38ec3be5030397f895fd19959a87a065fac14 (patch) | |
tree | c7943c41eccd257db9e4d633dccbf9b95de15f88 /src | |
parent | 48fe8d844460514f4cfe19320e71181247d13d12 (diff) | |
download | luaossl-77d38ec3be5030397f895fd19959a87a065fac14.tar.gz luaossl-77d38ec3be5030397f895fd19959a87a065fac14.tar.bz2 luaossl-77d38ec3be5030397f895fd19959a87a065fac14.zip |
src/openssl.c: Add lua_isinteger path to bignum construction for Lua 5.3
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index b0fea04..5108713 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -2802,6 +2802,24 @@ static BIGNUM *(checkbig)(lua_State *L, int index, _Bool *lvalue) { bn = prepsimple(L, BIGNUM_CLASS); +#if LUA_VERSION_NUM >= 503 + if (lua_isinteger(L, index)) { + lua_Integer n = lua_tointeger(L, index); + auxL_Unsigned lu; + + if (!*bn && !(*bn = BN_new())) + auxL_error(L, auxL_EOPENSSL, "bignum"); + + neg = n < 0; + lu = neg ? (0 - n) : n; + + if (!BN_set_word(*bn, lu)) + auxL_error(L, auxL_EOPENSSL, "bignum"); + + if (neg) + BN_set_negative(*bn, 1); + } else +#endif if (!f2bn(bn, lua_tonumber(L, index))) auxL_error(L, auxL_EOPENSSL, "bignum"); |