Skip to content

Commit

Permalink
Version 1.3.
Browse files Browse the repository at this point in the history
Improvement in the tests and generalization of the Makefile.
  • Loading branch information
tomasguisasola committed Apr 16, 2019
1 parent 2d8e18d commit 2a98633
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 27 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ src/$(DES56_LIBNAME) : $(DES56_OBJS) $(COMPAT52_OBJS)
$(CC) $(CFLAGS) $(LIB_OPTION) -o src/$(DES56_LIBNAME) $(DES56_OBJS) $(COMPAT52_OBJS)

install: src/$(MD5_LIBNAME) src/$(DES56_LIBNAME)
cp src/$(DES56_LIBNAME) $(LUA_LIBDIR)
mkdir -p $(LUA_LIBDIR)/md5
cp src/$(MD5_LIBNAME) $(LUA_LIBDIR)/md5.so
cp src/$(MD5_LIBNAME) $(LUA_LIBDIR)/md5/
mkdir -p $(LUA_DIR)
cp src/$(DES56_LIBNAME) $(LUA_LIBDIR)
cp $(MD5_LUAS) $(LUA_DIR)

clean:
rm -f $(MD5_OBJS) src/$(MD5_LIBNAME) $(DES56_OBJS) src/$(DES56_LIBNAME) $(COMPAT52_OBJS)
7 changes: 5 additions & 2 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# Default prefix
PREFIX = /usr/local

# Lua version
LUA_SYS_VER ?= 5.2

# System's libraries directory (where binary libraries are installed)
LUA_LIBDIR= $(PREFIX)/lib/lua/5.1
LUA_LIBDIR= $(PREFIX)/lib/lua/$(LUA_SYS_VER)

# System's lua directory (where Lua libraries are installed)
LUA_DIR= $(PREFIX)/share/lua/5.1
LUA_DIR= $(PREFIX)/share/lua/$(LUA_SYS_VER)

# Lua includes directory
LUA_INC= $(PREFIX)/include
Expand Down
15 changes: 12 additions & 3 deletions doc/us/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,26 @@ <h1>MD5</h1>
<h2><a name="overview"></a>Overview</h2>

<p>
MD5 offers basic cryptographic facilities for
<a href="http://www.lua.org">Lua</a> 5.0, 5.1 or 5.2:
MD5 offers checksum facilities for
<a href="http://www.lua.org">Lua</a> 5.X:
a hash (digest) function, a pair crypt/decrypt based on
<a href="http://en.wikipedia.org/wiki/MD5">MD5</a> and CFB,
and a pair crypt/decrypt based on
<a href="http://en.wikipedia.org/wiki/Data_Encryption_Standard">DES</a> with 56-bit keys.
</p>

<p>
Note that although <a href="https://en.wikipedia.org/wiki/MD5">MD5</a> was designed to be used as a cryptographic hash function, it was found that key collisions could be calculated in a few seconds, thus it should not be used where a <a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function">cryptographic hash</a> is required.
<p>

<p>
MD5 is free software and uses the same <a href="license.html">license</a>
as Lua (MIT).
</p>

<h2><a name="status"></a>Status</h2>

<p>MD5 version 1.2 is now available for
<p>MD5 version 1.3 is now available for
<a href="#download">download</a>.</p>

<h2><a name="download"></a>Download</h2>
Expand All @@ -96,6 +100,11 @@ <h2><a name="download"></a>Download</h2>
<h2><a name="history"></a>History</h2>

<dl class="history">
<dt><strong>Version 1.3</strong> [16/Apr/2019]</dt>
<dd><ul>
<li>Code updated to compile for Lua 5.X. Tested with Lua 5.1, 5.2, 5.3 and 5.4-work2.</li>
</ul></dd>

