diff options
-rw-r--r-- | src/openssl.c | 30 | ||||
-rw-r--r-- | src/openssl.des.lua | 3 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 58e60a6..dcebeef 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -73,6 +73,7 @@ #include <openssl/ssl.h> #include <openssl/hmac.h> #include <openssl/rand.h> +#include <openssl/des.h> #include <lua.h> #include <lualib.h> @@ -5606,6 +5607,35 @@ int luaopen__openssl_rand(lua_State *L) { /* + * DES - openssl.des + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static int de5_string_to_key(lua_State *L) { + DES_cblock key; + + DES_string_to_key(luaL_checkstring(L, 1), &key); + lua_pushlstring(L, (char *)key, sizeof key); + + return 1; +} /* de5_string_to_key() */ + + +static const luaL_Reg des_globals[] = { + { "string_to_key", &de5_string_to_key }, + { NULL, NULL }, +}; + +int luaopen__openssl_des(lua_State *L) { + initall(L); + + luaL_newlib(L, des_globals); + + return 1; +} /* luaopen__openssl_des() */ + + +/* * Multithread Reentrancy Protection * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/src/openssl.des.lua b/src/openssl.des.lua new file mode 100644 index 0000000..449267c --- /dev/null +++ b/src/openssl.des.lua @@ -0,0 +1,3 @@ +local ctx = require"_openssl.des" + +return ctx |