summaryrefslogtreecommitdiff
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
parent84f60bbd5db549b655e12a49ec8557e18c1b8d15 (diff)
Adding BigInt support and test to Dalos.
m---------Balau0
-rw-r--r--src/Dalos-cli.cc2
-rw-r--r--tests/alltests.lua2
-rw-r--r--tests/test3.lua22
4 files changed, 11 insertions, 15 deletions
diff --git a/Balau b/Balau
-Subproject e4212db6a548b96b9b288eaa450ef1a18d2e250
+Subproject 758469279bda5810ed7cef45b5f301234bfc759
diff --git a/src/Dalos-cli.cc b/src/Dalos-cli.cc
index 887d7d1..b331f15 100644
--- a/src/Dalos-cli.cc
+++ b/src/Dalos-cli.cc
@@ -4,6 +4,7 @@
#include <LuaTask.h>
#include <Input.h>
#include <BStdIO.h>
+#include <LuaBigInt.h>
#include <LuaHandle.h>
#include "BReadline.h"
#include "LuaLoad.h"
@@ -43,6 +44,7 @@ namespace {
class DalosInit : public LuaExecCell {
virtual void run(Lua & L) override {
registerLuaLoad(L);
+ registerLuaBigInt(L);
registerLuaHandle(L);
}
};
diff --git a/tests/alltests.lua b/tests/alltests.lua
index de3385f..2879e57 100644
--- a/tests/alltests.lua
+++ b/tests/alltests.lua
@@ -5,5 +5,5 @@ load "tests/test3.lua"
function runtests()
test1()
test2()
--- test3()
+ test3()
end
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