Closed mibamur closed 10 years ago
Thanks. I think the problem in fileenc source itself not in binding code.
May be it related with x64 arch.
You could build test application by building src/fileenc/*.c (without main.c
) defining TEST
macro.
$ luarocks build /home/debadmin/doc/lua/lua-AesFileEncrypt/rockspecs/aesfileencrypt-scm-0.rockspec
Archive: master.zip
849193c7aa66ddffa87145f725db6e94aed031cd
creating: lua-AesFileEncrypt-master/
inflating: lua-AesFileEncrypt-master/.gitignore
inflating: lua-AesFileEncrypt-master/.travis.yml
inflating: lua-AesFileEncrypt-master/README.md
creating: lua-AesFileEncrypt-master/examples/
inflating: lua-AesFileEncrypt-master/examples/eload.lua
inflating: lua-AesFileEncrypt-master/examples/fileenc.lua
extracting: lua-AesFileEncrypt-master/examples/prog.elua
inflating: lua-AesFileEncrypt-master/examples/prog.lua
inflating: lua-AesFileEncrypt-master/lakeconfig.lua
inflating: lua-AesFileEncrypt-master/lakefile
creating: lua-AesFileEncrypt-master/rockspecs/
inflating: lua-AesFileEncrypt-master/rockspecs/aesfileencrypt-0.1.0-1.rockspec
inflating: lua-AesFileEncrypt-master/rockspecs/aesfileencrypt-0.1.1-1.rockspec
inflating: lua-AesFileEncrypt-master/rockspecs/aesfileencrypt-scm-0.rockspec
creating: lua-AesFileEncrypt-master/src/
inflating: lua-AesFileEncrypt-master/src/AesFileEncrypt.c
inflating: lua-AesFileEncrypt-master/src/AesFileEncrypt.def
creating: lua-AesFileEncrypt-master/src/fileenc/
inflating: lua-AesFileEncrypt-master/src/fileenc/aes.h
inflating: lua-AesFileEncrypt-master/src/fileenc/aescrypt.c
inflating: lua-AesFileEncrypt-master/src/fileenc/aeskey.c
inflating: lua-AesFileEncrypt-master/src/fileenc/aesopt.h
inflating: lua-AesFileEncrypt-master/src/fileenc/aestab.c
inflating: lua-AesFileEncrypt-master/src/fileenc/fileenc.c
inflating: lua-AesFileEncrypt-master/src/fileenc/fileenc.h
inflating: lua-AesFileEncrypt-master/src/fileenc/hmac.c
inflating: lua-AesFileEncrypt-master/src/fileenc/hmac.h
inflating: lua-AesFileEncrypt-master/src/fileenc/main.c
inflating: lua-AesFileEncrypt-master/src/fileenc/platform_byte_order.h
inflating: lua-AesFileEncrypt-master/src/fileenc/prng.c
inflating: lua-AesFileEncrypt-master/src/fileenc/prng.h
inflating: lua-AesFileEncrypt-master/src/fileenc/pwd2key.c
inflating: lua-AesFileEncrypt-master/src/fileenc/pwd2key.h
inflating: lua-AesFileEncrypt-master/src/fileenc/sha1.c
inflating: lua-AesFileEncrypt-master/src/fileenc/sha1.h
inflating: lua-AesFileEncrypt-master/src/l52util.c
inflating: lua-AesFileEncrypt-master/src/l52util.h
creating: lua-AesFileEncrypt-master/test/
inflating: lua-AesFileEncrypt-master/test/test.lua
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/aescrypt.c -o src/fileenc/aescrypt.o -DUSE_SHA1
In file included from src/fileenc/aesopt.h:226:0,
from src/fileenc/aescrypt.c:38:
src/fileenc/platform_byte_order.h:107:11: warning: multi-character character constant [-Wmultichar]
# elif (('1234' >> 24) == '1')
^
src/fileenc/platform_byte_order.h:110:11: warning: multi-character character constant [-Wmultichar]
# elif (('4321' >> 24) == '1')
^
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/aeskey.c -o src/fileenc/aeskey.o -DUSE_SHA1
In file included from src/fileenc/aesopt.h:226:0,
from src/fileenc/aeskey.c:37:
src/fileenc/platform_byte_order.h:107:11: warning: multi-character character constant [-Wmultichar]
# elif (('1234' >> 24) == '1')
^
src/fileenc/platform_byte_order.h:110:11: warning: multi-character character constant [-Wmultichar]
# elif (('4321' >> 24) == '1')
^
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/aestab.c -o src/fileenc/aestab.o -DUSE_SHA1
In file included from src/fileenc/aesopt.h:226:0,
from src/fileenc/aestab.c:36:
src/fileenc/platform_byte_order.h:107:11: warning: multi-character character constant [-Wmultichar]
# elif (('1234' >> 24) == '1')
^
src/fileenc/platform_byte_order.h:110:11: warning: multi-character character constant [-Wmultichar]
# elif (('4321' >> 24) == '1')
^
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/fileenc.c -o src/fileenc/fileenc.o -DUSE_SHA1
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/hmac.c -o src/fileenc/hmac.o -DUSE_SHA1
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/prng.c -o src/fileenc/prng.o -DUSE_SHA1
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/pwd2key.c -o src/fileenc/pwd2key.o -DUSE_SHA1
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/fileenc/sha1.c -o src/fileenc/sha1.o -DUSE_SHA1
In file included from src/fileenc/sha1.c:50:0:
src/fileenc/platform_byte_order.h:107:11: warning: multi-character character constant [-Wmultichar]
# elif (('1234' >> 24) == '1')
^
src/fileenc/platform_byte_order.h:110:11: warning: multi-character character constant [-Wmultichar]
# elif (('4321' >> 24) == '1')
^
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/AesFileEncrypt.c -o src/AesFileEncrypt.o -DUSE_SHA1
gcc -O2 -fPIC -I/usr/local/openresty/luajit/include/luajit-2.0 -c src/l52util.c -o src/l52util.o -DUSE_SHA1
gcc -shared -o AesFileEncrypt.so -L/usr/local/openresty/luajit//lib src/fileenc/aescrypt.o src/fileenc/aeskey.o src/fileenc/aestab.o src/fileenc/fileenc.o src/fileenc/hmac.o src/fileenc/prng.o src/fileenc/pwd2key.o src/fileenc/sha1.o src/AesFileEncrypt.o src/l52util.o
Updating manifest for /usr/local/openresty/luajit//lib/luarocks/rocks
aesfileencrypt scm-0 is now built and installed in /usr/local/openresty/luajit/ (license: GPL)
✔ debadmin@deb (master) ~/doc/lua/lua-AesFileEncrypt/rockspecs
$
$ lua test.lua
Loaded testsuite with 6 tests in 1 testcases.
.FFF.F
31 Assertions checked.
1) Failure (AesFileEncrypt.test_encrypt_string):
test.lua:69: expected '9aa9' but was 'ece1'
2) Failure (AesFileEncrypt.test_encrypt_stream):
test.lua:116: expected '9aa9' but was 'ece1'
3) Failure (AesFileEncrypt.test_encrypt_context):
test.lua:135: expected '9aa9' but was 'ece1'
4) Failure (AesFileEncrypt.test_encrypt_writer):
test.lua:87: expected '9aa9' but was 'ece1'
Testsuite finished (2 passed, 4 failed, 0 errors).
But fileenc.lua
works fine. Encrypt anf decrypt works
my system Linux Debian 3.9.5 x86_64 GNU/Linux
This is what i talk about. This is not correct result so you can not e.g. decrypt data that was encryped on different platform. Test data was teted with winzip/winrar/7z. Today i plan create new repo for testing only aes/sha/hmac with latest sources.
Sounds good. Any help? just say.
I just upload new branch (bgcrypto). But zipball doesn't contain submodules so to install it you need manually clone repo with submodules and run luarocks make rockspecs\aesfileencrypt-scm-0.rockspec
.
Please test current master.
I do clone
then luarocks build aesfileencrypt-scm-0.rockspec
$ lua test.lua
Loaded testsuite with 6 tests in 1 testcases.
......
47 Assertions checked.
Testsuite finished (6 passed, 0 failed, 0 errors).
As I see build without problems and test passed too
And lua fileenc.lua decrypt 123456 prog.elua
fine too. Awesome!
Hello! I`ll help