aboutsummaryrefslogtreecommitdiff
path: root/src/dhtu/plugin_dhtu_gnunet.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-09-19 21:05:00 +0200
committerChristian Grothoff <christian@grothoff.org>2021-09-19 21:05:37 +0200
commit10eac9bb7230973e2c37be9181c36bd086ca38de (patch)
tree32344ca7ca145640947d03dddc963ba8b4457bfa /src/dhtu/plugin_dhtu_gnunet.c
parent83c0efff026598098addfabdf72698d5d13b7b48 (diff)
downloadgnunet-10eac9bb7230973e2c37be9181c36bd086ca38de.tar.gz
gnunet-10eac9bb7230973e2c37be9181c36bd086ca38de.zip
-work on dhtu
Diffstat (limited to 'src/dhtu/plugin_dhtu_gnunet.c')
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c92
1 files changed, 71 insertions, 21 deletions
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index d6cd75242..9597ebdc0 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -21,11 +21,43 @@
21/** 21/**
22 * @author Christian Grothoff 22 * @author Christian Grothoff
23 * 23 *
24 * @file plugin_dhtu_ip.c 24 * @file plugin_dhtu_gnunet.c
25 * @brief plain IP based DHT network underlay 25 * @brief plain IP based DHT network underlay
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#incluce "gnunet_dhtu_plugin.h" 28#include "gnunet_dhtu_plugin.h"
29
30/**
31 * Handle for a private key used by this underlay.
32 */
33struct GNUNET_DHTU_PrivateKey
34{
35 /**
36 * GNUnet uses eddsa for peers.
37 */
38 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
39
40};
41
42
43/**
44 * Handle for a public key used by this underlay.
45 */
46struct PublicKey
47{
48
49 /**
50 * Header.
51 */
52 struct GNUNET_DHTU_PublicKey header;
53
54 /**
55 * GNUnet uses eddsa for peers.
56 */
57 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
58
59};
60
29 61
30/** 62/**
31 * Opaque handle that the underlay offers for our address to be used when 63 * Opaque handle that the underlay offers for our address to be used when
@@ -47,7 +79,7 @@ struct GNUNET_DHTU_Source
47 */ 79 */
48struct GNUNET_DHTU_Target 80struct GNUNET_DHTU_Target
49{ 81{
50 82
51 /** 83 /**
52 * Application context for this target. 84 * Application context for this target.
53 */ 85 */
@@ -94,20 +126,11 @@ struct GNUNET_DHTU_PreferenceHandle
94 126
95 127
96/** 128/**
97 * Opaque handle for a private key used by this underlay.
98 */
99struct GNUNET_DHTU_PrivateKey
100{
101 /* we are IP, we do not do crypto */
102};
103
104
105/**
106 * Closure for all plugin functions. 129 * Closure for all plugin functions.
107 */ 130 */
108struct Plugin 131struct Plugin
109{ 132{
110 /** 133 /**
111 * Callbacks into the DHT. 134 * Callbacks into the DHT.
112 */ 135 */
113 struct GNUNET_DHTU_PluginEnvironment *env; 136 struct GNUNET_DHTU_PluginEnvironment *env;
@@ -126,10 +149,17 @@ struct Plugin
126static ssize_t 149static ssize_t
127ip_sign (void *cls, 150ip_sign (void *cls,
128 const struct GNUNET_DHTU_PrivateKey *pk, 151 const struct GNUNET_DHTU_PrivateKey *pk,
129 const struct GNUNET_DHTU_SignaturePurpose *purpose, 152 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
130 void **sig) 153 void **sig)
131{ 154{
132 return 0; 155 struct GNUNET_CRYPTO_EddsaSignature *es;
156
157 es = GNUNET_new (struct GNUNET_CRYPTO_EddsaSignature);
158 GNUNET_CRYPTO_eddsa_sign_ (&pk->eddsa_priv,
159 purpose,
160 es);
161 *sig = es;
162 return sizeof (*es);
133} 163}
134 164
135 165
@@ -148,11 +178,31 @@ ip_sign (void *cls,
148static enum GNUNET_GenericReturnValue 178static enum GNUNET_GenericReturnValue
149ip_verify (void *cls, 179ip_verify (void *cls,
150 const struct GNUNET_DHTU_PublicKey *pk, 180 const struct GNUNET_DHTU_PublicKey *pk,
151 const struct GNUNET_DHTU_SignaturePurpose *purpose, 181 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
152 const void *sig, 182 const void *sig,
153 size_t sig_size) 183 size_t sig_size)
154{ 184{
155 return GNUNET_NO; 185 const struct GNUNET_CRYPTO_EddsaSignature *es = sig;
186 const struct PublicKey *pub;
187
188 GNUNET_assert (sizeof (struct PublicKey) ==
189 ntohs (pk->size));
190 pub = (const struct PublicKey *) pk;
191 if (sizeof (*es) != sig_size)
192 {
193 GNUNET_break_op (0);
194 return GNUNET_SYSERR;
195 }
196 if (GNUNET_OK !=
197 GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
198 purpose,
199 es,
200 &pub->eddsa_pub))
201 {
202 GNUNET_break_op (0);
203 return GNUNET_SYSERR;
204 }
205 return GNUNET_OK;
156} 206}
157 207
158 208
@@ -174,7 +224,7 @@ ip_try_connect (void *cls,
174 * Request underlay to keep the connection to @a target alive if possible. 224 * Request underlay to keep the connection to @a target alive if possible.
175 * Hold may be called multiple times to express a strong preference to 225 * Hold may be called multiple times to express a strong preference to
176 * keep a connection, say because a @a target is in multiple tables. 226 * keep a connection, say because a @a target is in multiple tables.
177 * 227 *
178 * @param cls closure 228 * @param cls closure
179 * @param target connection to keep alive 229 * @param target connection to keep alive
180 */ 230 */
@@ -196,7 +246,7 @@ ip_hold (void *cls,
196 246
197/** 247/**
198 * Do no long request underlay to keep the connection alive. 248 * Do no long request underlay to keep the connection alive.
199 * 249 *
200 * @param cls closure 250 * @param cls closure
201 * @param target connection to keep alive 251 * @param target connection to keep alive
202 */ 252 */
@@ -204,7 +254,7 @@ static void
204ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) 254ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
205{ 255{
206 struct GNUNET_DHTU_Target *target = ph->target; 256 struct GNUNET_DHTU_Target *target = ph->target;
207 257
208 GNUNET_CONTAINER_DLL_remove (target->ph_head, 258 GNUNET_CONTAINER_DLL_remove (target->ph_head,
209 target->ph_tail, 259 target->ph_tail,
210 ph); 260 ph);
@@ -225,7 +275,7 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
225 * @param msg_size number of bytes in @a msg 275 * @param msg_size number of bytes in @a msg
226 * @param finished_cb function called once transmission is done 276 * @param finished_cb function called once transmission is done
227 * (not called if @a target disconnects, then only the 277 * (not called if @a target disconnects, then only the
228 * disconnect_cb is called). 278 * disconnect_cb is called).
229 * @param finished_cb_cls closure for @a finished_cb 279 * @param finished_cb_cls closure for @a finished_cb
230 */ 280 */
231static void 281static void