diff options
author | William Ahern <william@25thandClement.com> | 2015-12-17 15:47:05 +0800 |
---|---|---|
committer | William Ahern <william@25thandClement.com> | 2015-12-17 15:47:05 +0800 |
commit | 411981c1c308a9ad04d01421e9170d37f2013f4b (patch) | |
tree | c806d4a38ef5e7aa9271b5d8ea9a112b8698b687 | |
parent | a7063a8467c4c0db8eb8f9b1c9e6c9f33c3f664f (diff) | |
parent | c092552bf4a650c18f31b0cdb035606318aac66b (diff) | |
download | luaossl-411981c1c308a9ad04d01421e9170d37f2013f4b.tar.gz luaossl-411981c1c308a9ad04d01421e9170d37f2013f4b.tar.bz2 luaossl-411981c1c308a9ad04d01421e9170d37f2013f4b.zip |
Merge branch 'daurnimator-bn-tobin'
-rw-r--r-- | src/openssl.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 69115ce..4da28ef 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -1753,6 +1753,16 @@ static BN_CTX *getctx(lua_State *L) { | |||
1753 | } /* getctx() */ | 1753 | } /* getctx() */ |
1754 | 1754 | ||
1755 | 1755 | ||
1756 | static int bn_tobin(lua_State *L) { | ||
1757 | BIGNUM *bn = checksimple(L, 1, BIGNUM_CLASS); | ||
1758 | size_t len = BN_num_bytes(bn); | ||
1759 | unsigned char* dst = lua_newuserdata(L, len); | ||
1760 | BN_bn2bin(bn, dst); | ||
1761 | lua_pushlstring(L, dst, len); | ||
1762 | return 1; | ||
1763 | } /* bn_tobin() */ | ||
1764 | |||
1765 | |||
1756 | static int bn__add(lua_State *L) { | 1766 | static int bn__add(lua_State *L) { |
1757 | BIGNUM *r, *a, *b; | 1767 | BIGNUM *r, *a, *b; |
1758 | 1768 | ||
@@ -1898,6 +1908,7 @@ static int bn__tostring(lua_State *L) { | |||
1898 | 1908 | ||
1899 | 1909 | ||
1900 | static const luaL_Reg bn_methods[] = { | 1910 | static const luaL_Reg bn_methods[] = { |
1911 | { "tobin", &bn_tobin }, | ||
1901 | { NULL, NULL }, | 1912 | { NULL, NULL }, |
1902 | }; | 1913 | }; |
1903 | 1914 | ||