From 13f51c1c93ee31eb9e4f4f192ba6c51cd5945134 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 8 Aug 2013 18:05:04 +0200 Subject: Adding a test for RSA ; turns out it doesn't work so great... --- tests/test3.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/test3.lua (limited to 'tests/test3.lua') 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 -- cgit v1.2.3