[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 02/02: GNS: Fix revocation TVs.
From: |
gnunet |
Subject: |
[gnunet] 02/02: GNS: Fix revocation TVs. |
Date: |
Tue, 04 Jul 2023 15:29:04 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 34adfb777074bc23c950207d24ff078af29cddf6
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jul 4 15:28:49 2023 +0200
GNS: Fix revocation TVs.
---
src/gnsrecord/test_gnsrecord_testvectors.c | 93 ++++++++++++++++++++++++++++--
src/revocation/Makefile.am | 10 +++-
src/revocation/gnunet-revocation-tvg.c | 67 ++++++++++++++-------
3 files changed, 144 insertions(+), 26 deletions(-)
diff --git a/src/gnsrecord/test_gnsrecord_testvectors.c
b/src/gnsrecord/test_gnsrecord_testvectors.c
index af91518ac..c68ea56b3 100644
--- a/src/gnsrecord/test_gnsrecord_testvectors.c
+++ b/src/gnsrecord/test_gnsrecord_testvectors.c
@@ -22,10 +22,93 @@ struct GnsTv
char *nonce;
};
-/** The first tests is from the Go implementation.
- * The second test from GNUnet. But both produce different, verifiable
- * signatures.
- */
+struct RevocationTv
+{
+ char *d;
+ char *zid;
+ char *ztld;
+ char *m;
+ char *proof;
+ int diff;
+ int epochs;
+};
+
+struct RevocationTv rtvs[] = {
+ {
+ .d =
+ "70 ed 98 b9 07 8c 47 f7"
+ "d5 78 3b 26 cc f9 8b 7d"
+ "d5 5f 60 88 d1 53 95 97"
+ "fa 8b f5 5a c0 32 ea 6f",
+ .zid =
+ "00 01 00 00 2c a2 23 e8"
+ "79 ec c4 bb de b5 da 17"
+ "31 92 81 d6 3b 2e 3b 69"
+ "55 f1 c3 77 5c 80 4a 98"
+ "d5 f8 dd aa",
+ .ztld =
+ "000G001CM8HYGYFCRJXXXDET2WRS50EP7CQ3PTANY71QEQ409ACDBY6XN8",
+ .m =
+ "00 00 00 34 00 00 00 03"
+ "00 05 fe b4 6d 86 5c 1c"
+ "00 01 00 00 2c a2 23 e8"
+ "79 ec c4 bb de b5 da 17"
+ "31 92 81 d6 3b 2e 3b 69"
+ "55 f1 c3 77 5c 80 4a 98"
+ "d5 f8 dd aa",
+ .proof =
+ "00 05 fe b4 6d 86 5c 1c"
+ "00 00 39 5d 18 27 c0 00"
+ "e6 6a 57 0b cc d4 b3 93"
+ "e6 6a 57 0b cc d4 b3 ea"
+ "e6 6a 57 0b cc d4 b5 36"
+ "e6 6a 57 0b cc d4 b5 42"
+ "e6 6a 57 0b cc d4 b6 13"
+ "e6 6a 57 0b cc d4 b6 5f"
+ "e6 6a 57 0b cc d4 b6 72"
+ "e6 6a 57 0b cc d4 b7 0a"
+ "e6 6a 57 0b cc d4 b7 1a"
+ "e6 6a 57 0b cc d4 b7 23"
+ "e6 6a 57 0b cc d4 b7 47"
+ "e6 6a 57 0b cc d4 b7 77"
+ "e6 6a 57 0b cc d4 b7 85"
+ "e6 6a 57 0b cc d4 b7 89"
+ "e6 6a 57 0b cc d4 b7 cf"
+ "e6 6a 57 0b cc d4 b7 dc"
+ "e6 6a 57 0b cc d4 b9 3a"
+ "e6 6a 57 0b cc d4 b9 56"
+ "e6 6a 57 0b cc d4 ba 4a"
+ "e6 6a 57 0b cc d4 ba 9d"
+ "e6 6a 57 0b cc d4 bb 28"
+ "e6 6a 57 0b cc d4 bb 5a"
+ "e6 6a 57 0b cc d4 bb 92"
+ "e6 6a 57 0b cc d4 bb a2"
+ "e6 6a 57 0b cc d4 bb d8"
+ "e6 6a 57 0b cc d4 bb e2"
+ "e6 6a 57 0b cc d4 bc 93"
+ "e6 6a 57 0b cc d4 bc 94"
+ "e6 6a 57 0b cc d4 bd 0f"
+ "e6 6a 57 0b cc d4 bd ce"
+ "e6 6a 57 0b cc d4 be 6a"
+ "e6 6a 57 0b cc d4 be 73"
+ "00 01 00 00 2c a2 23 e8"
+ "79 ec c4 bb de b5 da 17"
+ "31 92 81 d6 3b 2e 3b 69"
+ "55 f1 c3 77 5c 80 4a 98"
+ "d5 f8 dd aa 04 4a 87 8a"
+ "15 8b 40 f0 c8 41 d9 f9"
+ "78 cb 13 72 ea ee 51 99"
+ "a3 d8 7e 5e 2b db c7 2a"
+ "6c 8c 73 d0 00 18 1d fc"
+ "39 c3 aa a4 81 66 7b 16"
+ "5b 58 44 e4 50 71 3d 8a"
+ "b6 a3 b2 ba 8f ef 44 7b"
+ "65 07 6a 0f",
+ .diff = 5,
+ .epochs = 2
+ }
+};
+
struct GnsTv tvs[] = {
{ .d =
"50 d7 b6 52 a4 ef ea df"
@@ -525,6 +608,8 @@ main ()
struct GNUNET_HashCode query;
struct GNUNET_HashCode expected_query;
struct GNUNET_TIME_Absolute expire;
+ struct GNUNET_TIME_Relative exprel;
+ struct GNUNET_REVOCATION_PowP *pow;
char label[128];
char rdata[8096];
char ztld[128];
diff --git a/src/revocation/Makefile.am b/src/revocation/Makefile.am
index ae8231a3c..71f30aab2 100644
--- a/src/revocation/Makefile.am
+++ b/src/revocation/Makefile.am
@@ -50,6 +50,13 @@ gnunet_revocation_tvg_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
+test_revocation_lsd0001testvectors_SOURCES = \
+ test_revocation_testvectors.c
+test_revocation_lsd0001testvectors_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ libgnunetrevocation.la \
+ $(top_builddir)/src/util/libgnunetutil.la
lib_LTLIBRARIES = libgnunetrevocation.la
@@ -92,7 +99,8 @@ test_revocation_LDADD = \
$(top_builddir)/src/testbed/libgnunettestbed.la
check_PROGRAMS = \
- test_revocation
+ test_revocation \
+ test_revocation_lsd0001testvectors
check_SCRIPTS = \
test_local_revocation.py
diff --git a/src/revocation/gnunet-revocation-tvg.c
b/src/revocation/gnunet-revocation-tvg.c
index 4dcf6e28f..0020c2d26 100644
--- a/src/revocation/gnunet-revocation-tvg.c
+++ b/src/revocation/gnunet-revocation-tvg.c
@@ -37,6 +37,9 @@
static char*d_pkey =
"6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70";
+static char *d_edkey =
+ "5af7020ee19160328832352bbc6a68a8d71a7cbe1b929969a7c66d415a0d8f65";
+
int
parsehex (char *src, char *dst, size_t dstlen, int invert)
{
@@ -71,10 +74,14 @@ print_bytes_ (void *buf,
if (0 != i)
{
if ((0 != fold) && (i % fold == 0))
- printf ("\n");
+ printf ("\n ");
else
printf (" ");
}
+ else
+ {
+ printf (" ");
+ }
if (in_be)
printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]);
else
@@ -93,21 +100,9 @@ print_bytes (void *buf,
}
-/**
- * Main function that will be run.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be
NULL!)
- * @param cfg configuration
- */
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run_with_key (struct GNUNET_IDENTITY_PrivateKey *id_priv)
{
- struct GNUNET_IDENTITY_PrivateKey id_priv;
struct GNUNET_IDENTITY_PublicKey id_pub;
struct GNUNET_REVOCATION_PowP *pow;
struct GNUNET_REVOCATION_PowCalculationHandle *ph;
@@ -115,18 +110,13 @@ run (void *cls,
char ztld[128];
ssize_t key_len;
- id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
- GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
- parsehex (d_pkey,(char*) &id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1);
- GNUNET_IDENTITY_key_get_public (&id_priv,
+ GNUNET_IDENTITY_key_get_public (id_priv,
&id_pub);
GNUNET_STRINGS_data_to_string (&id_pub,
GNUNET_IDENTITY_public_key_get_length (
&id_pub),
ztld,
sizeof (ztld));
- fprintf (stdout, "Zone private key (d, big-endian scalar):\n");
- print_bytes (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8);
fprintf (stdout, "\n");
fprintf (stdout, "Zone identifier (ztype|zkey):\n");
key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub);
@@ -137,7 +127,7 @@ run (void *cls,
fprintf (stdout, "%s\n", ztld);
fprintf (stdout, "\n");
pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE);
- GNUNET_REVOCATION_pow_init (&id_priv,
+ GNUNET_REVOCATION_pow_init (id_priv,
pow);
ph = GNUNET_REVOCATION_pow_start (pow,
TEST_EPOCHS,
@@ -170,6 +160,41 @@ run (void *cls,
GNUNET_REVOCATION_proof_get_size (pow),
8);
GNUNET_free (ph);
+
+}
+
+
+/**
+ * Main function that will be run.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be
NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct GNUNET_IDENTITY_PrivateKey id_priv;
+
+ id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
+ GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
+ parsehex (d_pkey,(char*) &id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1);
+
+ fprintf (stdout, "Zone private key (d, big-endian):\n");
+ print_bytes_ (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8, 1);
+ run_with_key (&id_priv);
+ printf ("\n");
+ id_priv.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA);
+ GNUNET_CRYPTO_eddsa_key_create (&id_priv.eddsa_key);
+ parsehex (d_edkey,(char*) &id_priv.eddsa_key, sizeof (id_priv.eddsa_key), 0);
+
+ fprintf (stdout, "Zone private key (d):\n");
+ print_bytes (&id_priv.eddsa_key, sizeof(id_priv.eddsa_key), 8);
+ run_with_key (&id_priv);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.