diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-09-19 21:05:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-09-19 21:05:37 +0200 |
commit | 10eac9bb7230973e2c37be9181c36bd086ca38de (patch) | |
tree | 32344ca7ca145640947d03dddc963ba8b4457bfa /src/dhtu | |
parent | 83c0efff026598098addfabdf72698d5d13b7b48 (diff) | |
download | gnunet-10eac9bb7230973e2c37be9181c36bd086ca38de.tar.gz gnunet-10eac9bb7230973e2c37be9181c36bd086ca38de.zip |
-work on dhtu
Diffstat (limited to 'src/dhtu')
-rw-r--r-- | src/dhtu/Makefile.am | 11 | ||||
-rw-r--r-- | src/dhtu/plugin_dhtu_gnunet.c | 92 | ||||
-rw-r--r-- | src/dhtu/plugin_dhtu_ip.c | 4 |
3 files changed, 84 insertions, 23 deletions
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am index 72b422812..4bc96f236 100644 --- a/src/dhtu/Makefile.am +++ b/src/dhtu/Makefile.am | |||
@@ -11,6 +11,7 @@ if USE_COVERAGE | |||
11 | endif | 11 | endif |
12 | 12 | ||
13 | plugin_LTLIBRARIES = \ | 13 | plugin_LTLIBRARIES = \ |
14 | libgnunet_plugin_dhtu_gnunet.la \ | ||
14 | libgnunet_plugin_dhtu_ip.la | 15 | libgnunet_plugin_dhtu_ip.la |
15 | 16 | ||
16 | libgnunet_plugin_dhtu_ip_la_SOURCES = \ | 17 | libgnunet_plugin_dhtu_ip_la_SOURCES = \ |
@@ -22,3 +23,13 @@ libgnunet_plugin_dhtu_ip_la_LIBADD = \ | |||
22 | libgnunet_plugin_dhtu_ip_la_LDFLAGS = \ | 23 | libgnunet_plugin_dhtu_ip_la_LDFLAGS = \ |
23 | $(GN_PLUGIN_LDFLAGS) | 24 | $(GN_PLUGIN_LDFLAGS) |
24 | 25 | ||
26 | |||
27 | |||
28 | libgnunet_plugin_dhtu_gnunet_la_SOURCES = \ | ||
29 | plugin_dhtu_gnunet.c | ||
30 | libgnunet_plugin_dhtu_gnunet_la_LIBADD = \ | ||
31 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
32 | $(XLIBS) \ | ||
33 | $(LTLIBINTL) | ||
34 | libgnunet_plugin_dhtu_gnunet_la_LDFLAGS = \ | ||
35 | $(GN_PLUGIN_LDFLAGS) | ||
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 | */ | ||
33 | struct 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 | */ | ||
46 | struct 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 | */ |
48 | struct GNUNET_DHTU_Target | 80 | struct 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 | */ | ||
99 | struct 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 | */ |
108 | struct Plugin | 131 | struct 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 | |||
126 | static ssize_t | 149 | static ssize_t |
127 | ip_sign (void *cls, | 150 | ip_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, | |||
148 | static enum GNUNET_GenericReturnValue | 178 | static enum GNUNET_GenericReturnValue |
149 | ip_verify (void *cls, | 179 | ip_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 | |||
204 | ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) | 254 | ip_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 | */ |
231 | static void | 281 | static void |
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c index 8593a69ef..ae35adb37 100644 --- a/src/dhtu/plugin_dhtu_ip.c +++ b/src/dhtu/plugin_dhtu_ip.c | |||
@@ -240,7 +240,7 @@ struct Plugin | |||
240 | static ssize_t | 240 | static ssize_t |
241 | ip_sign (void *cls, | 241 | ip_sign (void *cls, |
242 | const struct GNUNET_DHTU_PrivateKey *pk, | 242 | const struct GNUNET_DHTU_PrivateKey *pk, |
243 | const struct GNUNET_DHTU_SignaturePurpose *purpose, | 243 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
244 | void **sig) | 244 | void **sig) |
245 | { | 245 | { |
246 | return 0; | 246 | return 0; |
@@ -262,7 +262,7 @@ ip_sign (void *cls, | |||
262 | static enum GNUNET_GenericReturnValue | 262 | static enum GNUNET_GenericReturnValue |
263 | ip_verify (void *cls, | 263 | ip_verify (void *cls, |
264 | const struct GNUNET_DHTU_PublicKey *pk, | 264 | const struct GNUNET_DHTU_PublicKey *pk, |
265 | const struct GNUNET_DHTU_SignaturePurpose *purpose, | 265 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
266 | const void *sig, | 266 | const void *sig, |
267 | size_t sig_size) | 267 | size_t sig_size) |
268 | { | 268 | { |