aboutsummaryrefslogtreecommitdiff
path: root/src/dhtu
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-10 14:57:20 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-10 14:57:20 +0100
commitbfd4daf8ae1a3c6229ee3a8ca944adb2ef7e8677 (patch)
tree25aba3b09bbd0f1fdbc8f9295f49e2caffdb950c /src/dhtu
parent98edb2e5e83bafe96bb312262fcd9e992589b1d3 (diff)
downloadgnunet-bfd4daf8ae1a3c6229ee3a8ca944adb2ef7e8677.tar.gz
gnunet-bfd4daf8ae1a3c6229ee3a8ca944adb2ef7e8677.zip
-remove signing from DHTU API: no longer needed
Diffstat (limited to 'src/dhtu')
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c182
-rw-r--r--src/dhtu/plugin_dhtu_ip.c78
2 files changed, 44 insertions, 216 deletions
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index ee78858c8..2163af941 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -35,42 +35,6 @@
35 35
36 36
37/** 37/**
38 * Handle for a private key used by this underlay.
39 */
40struct GNUNET_DHTU_PrivateKey
41{
42 /**
43 * GNUnet uses eddsa for peers.
44 */
45 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
46
47};
48
49GNUNET_NETWORK_STRUCT_BEGIN
50
51/**
52 * Handle for a public key used by this underlay.
53 */
54struct PublicKey
55{
56
57 /**
58 * Header.
59 */
60 struct GNUNET_DHTU_PublicKey header;
61
62 /**
63 * GNUnet uses eddsa for peers.
64 */
65 struct GNUNET_PeerIdentity peer_pub;
66
67};
68
69
70GNUNET_NETWORK_STRUCT_END
71
72
73/**
74 * Handle for a HELLO we're offering the transport. 38 * Handle for a HELLO we're offering the transport.
75 */ 39 */
76struct HelloHandle 40struct HelloHandle
@@ -106,19 +70,14 @@ struct GNUNET_DHTU_Source
106{ 70{
107 71
108 /** 72 /**
109 * Application context for this source. 73 * Hash of @e pid, position of this peer in the DHT overlay.
110 */
111 void *app_ctx;
112
113 /**
114 * Hash position of this peer in the DHT.
115 */ 74 */
116 struct GNUNET_DHTU_Hash my_id; 75 struct GNUNET_DHTU_HashKey id;
117 76
118 /** 77 /**
119 * Private key of this peer. 78 * Application context for this source.
120 */ 79 */
121 struct GNUNET_DHTU_PrivateKey pk; 80 void *app_ctx;
122 81
123}; 82};
124 83
@@ -146,17 +105,6 @@ struct GNUNET_DHTU_Target
146 struct GNUNET_MQ_Handle *mq; 105 struct GNUNET_MQ_Handle *mq;
147 106
148 /** 107 /**
149 * Public key of the peer.
150 */
151 struct PublicKey pk;
152
153 /**
154 * Hash of the @a pk to identify position of the peer
155 * in the DHT.
156 */
157 struct GNUNET_DHTU_Hash peer_id;
158
159 /**
160 * Head of preferences expressed for this target. 108 * Head of preferences expressed for this target.
161 */ 109 */
162 struct GNUNET_DHTU_PreferenceHandle *ph_head; 110 struct GNUNET_DHTU_PreferenceHandle *ph_head;
@@ -172,6 +120,16 @@ struct GNUNET_DHTU_Target
172 struct GNUNET_ATS_ConnectivitySuggestHandle *csh; 120 struct GNUNET_ATS_ConnectivitySuggestHandle *csh;
173 121
174 /** 122 /**
123 * Identity of this peer.
124 */
125 struct GNUNET_PeerIdentity pid;
126
127 /**
128 * Hash of @e pid, position of this peer in the DHT overlay.
129 */
130 struct GNUNET_DHTU_HashKey id;
131
132 /**
175 * Preference counter, length of the @a ph_head DLL. 133 * Preference counter, length of the @a ph_head DLL.
176 */ 134 */
177 unsigned int ph_count; 135 unsigned int ph_count;
@@ -215,11 +173,6 @@ struct Plugin
215 struct GNUNET_DHTU_Source src; 173 struct GNUNET_DHTU_Source src;
216 174
217 /** 175 /**
218 * My identity.
219 */
220 struct GNUNET_PeerIdentity my_identity;
221
222 /**
223 * Callbacks into the DHT. 176 * Callbacks into the DHT.
224 */ 177 */
225 struct GNUNET_DHTU_PluginEnvironment *env; 178 struct GNUNET_DHTU_PluginEnvironment *env;
@@ -253,76 +206,13 @@ struct Plugin
253 * Hellos we are offering to transport. 206 * Hellos we are offering to transport.
254 */ 207 */
255 struct HelloHandle *hh_tail; 208 struct HelloHandle *hh_tail;
256};
257
258 209
259/** 210 /**
260 * Use our private key to sign a message. 211 * Identity of this peer.
261 * 212 */
262 * @param cls closure 213 struct GNUNET_PeerIdentity my_identity;
263 * @param pk our private key to sign with
264 * @param purpose what to sign
265 * @param[out] signature, allocated on heap and returned
266 * @return -1 on error, otherwise number of bytes in @a sig
267 */
268static ssize_t
269ip_sign (void *cls,
270 const struct GNUNET_DHTU_PrivateKey *pk,
271 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
272 void **sig)
273{
274 struct GNUNET_CRYPTO_EddsaSignature *es;
275
276 es = GNUNET_new (struct GNUNET_CRYPTO_EddsaSignature);
277 GNUNET_CRYPTO_eddsa_sign_ (&pk->eddsa_priv,
278 purpose,
279 es);
280 *sig = es;
281 return sizeof (*es);
282}
283
284
285/**
286 * Verify signature in @a sig over @a purpose.
287 *
288 * @param cls closure
289 * @param pk public key to verify signature of
290 * @param purpose what was being signed
291 * @param sig signature data
292 * @param sig_size number of bytes in @a sig
293 * @return #GNUNET_OK if signature is valid
294 * #GNUNET_NO if signatures are not supported
295 * #GNUNET_SYSERR if signature is invalid
296 */
297static enum GNUNET_GenericReturnValue
298ip_verify (void *cls,
299 const struct GNUNET_DHTU_PublicKey *pk,
300 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
301 const void *sig,
302 size_t sig_size)
303{
304 const struct GNUNET_CRYPTO_EddsaSignature *es = sig;
305 const struct PublicKey *pub;
306 214
307 GNUNET_assert (sizeof (struct PublicKey) == 215};
308 ntohs (pk->size));
309 pub = (const struct PublicKey *) pk;
310 if (sizeof (*es) != sig_size)
311 {
312 GNUNET_break_op (0);
313 return GNUNET_SYSERR;
314 }
315 if (GNUNET_OK !=
316 GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
317 purpose,
318 es,
319 &pub->peer_pub.public_key))
320 {
321 GNUNET_break_op (0);
322 return GNUNET_SYSERR;
323 }
324 return GNUNET_OK;
325}
326 216
327 217
328/** 218/**
@@ -409,7 +299,7 @@ ip_hold (void *cls,
409 GNUNET_ATS_connectivity_suggest_cancel (target->csh); 299 GNUNET_ATS_connectivity_suggest_cancel (target->csh);
410 target->csh 300 target->csh
411 = GNUNET_ATS_connectivity_suggest (plugin->ats, 301 = GNUNET_ATS_connectivity_suggest (plugin->ats,
412 &target->pk.peer_pub, 302 &target->pid,
413 target->ph_count); 303 target->ph_count);
414 return ph; 304 return ph;
415} 305}
@@ -439,7 +329,7 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
439 else 329 else
440 target->csh 330 target->csh
441 = GNUNET_ATS_connectivity_suggest (plugin->ats, 331 = GNUNET_ATS_connectivity_suggest (plugin->ats,
442 &target->pk.peer_pub, 332 &target->pid,
443 target->ph_count); 333 target->ph_count);
444} 334}
445 335
@@ -503,15 +393,13 @@ core_connect_cb (void *cls,
503 target = GNUNET_new (struct GNUNET_DHTU_Target); 393 target = GNUNET_new (struct GNUNET_DHTU_Target);
504 target->plugin = plugin; 394 target->plugin = plugin;
505 target->mq = mq; 395 target->mq = mq;
506 target->pk.header.size = htons (sizeof (struct PublicKey)); 396 target->pid = *peer;
507 target->pk.peer_pub = *peer;
508 GNUNET_CRYPTO_hash (peer, 397 GNUNET_CRYPTO_hash (peer,
509 sizeof (struct GNUNET_PeerIdentity), 398 sizeof (*peer),
510 &target->peer_id.hc); 399 &target->id.sha512);
511 plugin->env->connect_cb (plugin->env->cls, 400 plugin->env->connect_cb (plugin->env->cls,
512 &target->pk.header,
513 &target->peer_id,
514 target, 401 target,
402 &target->id,
515 &target->app_ctx); 403 &target->app_ctx);
516 return target; 404 return target;
517} 405}
@@ -573,12 +461,11 @@ peerinfo_cb (void *cls,
573 &GPI_plugins_find); 461 &GPI_plugins_find);
574 if (NULL == addr) 462 if (NULL == addr)
575 return; 463 return;
576 GNUNET_CRYPTO_hash (&plugin->my_identity, 464 GNUNET_CRYPTO_hash (peer,
577 sizeof (struct GNUNET_PeerIdentity), 465 sizeof (*peer),
578 &plugin->src.my_id.hc); 466 &plugin->src.id.sha512);
579 plugin->env->address_add_cb (plugin->env->cls, 467 plugin->env->address_add_cb (plugin->env->cls,
580 &plugin->src.my_id, 468 &plugin->src.id,
581 &plugin->src.pk,
582 addr, 469 addr,
583 &plugin->src, 470 &plugin->src,
584 &plugin->src.app_ctx); 471 &plugin->src.app_ctx);
@@ -729,22 +616,11 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
729 NULL), 616 NULL),
730 GNUNET_MQ_handler_end () 617 GNUNET_MQ_handler_end ()
731 }; 618 };
732 struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
733 619
734 pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (env->cfg);
735 if (NULL == pk)
736 {
737 GNUNET_break (0);
738 return NULL;
739 }
740 plugin = GNUNET_new (struct Plugin); 620 plugin = GNUNET_new (struct Plugin);
741 plugin->env = env; 621 plugin->env = env;
742 plugin->src.pk.eddsa_priv = *pk;
743 GNUNET_free (pk);
744 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); 622 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
745 api->cls = plugin; 623 api->cls = plugin;
746 api->sign = &ip_sign;
747 api->verify = &ip_verify;
748 api->try_connect = &ip_try_connect; 624 api->try_connect = &ip_try_connect;
749 api->hold = &ip_hold; 625 api->hold = &ip_hold;
750 api->drop = &ip_drop; 626 api->drop = &ip_drop;
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index ae35adb37..8eec6294b 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -56,6 +56,11 @@ struct GNUNET_DHTU_Source
56 struct GNUNET_DHTU_Source *prev; 56 struct GNUNET_DHTU_Source *prev;
57 57
58 /** 58 /**
59 * Position of this peer in the DHT.
60 */
61 struct GNUNET_DHTU_HashKey id;
62
63 /**
59 * Application context for this source. 64 * Application context for this source.
60 */ 65 */
61 void *app_ctx; 66 void *app_ctx;
@@ -66,11 +71,6 @@ struct GNUNET_DHTU_Source
66 char *address; 71 char *address;
67 72
68 /** 73 /**
69 * Hash of the IP address.
70 */
71 struct GNUNET_DHTU_Hash id;
72
73 /**
74 * My actual address. 74 * My actual address.
75 */ 75 */
76 struct sockaddr_storage addr; 76 struct sockaddr_storage addr;
@@ -111,11 +111,6 @@ struct GNUNET_DHTU_Target
111 void *app_ctx; 111 void *app_ctx;
112 112
113 /** 113 /**
114 * Hash of the IP address.
115 */
116 struct GNUNET_DHTU_Hash id;
117
118 /**
119 * Head of preferences expressed for this target. 114 * Head of preferences expressed for this target.
120 */ 115 */
121 struct GNUNET_DHTU_PreferenceHandle *ph_head; 116 struct GNUNET_DHTU_PreferenceHandle *ph_head;
@@ -126,6 +121,11 @@ struct GNUNET_DHTU_Target
126 struct GNUNET_DHTU_PreferenceHandle *ph_tail; 121 struct GNUNET_DHTU_PreferenceHandle *ph_tail;
127 122
128 /** 123 /**
124 * Position of this peer in the DHT.
125 */
126 struct GNUNET_DHTU_HashKey id;
127
128 /**
129 * Target IP address. 129 * Target IP address.
130 */ 130 */
131 struct sockaddr_storage addr; 131 struct sockaddr_storage addr;
@@ -229,48 +229,6 @@ struct Plugin
229 229
230 230
231/** 231/**
232 * Use our private key to sign a message.
233 *
234 * @param cls closure
235 * @param pk our private key to sign with
236 * @param purpose what to sign
237 * @param[out] signature, allocated on heap and returned
238 * @return -1 on error, otherwise number of bytes in @a sig
239 */
240static ssize_t
241ip_sign (void *cls,
242 const struct GNUNET_DHTU_PrivateKey *pk,
243 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
244 void **sig)
245{
246 return 0;
247}
248
249
250/**
251 * Verify signature in @a sig over @a purpose.
252 *
253 * @param cls closure
254 * @param pk public key to verify signature of
255 * @param purpose what was being signed
256 * @param sig signature data
257 * @param sig_size number of bytes in @a sig
258 * @return #GNUNET_OK if signature is valid
259 * #GNUNET_NO if signatures are not supported
260 * #GNUNET_SYSERR if signature is invalid
261 */
262static enum GNUNET_GenericReturnValue
263ip_verify (void *cls,
264 const struct GNUNET_DHTU_PublicKey *pk,
265 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
266 const void *sig,
267 size_t sig_size)
268{
269 return GNUNET_NO;
270}
271
272
273/**
274 * Create a target to which we may send traffic. 232 * Create a target to which we may send traffic.
275 * 233 *
276 * @param plugin our plugin 234 * @param plugin our plugin
@@ -283,7 +241,6 @@ create_target (struct Plugin *plugin,
283 const struct sockaddr *addr, 241 const struct sockaddr *addr,
284 socklen_t addrlen) 242 socklen_t addrlen)
285{ 243{
286 static struct GNUNET_DHTU_PublicKey pk;
287 struct GNUNET_DHTU_Target *dst; 244 struct GNUNET_DHTU_Target *dst;
288 245
289 if (MAX_DESTS > 246 if (MAX_DESTS >
@@ -316,7 +273,6 @@ create_target (struct Plugin *plugin,
316 GNUNET_assert (NULL == dst->ph_head); 273 GNUNET_assert (NULL == dst->ph_head);
317 GNUNET_free (dst); 274 GNUNET_free (dst);
318 } 275 }
319 pk.size = htons (sizeof (pk));
320 dst = GNUNET_new (struct GNUNET_DHTU_Target); 276 dst = GNUNET_new (struct GNUNET_DHTU_Target);
321 dst->addrlen = addrlen; 277 dst->addrlen = addrlen;
322 memcpy (&dst->addr, 278 memcpy (&dst->addr,
@@ -331,7 +287,7 @@ create_target (struct Plugin *plugin,
331 GNUNET_assert (sizeof (struct sockaddr_in) == addrlen); 287 GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
332 GNUNET_CRYPTO_hash (&s4->sin_addr, 288 GNUNET_CRYPTO_hash (&s4->sin_addr,
333 sizeof (struct in_addr), 289 sizeof (struct in_addr),
334 &dst->id.hc); 290 &dst->id.sha512);
335 } 291 }
336 break; 292 break;
337 case AF_INET6: 293 case AF_INET6:
@@ -341,7 +297,7 @@ create_target (struct Plugin *plugin,
341 GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen); 297 GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
342 GNUNET_CRYPTO_hash (&s6->sin6_addr, 298 GNUNET_CRYPTO_hash (&s6->sin6_addr,
343 sizeof (struct in6_addr), 299 sizeof (struct in6_addr),
344 &dst->id.hc); 300 &dst->id.sha512);
345 } 301 }
346 break; 302 break;
347 default: 303 default:
@@ -353,9 +309,8 @@ create_target (struct Plugin *plugin,
353 plugin->dst_tail, 309 plugin->dst_tail,
354 dst); 310 dst);
355 plugin->env->connect_cb (plugin->env->cls, 311 plugin->env->connect_cb (plugin->env->cls,
356 &pk,
357 &dst->id,
358 dst, 312 dst,
313 &dst->id,
359 &dst->app_ctx); 314 &dst->app_ctx);
360 return dst; 315 return dst;
361} 316}
@@ -585,7 +540,7 @@ create_source (struct Plugin *plugin,
585 GNUNET_assert (sizeof (struct sockaddr_in) == addrlen); 540 GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
586 GNUNET_CRYPTO_hash (&s4->sin_addr, 541 GNUNET_CRYPTO_hash (&s4->sin_addr,
587 sizeof (struct in_addr), 542 sizeof (struct in_addr),
588 &src->id.hc); 543 &src->id.sha512);
589 GNUNET_asprintf (&src->address, 544 GNUNET_asprintf (&src->address,
590 "ip+udp://%s:%u", 545 "ip+udp://%s:%u",
591 inet_ntop (AF_INET, 546 inet_ntop (AF_INET,
@@ -603,7 +558,7 @@ create_source (struct Plugin *plugin,
603 GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen); 558 GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
604 GNUNET_CRYPTO_hash (&s6->sin6_addr, 559 GNUNET_CRYPTO_hash (&s6->sin6_addr,
605 sizeof (struct in6_addr), 560 sizeof (struct in6_addr),
606 &src->id.hc); 561 &src->id.sha512);
607 GNUNET_asprintf (&src->address, 562 GNUNET_asprintf (&src->address,
608 "ip+udp://[%s]:%u", 563 "ip+udp://[%s]:%u",
609 inet_ntop (AF_INET6, 564 inet_ntop (AF_INET6,
@@ -623,7 +578,6 @@ create_source (struct Plugin *plugin,
623 src); 578 src);
624 plugin->env->address_add_cb (plugin->env->cls, 579 plugin->env->address_add_cb (plugin->env->cls,
625 &src->id, 580 &src->id,
626 NULL, /* no key */
627 src->address, 581 src->address,
628 src, 582 src,
629 &src->app_ctx); 583 &src->app_ctx);
@@ -1023,8 +977,6 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
1023 plugin); 977 plugin);
1024 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); 978 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
1025 api->cls = plugin; 979 api->cls = plugin;
1026 api->sign = &ip_sign;
1027 api->verify = &ip_verify;
1028 api->try_connect = &ip_try_connect; 980 api->try_connect = &ip_try_connect;
1029 api->hold = &ip_hold; 981 api->hold = &ip_hold;
1030 api->drop = &ip_drop; 982 api->drop = &ip_drop;