summaryrefslogtreecommitdiff
path: root/scripts/test-nettle.lua
diff options
context:
space:
mode:
authorIronClawTrem <louie.nutman@gmail.com>2020-02-16 03:40:06 +0000
committerIronClawTrem <louie.nutman@gmail.com>2020-02-16 03:40:06 +0000
commit425decdf7e9284d15aa726e3ae96b9942fb0e3ea (patch)
tree6c0dd7edfefff1be7b9e75fe0b3a0a85fe1595f3 /scripts/test-nettle.lua
parentccb0b2e4d6674a7a00c9bf491f08fc73b6898c54 (diff)
create tremded branch
Diffstat (limited to 'scripts/test-nettle.lua')
-rw-r--r--scripts/test-nettle.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/test-nettle.lua b/scripts/test-nettle.lua
new file mode 100644
index 0000000..09a96be
--- /dev/null
+++ b/scripts/test-nettle.lua
@@ -0,0 +1,24 @@
+print "nettle tests begin"
+
+empty_hash = tostring(nettle.sha256())
+
+ctx = nettle.sha256()
+ctx:update(nil)
+assert(empty_hash == tostring(ctx))
+
+ctx = nettle.sha256()
+ctx:update("Hello World!")
+ctx:update("Hello World!")
+hash = tostring(ctx)
+assert(hash == "95a5a79bf6218dd0938950acb61bca24d5809172fe6cfd7f1af4b059449e52f8")
+
+ctx = nettle.sha256()
+ctx:update("Hello World!Hello World!")
+hash = tostring(ctx)
+assert(hash == "95a5a79bf6218dd0938950acb61bca24d5809172fe6cfd7f1af4b059449e52f8")
+
+require "util"
+hash = hash_file("../../COPYING")
+assert(hash == "8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643")
+
+print "nettle tests completed"