From 34adfb777074bc23c950207d24ff078af29cddf6 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 4 Jul 2023 15:28:49 +0200 Subject: GNS: Fix revocation TVs. --- src/revocation/Makefile.am | 10 ++++- src/revocation/gnunet-revocation-tvg.c | 67 +++++++++++++++++++++++----------- 2 files changed, 55 insertions(+), 22 deletions(-) (limited to 'src/revocation') 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); } -- cgit v1.2.3