From 1476267d26c9b0cac8818bf7a74696d48505b79d Mon Sep 17 00:00:00 2001 From: william Date: Wed, 25 Feb 2015 14:38:28 -0800 Subject: bind set_odd_parity as DES_string_to_key is incompatible with LM scheme --- src/openssl.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/openssl.c b/src/openssl.c index dcebeef..6e3039f 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -5620,9 +5620,24 @@ static int de5_string_to_key(lua_State *L) { return 1; } /* de5_string_to_key() */ +static int de5_set_odd_parity(lua_State *L) { + const char *src; + size_t len; + DES_cblock key; + + src = luaL_checklstring(L, 1, &len); + memset(&key, 0, sizeof key); + memcpy(&key, src, MIN(len, sizeof key)); + + DES_set_odd_parity(&key); + lua_pushlstring(L, (char *)key, sizeof key); + + return 1; +} /* de5_set_odd_parity() */ static const luaL_Reg des_globals[] = { - { "string_to_key", &de5_string_to_key }, + { "string_to_key", &de5_string_to_key }, + { "set_odd_parity", &de5_set_odd_parity }, { NULL, NULL }, }; -- cgit v1.2.3-59-g8ed1b