diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-08-08 18:05:04 +0200 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-08-08 18:05:04 +0200 |
commit | 13f51c1c93ee31eb9e4f4f192ba6c51cd5945134 (patch) | |
tree | 5d011f7a52414d0c77114878655418bf4db190ac /tests | |
parent | 86c24ca2a20cb570fdd14df7053b6e1950ca29d2 (diff) |
Adding a test for RSA ; turns out it doesn't work so great...
Diffstat (limited to 'tests')
-rw-r--r-- | tests/alltests.lua | 2 | ||||
-rw-r--r-- | tests/test3.lua | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/alltests.lua b/tests/alltests.lua index d4088e6..2879e57 100644 --- a/tests/alltests.lua +++ b/tests/alltests.lua @@ -1,7 +1,9 @@ load "tests/test1.lua" load "tests/test2.lua" +load "tests/test3.lua" function runtests() test1() test2() + test3() end diff --git a/tests/test3.lua b/tests/test3.lua new file mode 100644 index 0000000..b3b9eb9 --- /dev/null +++ b/tests/test3.lua @@ -0,0 +1,17 @@ +function test3() + print "testing rsa" + local bits = 2048 + local e = 65537 + local key = rsa:gen_key(bits, 65537) + --for k, v in pairs(key) do print(k.."=lcrypt.bigint(lcrypt.fromhex('"..lcrypt.tohex(tostring(v)).."'))") end + + msg = lcrypt.random(bits/8 - 1) + s = rsa:sign_oaep(msg, 'jello', key) + if rsa:verify_oaep(s, msg, 'jello', key) then + print "ok" + else + --for k, v in pairs(key) do print(k.."=lcrypt.bigint(lcrypt.fromhex('"..lcrypt.tohex(tostring(v)).."'))") end + error "rsa failure" + end +end +
\ No newline at end of file |