summaryrefslogtreecommitdiff
path: root/tests/test3.lua
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-12 17:55:04 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-12 17:55:04 +0200
commitcff5910982e3201d4b79178b8204d5dc5b95f166 (patch)
treed206a7d5ed676fc230fdafb3d52bb7d86072c457 /tests/test3.lua
parent84f60bbd5db549b655e12a49ec8557e18c1b8d15 (diff)
Adding BigInt support and test to Dalos.
Diffstat (limited to 'tests/test3.lua')
-rw-r--r--tests/test3.lua22
1 files changed, 8 insertions, 14 deletions
diff --git a/tests/test3.lua b/tests/test3.lua
index 15c59e3..aeea660 100644
--- a/tests/test3.lua
+++ b/tests/test3.lua
@@ -1,16 +1,10 @@
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 - 5)
- 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
+ local x = BigInt.new "1234"
+ local y = BigInt.new "5678"
+ local z = x + y
+ if tostring(z) ~= "6912" then error "bigint1" end
+ -- unlike PHP, Lua is smarter. An object and a number aren't the same things, thus aren't equal.
+ if z == 6912 then error "bigint2" end
+ -- this is the proper comparison.
+ if z ~= BigInt.new(6912) then error "bigint3" end
end