aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-07-04 15:28:49 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-07-04 15:28:49 +0200
commit34adfb777074bc23c950207d24ff078af29cddf6 (patch)
tree5a83d1f39c5271860cc8f2d574379d7ecad3b057 /src
parentcd6ef3fb3d9579630cebb332838731b062d7f101 (diff)
downloadgnunet-34adfb777074bc23c950207d24ff078af29cddf6.tar.gz
gnunet-34adfb777074bc23c950207d24ff078af29cddf6.zip
GNS: Fix revocation TVs.
Diffstat (limited to 'src')
-rw-r--r--src/gnsrecord/test_gnsrecord_testvectors.c93
-rw-r--r--src/revocation/Makefile.am10
-rw-r--r--src/revocation/gnunet-revocation-tvg.c67
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
22 char *nonce; 22 char *nonce;
23}; 23};
24 24
25/** The first tests is from the Go implementation. 25struct RevocationTv
26 * The second test from GNUnet. But both produce different, verifiable 26{
27 * signatures. 27 char *d;
28 */ 28 char *zid;
29 char *ztld;
30 char *m;
31 char *proof;
32 int diff;
33 int epochs;
34};
35
36struct RevocationTv rtvs[] = {
37 {
38 .d =
39 "70 ed 98 b9 07 8c 47 f7"
40 "d5 78 3b 26 cc f9 8b 7d"
41 "d5 5f 60 88 d1 53 95 97"
42 "fa 8b f5 5a c0 32 ea 6f",
43 .zid =
44 "00 01 00 00 2c a2 23 e8"
45 "79 ec c4 bb de b5 da 17"
46 "31 92 81 d6 3b 2e 3b 69"
47 "55 f1 c3 77 5c 80 4a 98"
48 "d5 f8 dd aa",
49 .ztld =
50 "000G001CM8HYGYFCRJXXXDET2WRS50EP7CQ3PTANY71QEQ409ACDBY6XN8",
51 .m =
52 "00 00 00 34 00 00 00 03"
53 "00 05 fe b4 6d 86 5c 1c"
54 "00 01 00 00 2c a2 23 e8"
55 "79 ec c4 bb de b5 da 17"
56 "31 92 81 d6 3b 2e 3b 69"
57 "55 f1 c3 77 5c 80 4a 98"
58 "d5 f8 dd aa",
59 .proof =
60 "00 05 fe b4 6d 86 5c 1c"
61 "00 00 39 5d 18 27 c0 00"
62 "e6 6a 57 0b cc d4 b3 93"
63 "e6 6a 57 0b cc d4 b3 ea"
64 "e6 6a 57 0b cc d4 b5 36"
65 "e6 6a 57 0b cc d4 b5 42"
66 "e6 6a 57 0b cc d4 b6 13"
67 "e6 6a 57 0b cc d4 b6 5f"
68 "e6 6a 57 0b cc d4 b6 72"
69 "e6 6a 57 0b cc d4 b7 0a"
70 "e6 6a 57 0b cc d4 b7 1a"
71 "e6 6a 57 0b cc d4 b7 23"
72 "e6 6a 57 0b cc d4 b7 47"
73 "e6 6a 57 0b cc d4 b7 77"
74 "e6 6a 57 0b cc d4 b7 85"
75 "e6 6a 57 0b cc d4 b7 89"
76 "e6 6a 57 0b cc d4 b7 cf"
77 "e6 6a 57 0b cc d4 b7 dc"
78 "e6 6a 57 0b cc d4 b9 3a"
79 "e6 6a 57 0b cc d4 b9 56"
80 "e6 6a 57 0b cc d4 ba 4a"
81 "e6 6a 57 0b cc d4 ba 9d"
82 "e6 6a 57 0b cc d4 bb 28"
83 "e6 6a 57 0b cc d4 bb 5a"
84 "e6 6a 57 0b cc d4 bb 92"
85 "e6 6a 57 0b cc d4 bb a2"
86 "e6 6a 57 0b cc d4 bb d8"
87 "e6 6a 57 0b cc d4 bb e2"
88 "e6 6a 57 0b cc d4 bc 93"
89 "e6 6a 57 0b cc d4 bc 94"
90 "e6 6a 57 0b cc d4 bd 0f"
91 "e6 6a 57 0b cc d4 bd ce"
92 "e6 6a 57 0b cc d4 be 6a"
93 "e6 6a 57 0b cc d4 be 73"
94 "00 01 00 00 2c a2 23 e8"
95 "79 ec c4 bb de b5 da 17"
96 "31 92 81 d6 3b 2e 3b 69"
97 "55 f1 c3 77 5c 80 4a 98"
98 "d5 f8 dd aa 04 4a 87 8a"
99 "15 8b 40 f0 c8 41 d9 f9"
100 "78 cb 13 72 ea ee 51 99"
101 "a3 d8 7e 5e 2b db c7 2a"
102 "6c 8c 73 d0 00 18 1d fc"
103 "39 c3 aa a4 81 66 7b 16"
104 "5b 58 44 e4 50 71 3d 8a"
105 "b6 a3 b2 ba 8f ef 44 7b"
106 "65 07 6a 0f",
107 .diff = 5,
108 .epochs = 2
109 }
110};
111
29struct GnsTv tvs[] = { 112struct GnsTv tvs[] = {
30 { .d = 113 { .d =
31 "50 d7 b6 52 a4 ef ea df" 114 "50 d7 b6 52 a4 ef ea df"
@@ -525,6 +608,8 @@ main ()
525 struct GNUNET_HashCode query; 608 struct GNUNET_HashCode query;
526 struct GNUNET_HashCode expected_query; 609 struct GNUNET_HashCode expected_query;
527 struct GNUNET_TIME_Absolute expire; 610 struct GNUNET_TIME_Absolute expire;
611 struct GNUNET_TIME_Relative exprel;
612 struct GNUNET_REVOCATION_PowP *pow;
528 char label[128]; 613 char label[128];
529 char rdata[8096]; 614 char rdata[8096];
530 char ztld[128]; 615 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 = \
50 $(top_builddir)/src/util/libgnunetutil.la \ 50 $(top_builddir)/src/util/libgnunetutil.la \
51 $(GN_LIBINTL) 51 $(GN_LIBINTL)
52 52
53test_revocation_lsd0001testvectors_SOURCES = \
54 test_revocation_testvectors.c
55test_revocation_lsd0001testvectors_LDADD = \
56 $(top_builddir)/src/testing/libgnunettesting.la \
57 $(top_builddir)/src/identity/libgnunetidentity.la \
58 libgnunetrevocation.la \
59 $(top_builddir)/src/util/libgnunetutil.la
53 60
54lib_LTLIBRARIES = libgnunetrevocation.la 61lib_LTLIBRARIES = libgnunetrevocation.la
55 62
@@ -92,7 +99,8 @@ test_revocation_LDADD = \
92 $(top_builddir)/src/testbed/libgnunettestbed.la 99 $(top_builddir)/src/testbed/libgnunettestbed.la
93 100
94check_PROGRAMS = \ 101check_PROGRAMS = \
95 test_revocation 102 test_revocation \
103 test_revocation_lsd0001testvectors
96 104
97check_SCRIPTS = \ 105check_SCRIPTS = \
98 test_local_revocation.py 106 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 @@
37static char*d_pkey = 37static char*d_pkey =
38 "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; 38 "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70";
39 39
40static char *d_edkey =
41 "5af7020ee19160328832352bbc6a68a8d71a7cbe1b929969a7c66d415a0d8f65";
42
40int 43int
41parsehex (char *src, char *dst, size_t dstlen, int invert) 44parsehex (char *src, char *dst, size_t dstlen, int invert)
42{ 45{
@@ -71,10 +74,14 @@ print_bytes_ (void *buf,
71 if (0 != i) 74 if (0 != i)
72 { 75 {
73 if ((0 != fold) && (i % fold == 0)) 76 if ((0 != fold) && (i % fold == 0))
74 printf ("\n"); 77 printf ("\n ");
75 else 78 else
76 printf (" "); 79 printf (" ");
77 } 80 }
81 else
82 {
83 printf (" ");
84 }
78 if (in_be) 85 if (in_be)
79 printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); 86 printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]);
80 else 87 else
@@ -93,21 +100,9 @@ print_bytes (void *buf,
93} 100}
94 101
95 102
96/**
97 * Main function that will be run.
98 *
99 * @param cls closure
100 * @param args remaining command-line arguments
101 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
102 * @param cfg configuration
103 */
104static void 103static void
105run (void *cls, 104run_with_key (struct GNUNET_IDENTITY_PrivateKey *id_priv)
106 char *const *args,
107 const char *cfgfile,
108 const struct GNUNET_CONFIGURATION_Handle *cfg)
109{ 105{
110 struct GNUNET_IDENTITY_PrivateKey id_priv;
111 struct GNUNET_IDENTITY_PublicKey id_pub; 106 struct GNUNET_IDENTITY_PublicKey id_pub;
112 struct GNUNET_REVOCATION_PowP *pow; 107 struct GNUNET_REVOCATION_PowP *pow;
113 struct GNUNET_REVOCATION_PowCalculationHandle *ph; 108 struct GNUNET_REVOCATION_PowCalculationHandle *ph;
@@ -115,18 +110,13 @@ run (void *cls,
115 char ztld[128]; 110 char ztld[128];
116 ssize_t key_len; 111 ssize_t key_len;
117 112
118 id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); 113 GNUNET_IDENTITY_key_get_public (id_priv,
119 GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
120 parsehex (d_pkey,(char*) &id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1);
121 GNUNET_IDENTITY_key_get_public (&id_priv,
122 &id_pub); 114 &id_pub);
123 GNUNET_STRINGS_data_to_string (&id_pub, 115 GNUNET_STRINGS_data_to_string (&id_pub,
124 GNUNET_IDENTITY_public_key_get_length ( 116 GNUNET_IDENTITY_public_key_get_length (
125 &id_pub), 117 &id_pub),
126 ztld, 118 ztld,
127 sizeof (ztld)); 119 sizeof (ztld));
128 fprintf (stdout, "Zone private key (d, big-endian scalar):\n");
129 print_bytes (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8);
130 fprintf (stdout, "\n"); 120 fprintf (stdout, "\n");
131 fprintf (stdout, "Zone identifier (ztype|zkey):\n"); 121 fprintf (stdout, "Zone identifier (ztype|zkey):\n");
132 key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub); 122 key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub);
@@ -137,7 +127,7 @@ run (void *cls,
137 fprintf (stdout, "%s\n", ztld); 127 fprintf (stdout, "%s\n", ztld);
138 fprintf (stdout, "\n"); 128 fprintf (stdout, "\n");
139 pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE); 129 pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE);
140 GNUNET_REVOCATION_pow_init (&id_priv, 130 GNUNET_REVOCATION_pow_init (id_priv,
141 pow); 131 pow);
142 ph = GNUNET_REVOCATION_pow_start (pow, 132 ph = GNUNET_REVOCATION_pow_start (pow,
143 TEST_EPOCHS, 133 TEST_EPOCHS,
@@ -170,6 +160,41 @@ run (void *cls,
170 GNUNET_REVOCATION_proof_get_size (pow), 160 GNUNET_REVOCATION_proof_get_size (pow),
171 8); 161 8);
172 GNUNET_free (ph); 162 GNUNET_free (ph);
163
164}
165
166
167/**
168 * Main function that will be run.
169 *
170 * @param cls closure
171 * @param args remaining command-line arguments
172 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
173 * @param cfg configuration
174 */
175static void
176run (void *cls,
177 char *const *args,
178 const char *cfgfile,
179 const struct GNUNET_CONFIGURATION_Handle *cfg)
180{
181 struct GNUNET_IDENTITY_PrivateKey id_priv;
182
183 id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
184 GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
185 parsehex (d_pkey,(char*) &id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1);
186
187 fprintf (stdout, "Zone private key (d, big-endian):\n");
188 print_bytes_ (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8, 1);
189 run_with_key (&id_priv);
190 printf ("\n");
191 id_priv.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA);
192 GNUNET_CRYPTO_eddsa_key_create (&id_priv.eddsa_key);
193 parsehex (d_edkey,(char*) &id_priv.eddsa_key, sizeof (id_priv.eddsa_key), 0);
194
195 fprintf (stdout, "Zone private key (d):\n");
196 print_bytes (&id_priv.eddsa_key, sizeof(id_priv.eddsa_key), 8);
197 run_with_key (&id_priv);
173} 198}
174 199
175 200