aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-revocation-tvg.c
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/revocation/gnunet-revocation-tvg.c
parentcd6ef3fb3d9579630cebb332838731b062d7f101 (diff)
downloadgnunet-34adfb777074bc23c950207d24ff078af29cddf6.tar.gz
gnunet-34adfb777074bc23c950207d24ff078af29cddf6.zip
GNS: Fix revocation TVs.
Diffstat (limited to 'src/revocation/gnunet-revocation-tvg.c')
-rw-r--r--src/revocation/gnunet-revocation-tvg.c67
1 files changed, 46 insertions, 21 deletions
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