From 685b4c9e4038268872d4f144bd495aae518c23de Mon Sep 17 00:00:00 2001 From: william Date: Wed, 25 Feb 2015 12:45:18 -0800 Subject: add des module to make it easier to implement NTLM authentication protocol --- src/openssl.c | 30 ++++++++++++++++++++++++++++++ src/openssl.des.lua | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 src/openssl.des.lua 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 #include #include +#include #include #include @@ -5605,6 +5606,35 @@ int luaopen__openssl_rand(lua_State *L) { } /* luaopen__openssl_rand() */ +/* + * 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 -- cgit v1.2.3-59-g8ed1b