<dt><strong>Version 1.2</strong> [06/Sep/2013]</dt>
<dd><ul>
<li>Code adapted to compile for Lua 5.0, 5.1 and 5.2</li>
Expand Down
2 changes: 1 addition & 1 deletion src/des56.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LIBRARY des56.dll
DESCRIPTION "DES56"
VERSION 1.2
VERSION 1.3
EXPORTS
luaopen_des56
4 changes: 2 additions & 2 deletions src/ldes56.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ static int des56_crypt( lua_State *L )
*/
static void set_info (lua_State *L) {
lua_pushliteral (L, "_COPYRIGHT");
lua_pushliteral (L, "Copyright (C) 2007-2013 PUC-Rio");
lua_pushliteral (L, "Copyright (C) 2007-2019 PUC-Rio");
lua_settable (L, -3);
lua_pushliteral (L, "_DESCRIPTION");
lua_pushliteral (L, "DES 56 cryptographic facilities for Lua");
lua_settable (L, -3);
lua_pushliteral (L, "_VERSION");
lua_pushliteral (L, "DES56 1.2");
lua_pushliteral (L, "DES56 1.3");
lua_settable (L, -3);
}

Expand Down
8 changes: 0 additions & 8 deletions src/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
#include <string.h>
#include <time.h>

#include <lua.h>
#include <lauxlib.h>

#if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
#include "compat-5.1.h"
#endif


#include "md5.h"


Expand Down
4 changes: 2 additions & 2 deletions src/md5.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LIBRARY core.dll
DESCRIPTION "LuaMD5"
VERSION 1.2
VERSION 1.3
EXPORTS
luaopen_md5
luaopen_md5_core
2 changes: 1 addition & 1 deletion src/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int md5_update (md5_t *m, const char *message, size_t len);
void md5_finish (md5_t *m, char output[HASHSIZE]);
void md5 (const char *message, size_t len, char output[HASHSIZE]);

LUALIB_API int luaopen_md5 (lua_State *L);
LUALIB_API int luaopen_md5_core (lua_State *L);


#endif
6 changes: 3 additions & 3 deletions src/md5lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ static int decrypt (lua_State *L) {
*/
static void set_info (lua_State *L) {
lua_pushliteral (L, "_COPYRIGHT");
lua_pushliteral (L, "Copyright (C) 2003-2013 PUC-Rio");
lua_pushliteral (L, "Copyright (C) 2003-2019 PUC-Rio");
lua_settable (L, -3);
lua_pushliteral (L, "_DESCRIPTION");
lua_pushliteral (L, "Basic cryptographic facilities");
lua_pushliteral (L, "Checksum facilities for Lua");
lua_settable (L, -3);
lua_pushliteral (L, "_VERSION");
lua_pushliteral (L, "MD5 1.2");
lua_pushliteral (L, "MD5 1.3");
lua_settable (L, -3);
}

Expand Down
7 changes: 4 additions & 3 deletions tests/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if string.find(_VERSION, "Lua 5.0") then
string.gmatch = string.gfind
end
local md5 = require"md5"
io.write (md5._VERSION..' '.._VERSION..'\n')


assert(md5.exor('', '') == '')
Expand Down Expand Up @@ -50,7 +51,7 @@ assert(md5.sumhexa(
"12345678901234567890123456789012345678901234567890123456789012345678901234567890")
== "57edf4a22be3c955ac49da2e2107b67a")

print '+'
io.write '+'



Expand Down Expand Up @@ -82,7 +83,7 @@ contchars(code)
local seed = 'some_seed'
assert(md5.crypt('a','a',seed) ~= md5.crypt('a','b',seed))

print"MD5 OK"
io.write'+'


-- Testing DES 56
Expand Down Expand Up @@ -117,4 +118,4 @@ assert(des56.decrypt(des56.crypt(ascii, key), key) == ascii)
key = string.sub(ascii, 2)
assert(des56.decrypt(des56.crypt(ascii, key), key) == ascii)

print"DES56 OK"
io.write'+\n'

0 comments on commit 2a98633

Please sign in to comment.