[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 02/02: more unit crypto tests
From: |
gnunet |
Subject: |
[taler-exchange] 02/02: more unit crypto tests |
Date: |
Sat, 11 Jul 2020 17:26:06 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 82b6067de68cbaed7bfd01222fab8f0c2f6b9cfb
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jul 11 17:26:02 2020 +0200
more unit crypto tests
---
src/util/test_crypto.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 2 deletions(-)
diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c
index 99d197b6..af5b6d5e 100644
--- a/src/util/test_crypto.c
+++ b/src/util/test_crypto.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2015 Taler Systems SA
+ (C) 2015, 2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -119,6 +119,89 @@ test_planchets (void)
}
+static int
+test_exchange_sigs ()
+{
+ const char *pt = "payto://x-taler-bank/localhost/Account";
+ struct TALER_MasterPrivateKeyP priv;
+ struct TALER_MasterPublicKeyP pub;
+ struct TALER_MasterSignatureP sig;
+
+ GNUNET_CRYPTO_eddsa_key_create (&priv.eddsa_priv);
+ TALER_exchange_wire_signature_make (pt,
+ &priv,
+ &sig);
+ GNUNET_CRYPTO_eddsa_key_get_public (&priv.eddsa_priv,
+ &pub.eddsa_pub);
+ if (GNUNET_OK !=
+ TALER_exchange_wire_signature_check (pt,
+ &pub,
+ &sig))
+ {
+ GNUNET_break (0);
+ return 1;
+ }
+ if (GNUNET_OK ==
+ TALER_exchange_wire_signature_check (
+ "payto://x-taler-bank/localhost/Other",
+ &pub,
+ &sig))
+ {
+ GNUNET_break (0);
+ return 1;
+ }
+ return 0;
+}
+
+
+static int
+test_merchant_sigs ()
+{
+ const char *pt = "payto://x-taler-bank/localhost/Account";
+ const char *salt = "my test salt";
+ struct TALER_MerchantPrivateKeyP priv;
+ struct TALER_MerchantPublicKeyP pub;
+ struct TALER_MerchantSignatureP sig;
+
+ GNUNET_CRYPTO_eddsa_key_create (&priv.eddsa_priv);
+ TALER_merchant_wire_signature_make (pt,
+ salt,
+ &priv,
+ &sig);
+ GNUNET_CRYPTO_eddsa_key_get_public (&priv.eddsa_priv,
+ &pub.eddsa_pub);
+ if (GNUNET_OK !=
+ TALER_merchant_wire_signature_check (pt,
+ salt,
+ &pub,
+ &sig))
+ {
+ GNUNET_break (0);
+ return 1;
+ }
+ if (GNUNET_OK ==
+ TALER_merchant_wire_signature_check (
+ "payto://x-taler-bank/localhost/Other",
+ salt,
+ &pub,
+ &sig))
+ {
+ GNUNET_break (0);
+ return 1;
+ }
+ if (GNUNET_OK ==
+ TALER_merchant_wire_signature_check (pt,
+ "other salt",
+ &pub,
+ &sig))
+ {
+ GNUNET_break (0);
+ return 1;
+ }
+ return 0;
+}
+
+
int
main (int argc,
const char *const argv[])
@@ -128,7 +211,11 @@ main (int argc,
if (0 != test_high_level ())
return 1;
if (0 != test_planchets ())
- return 1;
+ return 2;
+ if (0 != test_exchange_sigs ())
+ return 3;
+ if (0 != test_merchant_sigs ())
+ return 4;
return 0;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.