summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/05_crypto/03_eddsa
diff options
context:
space:
mode:
Diffstat (limited to 'tests/custom/05_crypto/03_eddsa')
-rw-r--r--tests/custom/05_crypto/03_eddsa70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/custom/05_crypto/03_eddsa b/tests/custom/05_crypto/03_eddsa
new file mode 100644
index 0000000..468e3b7
--- /dev/null
+++ b/tests/custom/05_crypto/03_eddsa
@@ -0,0 +1,70 @@
+-- Testcase --
+{%
+ import { pk as pk_openssl } from 'crypto_openssl';
+ import { test_eddsa } from './files/eddsa.uc';
+
+ const tests = {
+ test_1: {
+ // raw key = 'd75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a',
+ key: '302a300506032b6570032100d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a',
+ msg: '',
+ sig: 'e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b',
+ },
+ test_2: {
+ // raw key = '3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c'
+ key: '302a300506032b65700321003d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c',
+ msg: '72',
+ sig: '92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00',
+ },
+ test_3: {
+ // raw key = 'fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025'
+ key: '302a300506032b6570032100fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025',
+ msg: 'af82',
+ sig: '6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40a',
+ },
+ test_4_fail: {
+ key: '302a300506032b6570032100d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a',
+ msg: hexenc('Message'),
+ sig: '8e06163289f37c4e8a15cb3ddcf7379247f7820cea8488531579b32bf8aed7dc5dd4839e800ecc1911a8984344ef281db684b6f538d1c38a0a4570849e32fd02',
+ },
+ };
+
+ for (test in tests) {
+ test_eddsa(pk_openssl(), tests[test]);
+ }
+%}
+-- End --
+
+-- Expect stdout --
+true
+true
+true
+exception
+-- End --
+
+-- Expect stderr --
+-- End --
+
+-- File eddsa.uc --
+export
+function test_eddsa(pk, test)
+{
+ const pkey = test.key;
+ const msg = test.msg;
+ const s = test.sig;
+
+ const data = hexdec(msg);
+ const signature = hexdec(s);
+
+ //pk.set_raw_public_key('ED25519', hexdec(pkey));
+ pk.set_public_key(hexdec(pkey));
+
+ let verify = 'undefined';
+ try {
+ verify = pk.verify(null, data, signature);
+ } catch {
+ verify = 'exception';
+ }
+ print(verify, '\n');
+};
+-- End --