aboutsummaryrefslogtreecommitdiff
path: root/src/abd
diff options
context:
space:
mode:
Diffstat (limited to 'src/abd')
-rw-r--r--src/abd/.gitignore2
-rw-r--r--src/abd/Makefile.am100
-rw-r--r--src/abd/abd.conf.in5
-rw-r--r--src/abd/abd.h290
-rw-r--r--src/abd/abd_api.c564
-rw-r--r--src/abd/abd_serialization.c516
-rw-r--r--src/abd/abd_serialization.h167
-rw-r--r--src/abd/delegate_misc.c270
-rw-r--r--src/abd/delegate_misc.h36
-rw-r--r--src/abd/gnunet-abd.c1100
-rw-r--r--src/abd/gnunet-service-abd.c1775
-rw-r--r--src/abd/plugin_gnsrecord_abd.c353
-rwxr-xr-xsrc/abd/test_abd_bi_and.sh98
-rwxr-xr-xsrc/abd/test_abd_bi_and2.sh94
-rwxr-xr-xsrc/abd/test_abd_bi_and3.sh96
-rwxr-xr-xsrc/abd/test_abd_bi_and4.sh83
-rwxr-xr-xsrc/abd/test_abd_bi_bw.sh87
-rwxr-xr-xsrc/abd/test_abd_bi_bw_link.sh92
-rwxr-xr-xsrc/abd/test_abd_bi_bw_link2.sh93
-rwxr-xr-xsrc/abd/test_abd_bi_fw.sh92
-rw-r--r--src/abd/test_abd_defaults.conf24
-rwxr-xr-xsrc/abd/test_abd_issue.sh46
-rw-r--r--src/abd/test_abd_lookup.conf28
-rwxr-xr-xsrc/abd/test_abd_own.sh139
-rwxr-xr-xsrc/abd/test_abd_verify.sh87
-rwxr-xr-xsrc/abd/test_abd_verify_and.sh86
-rwxr-xr-xsrc/abd/test_abd_verify_simple.sh56
27 files changed, 0 insertions, 6379 deletions
diff --git a/src/abd/.gitignore b/src/abd/.gitignore
deleted file mode 100644
index ee1eb7837..000000000
--- a/src/abd/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
1gnunet-abd
2gnunet-service-abd
diff --git a/src/abd/Makefile.am b/src/abd/Makefile.am
deleted file mode 100644
index 34a0438f5..000000000
--- a/src/abd/Makefile.am
+++ /dev/null
@@ -1,100 +0,0 @@
1# This Makefile.am is in the public domain
2AM_CPPFLAGS = -I$(top_srcdir)/src/include
3
4EXTRA_DIST = \
5 test_abd_defaults.conf \
6 test_abd_lookup.conf
7
8
9if USE_COVERAGE
10 AM_CFLAGS = --coverage -O0
11endif
12
13pkgcfgdir = $(pkgdatadir)/config.d/
14
15libexecdir= $(pkglibdir)/libexec/
16
17plugindir = $(libdir)/gnunet
18
19pkgcfg_DATA = \
20 abd.conf
21
22
23# /usr/lib - compiles a layer which can be used to be communicagte with the service
24lib_LTLIBRARIES = \
25 libgnunetabd.la
26
27# /usr/lib/gnunet/libexec - Business logic . Separate process
28libexec_PROGRAMS = \
29 gnunet-service-abd
30
31bin_PROGRAMS = \
32 gnunet-abd
33
34plugin_LTLIBRARIES = \
35 libgnunet_plugin_gnsrecord_abd.la
36
37
38gnunet_abd_SOURCES = \
39 gnunet-abd.c
40gnunet_abd_LDADD = \
41 libgnunetabd.la \
42 $(top_builddir)/src/util/libgnunetutil.la \
43 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
44 $(top_builddir)/src/identity/libgnunetidentity.la \
45 $(top_builddir)/src/namestore/libgnunetnamestore.la \
46 $(GN_LIBINTL)
47
48
49libgnunet_plugin_gnsrecord_abd_la_SOURCES = \
50 plugin_gnsrecord_abd.c
51libgnunet_plugin_gnsrecord_abd_la_LIBADD = \
52 libgnunetabd.la \
53 $(top_builddir)/src/util/libgnunetutil.la \
54 $(LTLIBINTL)
55libgnunet_plugin_gnsrecord_abd_la_LDFLAGS = \
56 $(GN_PLUGIN_LDFLAGS)
57
58
59
60gnunet_service_abd_SOURCES = \
61 gnunet-service-abd.c
62gnunet_service_abd_LDADD = \
63 libgnunetabd.la \
64 $(top_builddir)/src/util/libgnunetutil.la \
65 $(top_builddir)/src/gns/libgnunetgns.la \
66 $(top_builddir)/src/namestore/libgnunetnamestore.la \
67 $(top_builddir)/src/statistics/libgnunetstatistics.la \
68 $(GN_LIBINTL)
69
70
71libgnunetabd_la_SOURCES = \
72 abd_api.c abd.h\
73 abd_serialization.c \
74 abd_serialization.h \
75 delegate_misc.c \
76 delegate_misc.h
77libgnunetabd_la_LIBADD = \
78 $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
79libgnunetabd_la_LDFLAGS = \
80 $(GN_LIB_LDFLAGS)
81
82
83
84check_SCRIPTS = \
85 test_abd_issue.sh \
86 test_abd_verify_simple.sh \
87 test_abd_verify.sh \
88 test_abd_verify_and.sh
89
90if ENABLE_TEST_RUN
91if HAVE_SQLITE
92 AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
93 TESTS = $(check_SCRIPTS)
94endif
95endif
96
97
98
99
100
diff --git a/src/abd/abd.conf.in b/src/abd/abd.conf.in
deleted file mode 100644
index 7baf95fc8..000000000
--- a/src/abd/abd.conf.in
+++ /dev/null
@@ -1,5 +0,0 @@
1[abd]
2BINARY = gnunet-service-abd
3UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-abd.sock
4RUN_PER_USER = YES
5OPTIONS = -L DEBUG
diff --git a/src/abd/abd.h b/src/abd/abd.h
deleted file mode 100644
index 0af0d43ca..000000000
--- a/src/abd/abd.h
+++ /dev/null
@@ -1,290 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012-2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file abd/abd.h
22 * @brief IPC messages between ABD API and ABD service
23 * @author Martin Schanzenbach
24 */
25#ifndef ABD_H
26#define ABD_H
27
28#include "gnunet_abd_service.h"
29
30GNUNET_NETWORK_STRUCT_BEGIN
31
32/**
33 * Message from client to Credential service to collect credentials.
34 */
35struct CollectMessage
36{
37 /**
38 * Header of type #GNUNET_MESSAGE_TYPE_ABD_VERIFY
39 */
40 struct GNUNET_MessageHeader header;
41
42 /**
43 * Subject public key
44 */
45 struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key;
46
47 /**
48 * Trust anchor
49 */
50 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
51
52 /**
53 * Length of the issuer attribute
54 */
55 uint16_t issuer_attribute_len;
56
57 /**
58 * Direction of the resolution algo
59 */
60 uint16_t resolution_algo;
61
62 /**
63 * Unique identifier for this request (for key collisions).
64 */
65 uint32_t id GNUNET_PACKED;
66
67 /* Followed by the zero-terminated attribute */
68};
69
70
71/**
72 * Message from client to Credential service to verify attributes.
73 */
74struct VerifyMessage
75{
76 /**
77 * Header of type #GNUNET_MESSAGE_TYPE_ABD_VERIFY
78 */
79 struct GNUNET_MessageHeader header;
80
81 /**
82 * Subject public key
83 */
84 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
85
86 /**
87 * Trust anchor
88 */
89 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
90
91 /**
92 * Number of delegates
93 */
94 uint32_t d_count;
95
96 /**
97 * Length of the issuer attribute
98 */
99 uint16_t issuer_attribute_len;
100
101 /**
102 * Direction of the resolution algo
103 */
104 uint16_t resolution_algo;
105
106 /**
107 * Unique identifier for this request (for key collisions).
108 */
109 uint32_t id GNUNET_PACKED;
110
111 /* Followed by the zero-terminated attribute and credentials to look up */
112};
113
114
115/**
116 * Message from ABD service to client: new results.
117 */
118struct DelegationChainResultMessage
119{
120 /**
121 * Header of type #GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT
122 */
123 struct GNUNET_MessageHeader header;
124
125 /**
126 * Unique identifier for this request (for key collisions).
127 */
128 uint32_t id GNUNET_PACKED;
129
130 /**
131 * Indicates if credential has been found at all
132 */
133 uint32_t del_found GNUNET_PACKED;
134
135 /**
136 * The number of delegations in the response
137 */
138 uint32_t d_count GNUNET_PACKED;
139
140 /**
141 * The number of credentials in the response
142 */
143 uint32_t c_count GNUNET_PACKED;
144
145 /* followed by ad_count GNUNET_ABD_RecordData structs*/
146};
147
148/**
149 * Message from ABD service to client: new results.
150 */
151struct DelegationChainIntermediateMessage
152{
153 /**
154 * Header of type #GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT
155 */
156 struct GNUNET_MessageHeader header;
157
158 /**
159 * Unique identifier for this request (for key collisions).
160 */
161 uint32_t id GNUNET_PACKED;
162
163 uint16_t is_bw GNUNET_PACKED;
164
165 uint32_t size GNUNET_PACKED;
166};
167
168struct DelegationRecordData
169{
170 /**
171 * Subject key
172 */
173 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
174
175 /**
176 * Subject attributes
177 */
178 uint32_t subject_attribute_len GNUNET_PACKED;
179};
180
181
182struct ChainEntry
183{
184 /**
185 * Issuer key
186 */
187 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
188
189 /**
190 * Subject key
191 */
192 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
193
194 /**
195 * Issuer attributes
196 */
197 uint32_t issuer_attribute_len GNUNET_PACKED;
198
199 /**
200 * Subject attributes
201 */
202 uint32_t subject_attribute_len GNUNET_PACKED;
203};
204
205
206struct CredentialEntry
207{
208
209 /**
210 * The signature for this credential by the issuer
211 */
212 struct GNUNET_CRYPTO_EcdsaSignature signature;
213
214 /**
215 * Signature meta
216 */
217 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
218
219 /**
220 * Public key of the issuer
221 */
222 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
223
224 /**
225 * Public key of the subject this credential was issued to
226 */
227 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
228
229 /**
230 * Expiration time of this credential
231 */
232 uint64_t expiration GNUNET_PACKED;
233
234 /**
235 * Issuer attribute length
236 */
237 uint32_t issuer_attribute_len;
238
239 /**
240 * Followed by the attribute string
241 */
242};
243
244struct DelegateEntry
245{
246
247 /**
248 * Signature meta
249 */
250 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
251
252 /**
253 * The signature for this credential by the issuer
254 */
255 struct GNUNET_CRYPTO_EcdsaSignature signature;
256
257 /**
258 * Public key of the issuer
259 */
260 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
261
262 /**
263 * Public key of the subject this credential was issued to
264 */
265 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
266
267 /**
268 * Expiration time of this credential
269 */
270 uint64_t expiration GNUNET_PACKED;
271
272 /**
273 * Issuer subject attribute length
274 */
275 uint32_t issuer_attribute_len;
276
277 /**
278 * Issuer attribute length
279 */
280 uint32_t subject_attribute_len;
281
282 /**
283 * Followed by the subject attribute string
284 */
285};
286
287
288GNUNET_NETWORK_STRUCT_END
289
290#endif
diff --git a/src/abd/abd_api.c b/src/abd/abd_api.c
deleted file mode 100644
index cc25d06da..000000000
--- a/src/abd/abd_api.c
+++ /dev/null
@@ -1,564 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20/**
21 * @file abd/abd_api.c
22 * @brief library to access the ABD service
23 * @author Martin Schanzenbach
24 */
25#include "platform.h"
26#include "gnunet_util_lib.h"
27#include "gnunet_constants.h"
28#include "gnunet_arm_service.h"
29#include "gnunet_hello_lib.h"
30#include "gnunet_protocols.h"
31#include "gnunet_signatures.h"
32#include "abd.h"
33#include "abd_serialization.h"
34#include "gnunet_abd_service.h"
35#include "gnunet_identity_service.h"
36
37
38#define LOG(kind, ...) GNUNET_log_from (kind, "abd-api", __VA_ARGS__)
39
40/**
41 * Handle to a verify request
42 */
43struct GNUNET_ABD_Request
44{
45
46 /**
47 * DLL
48 */
49 struct GNUNET_ABD_Request *next;
50
51 /**
52 * DLL
53 */
54 struct GNUNET_ABD_Request *prev;
55
56 /**
57 * handle to abd service
58 */
59 struct GNUNET_ABD_Handle *abd_handle;
60
61 /**
62 * processor to call on verify result
63 */
64 GNUNET_ABD_CredentialResultProcessor verify_proc;
65
66 /**
67 * @e verify_proc closure
68 */
69 void *proc_cls;
70
71 /**
72 * processor to call on intermediate result
73 */
74 GNUNET_ABD_IntermediateResultProcessor int_proc;
75
76 /**
77 * @e verify_proc2 closure
78 */
79 void *proc2_cls;
80
81 /**
82 * Envelope with the message for this queue entry.
83 */
84 struct GNUNET_MQ_Envelope *env;
85
86 /**
87 * request id
88 */
89 uint32_t r_id;
90};
91
92
93/**
94 * Connection to the ABD service.
95 */
96struct GNUNET_ABD_Handle
97{
98
99 /**
100 * Configuration to use.
101 */
102 const struct GNUNET_CONFIGURATION_Handle *cfg;
103
104 /**
105 * Connection to service (if available).
106 */
107 struct GNUNET_MQ_Handle *mq;
108
109 /**
110 * Head of linked list of active verify requests.
111 */
112 struct GNUNET_ABD_Request *request_head;
113
114 /**
115 * Tail of linked list of active verify requests.
116 */
117 struct GNUNET_ABD_Request *request_tail;
118
119 /**
120 * Reconnect task
121 */
122 struct GNUNET_SCHEDULER_Task *reconnect_task;
123
124 /**
125 * How long do we wait until we try to reconnect?
126 */
127 struct GNUNET_TIME_Relative reconnect_backoff;
128
129 /**
130 * Request Id generator. Incremented by one for each request.
131 */
132 uint32_t r_id_gen;
133};
134
135
136/**
137 * Reconnect to ABD service.
138 *
139 * @param handle the handle to the ABD service
140 */
141static void
142reconnect (struct GNUNET_ABD_Handle *handle);
143
144
145/**
146 * Reconnect to ABD
147 *
148 * @param cls the handle
149 */
150static void
151reconnect_task (void *cls)
152{
153 struct GNUNET_ABD_Handle *handle = cls;
154
155 handle->reconnect_task = NULL;
156 reconnect (handle);
157}
158
159
160/**
161 * Disconnect from service and then reconnect.
162 *
163 * @param handle our handle
164 */
165static void
166force_reconnect (struct GNUNET_ABD_Handle *handle)
167{
168 GNUNET_MQ_destroy (handle->mq);
169 handle->mq = NULL;
170 handle->reconnect_backoff =
171 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
172 handle->reconnect_task =
173 GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
174 &reconnect_task,
175 handle);
176}
177
178
179/**
180 * Generic error handler, called with the appropriate error code and
181 * the same closure specified at the creation of the message queue.
182 * Not every message queue implementation supports an error handler.
183 *
184 * @param cls closure with the `struct GNUNET_ABD_Handle *`
185 * @param error error code
186 */
187static void
188mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
189{
190 struct GNUNET_ABD_Handle *handle = cls;
191
192 force_reconnect (handle);
193}
194
195
196/**
197 * Check validity of message received from the ABD service
198 *
199 * @param cls the `struct GNUNET_ABD_Handle *`
200 * @param vr_msg the incoming message
201 */
202static int
203check_result (void *cls, const struct DelegationChainResultMessage *vr_msg)
204{
205 // TODO
206 return GNUNET_OK;
207}
208
209
210/**
211 * Handler for messages received from the ABD service
212 *
213 * @param cls the `struct GNUNET_ABD_Handle *`
214 * @param vr_msg the incoming message
215 */
216static void
217handle_result (void *cls, const struct DelegationChainResultMessage *vr_msg)
218{
219 struct GNUNET_ABD_Handle *handle = cls;
220 uint32_t r_id = ntohl (vr_msg->id);
221 struct GNUNET_ABD_Request *vr;
222 size_t mlen = ntohs (vr_msg->header.size) - sizeof (*vr_msg);
223 uint32_t d_count = ntohl (vr_msg->d_count);
224 uint32_t c_count = ntohl (vr_msg->c_count);
225 struct GNUNET_ABD_Delegation d_chain[d_count];
226 struct GNUNET_ABD_Delegate dels[c_count];
227 GNUNET_ABD_CredentialResultProcessor proc;
228 void *proc_cls;
229
230 LOG (GNUNET_ERROR_TYPE_DEBUG,
231 "Received verify reply from ABD service\n");
232 for (vr = handle->request_head; NULL != vr; vr = vr->next)
233 if (vr->r_id == r_id)
234 break;
235 if (NULL == vr)
236 return;
237 proc = vr->verify_proc;
238 proc_cls = vr->proc_cls;
239 GNUNET_CONTAINER_DLL_remove (handle->request_head, handle->request_tail, vr);
240 GNUNET_MQ_discard (vr->env);
241 GNUNET_free (vr);
242 GNUNET_assert (
243 GNUNET_OK ==
244 GNUNET_ABD_delegation_chain_deserialize (mlen,
245 (const char *) &vr_msg[1],
246 d_count,
247 d_chain,
248 c_count,
249 dels));
250 if (GNUNET_NO == ntohl (vr_msg->del_found))
251 {
252 proc (proc_cls, 0, NULL, 0,
253 NULL);
254 }
255 else
256 {
257 proc (proc_cls, d_count, d_chain, c_count, dels);
258 }
259}
260
261
262static int
263check_intermediate (void *cls, const struct
264 DelegationChainIntermediateMessage *vr_msg)
265{
266 // TODO
267 return GNUNET_OK;
268}
269
270
271static void
272handle_intermediate (void *cls, const struct
273 DelegationChainIntermediateMessage *vr_msg)
274{
275 struct GNUNET_ABD_Handle *handle = cls;
276 uint32_t r_id = ntohl (vr_msg->id);
277 uint32_t size = ntohl (vr_msg->size);
278 bool is_bw = ntohs (vr_msg->is_bw);
279 struct GNUNET_ABD_Request *vr;
280 GNUNET_ABD_IntermediateResultProcessor proc;
281 void *proc_cls;
282 struct GNUNET_ABD_Delegation *dd;
283
284
285 LOG (GNUNET_ERROR_TYPE_DEBUG,
286 "Received intermediate reply from ABD service\n");
287
288 for (vr = handle->request_head; NULL != vr; vr = vr->next)
289 if (vr->r_id == r_id)
290 break;
291 if (NULL == vr)
292 return;
293
294 proc = vr->int_proc;
295 proc_cls = vr->proc2_cls;
296
297 dd = GNUNET_new (struct GNUNET_ABD_Delegation);
298 GNUNET_assert (
299 GNUNET_OK ==
300 GNUNET_ABD_delegation_chain_deserialize (size,
301 (const char *) &vr_msg[1],
302 1,
303 dd,
304 0,
305 NULL));
306 proc (proc_cls, dd, is_bw);
307}
308
309
310/**
311 * Reconnect to ABD service.
312 *
313 * @param handle the handle to the ABD service
314 */
315static void
316reconnect (struct GNUNET_ABD_Handle *handle)
317{
318 struct GNUNET_MQ_MessageHandler handlers[] =
319 {GNUNET_MQ_hd_var_size (result,
320 GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT,
321 struct DelegationChainResultMessage,
322 handle),
323 GNUNET_MQ_hd_var_size (result,
324 GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT,
325 struct DelegationChainResultMessage,
326 handle),
327 GNUNET_MQ_hd_var_size (intermediate,
328 GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT,
329 struct DelegationChainIntermediateMessage,
330 handle),
331 GNUNET_MQ_handler_end ()};
332 struct GNUNET_ABD_Request *vr;
333
334 GNUNET_assert (NULL == handle->mq);
335 LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to ABD\n");
336 handle->mq = GNUNET_CLIENT_connect (handle->cfg,
337 "abd",
338 handlers,
339 &mq_error_handler,
340 handle);
341 if (NULL == handle->mq)
342 return;
343 for (vr = handle->request_head; NULL != vr; vr = vr->next)
344 GNUNET_MQ_send_copy (handle->mq, vr->env);
345}
346
347
348/**
349 * Initialize the connection with the ABD service.
350 *
351 * @param cfg configuration to use
352 * @return handle to the ABD service, or NULL on error
353 */
354struct GNUNET_ABD_Handle *
355GNUNET_ABD_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
356{
357 struct GNUNET_ABD_Handle *handle;
358
359 handle = GNUNET_new (struct GNUNET_ABD_Handle);
360 handle->cfg = cfg;
361 reconnect (handle);
362 if (NULL == handle->mq)
363 {
364 GNUNET_free (handle);
365 return NULL;
366 }
367 return handle;
368}
369
370
371/**
372 * Shutdown connection with the ABD service.
373 *
374 * @param handle handle of the ABD connection to stop
375 */
376void
377GNUNET_ABD_disconnect (struct GNUNET_ABD_Handle *handle)
378{
379 if (NULL != handle->mq)
380 {
381 GNUNET_MQ_destroy (handle->mq);
382 handle->mq = NULL;
383 }
384 if (NULL != handle->reconnect_task)
385 {
386 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
387 handle->reconnect_task = NULL;
388 }
389 GNUNET_assert (NULL == handle->request_head);
390 GNUNET_free (handle);
391}
392
393
394/**
395 * Cancel pending verify request
396 *
397 * @param lr the verify request to cancel
398 */
399void
400GNUNET_ABD_request_cancel (struct GNUNET_ABD_Request *lr)
401{
402 struct GNUNET_ABD_Handle *handle = lr->abd_handle;
403
404 GNUNET_CONTAINER_DLL_remove (handle->request_head, handle->request_tail, lr);
405 GNUNET_MQ_discard (lr->env);
406 GNUNET_free (lr);
407}
408
409
410/**
411 * Performs attribute collection.
412 * Collects all abds of subject to fulfill the
413 * attribute, if possible
414 *
415 * @param handle handle to the Credential service
416 * @param issuer_key the issuer public key
417 * @param issuer_attribute the issuer attribute
418 * @param subject_key the subject public key
419 * @param proc function to call on result
420 * @param proc_cls closure for processor
421 * @return handle to the queued request
422 */
423struct GNUNET_ABD_Request *
424GNUNET_ABD_collect (
425 struct GNUNET_ABD_Handle *handle,
426 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
427 const char *issuer_attribute,
428 const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key,
429 enum GNUNET_ABD_AlgoDirectionFlags direction,
430 GNUNET_ABD_CredentialResultProcessor proc,
431 void *proc_cls,
432 GNUNET_ABD_IntermediateResultProcessor proc2,
433 void *proc2_cls)
434{
435 /* IPC to shorten abd names, return shorten_handle */
436 struct CollectMessage *c_msg;
437 struct GNUNET_ABD_Request *vr;
438 size_t nlen;
439
440 if (NULL == issuer_attribute)
441 {
442 GNUNET_break (0);
443 return NULL;
444 }
445
446 // DEBUG LOG
447 LOG (GNUNET_ERROR_TYPE_DEBUG,
448 "Trying to collect `%s' in ABD\n",
449 issuer_attribute);
450 nlen = strlen (issuer_attribute) + 1;
451 if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*vr))
452 {
453 GNUNET_break (0);
454 return NULL;
455 }
456 vr = GNUNET_new (struct GNUNET_ABD_Request);
457 vr->abd_handle = handle;
458 vr->verify_proc = proc;
459 vr->proc_cls = proc_cls;
460 vr->int_proc = proc2;
461 vr->proc2_cls = proc2_cls;
462 vr->r_id = handle->r_id_gen++;
463 vr->env =
464 GNUNET_MQ_msg_extra (c_msg, nlen, GNUNET_MESSAGE_TYPE_ABD_COLLECT);
465 c_msg->id = htonl (vr->r_id);
466 c_msg->subject_key = *subject_key;
467 c_msg->issuer_key = *issuer_key;
468 c_msg->issuer_attribute_len = htons (strlen (issuer_attribute));
469 c_msg->resolution_algo = htons (direction);
470
471 GNUNET_memcpy (&c_msg[1], issuer_attribute, strlen (issuer_attribute));
472 GNUNET_CONTAINER_DLL_insert (handle->request_head, handle->request_tail, vr);
473 if (NULL != handle->mq)
474 GNUNET_MQ_send_copy (handle->mq, vr->env);
475 return vr;
476}
477
478
479/**
480 * Performs attribute verification.
481 * Checks if there is a delegation chain from
482 * attribute ``issuer_attribute'' issued by the issuer
483 * with public key ``issuer_key'' maps to the attribute
484 * ``subject_attribute'' claimed by the subject with key
485 * ``subject_key''
486 *
487 * @param handle handle to the Credential service
488 * @param issuer_key the issuer public key
489 * @param issuer_attribute the issuer attribute
490 * @param subject_key the subject public key
491 * @param delegate_count number of delegates provided
492 * @param delegates subject delegates
493 * @param proc function to call on result
494 * @param proc_cls closure for processor
495 * @return handle to the queued request
496 */
497struct GNUNET_ABD_Request *
498GNUNET_ABD_verify (
499 struct GNUNET_ABD_Handle *handle,
500 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
501 const char *issuer_attribute,
502 const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
503 uint32_t delegate_count,
504 const struct GNUNET_ABD_Delegate *delegates,
505 enum GNUNET_ABD_AlgoDirectionFlags direction,
506 GNUNET_ABD_CredentialResultProcessor proc,
507 void *proc_cls,
508 GNUNET_ABD_IntermediateResultProcessor proc2,
509 void *proc2_cls)
510{
511 /* IPC to shorten abd names, return shorten_handle */
512 struct VerifyMessage *v_msg;
513 struct GNUNET_ABD_Request *vr;
514 size_t nlen;
515 size_t clen;
516
517 if ((NULL == issuer_attribute) || (NULL == delegates))
518 {
519 GNUNET_break (0);
520 return NULL;
521 }
522
523 clen = GNUNET_ABD_delegates_get_size (delegate_count, delegates);
524
525 // DEBUG LOG
526 LOG (GNUNET_ERROR_TYPE_DEBUG,
527 "Trying to verify `%s' in ABD\n",
528 issuer_attribute);
529 nlen = strlen (issuer_attribute) + 1 + clen;
530 if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*vr))
531 {
532 GNUNET_break (0);
533 return NULL;
534 }
535 vr = GNUNET_new (struct GNUNET_ABD_Request);
536 vr->abd_handle = handle;
537 vr->verify_proc = proc;
538 vr->proc_cls = proc_cls;
539 vr->int_proc = proc2;
540 vr->proc2_cls = proc2_cls;
541 vr->r_id = handle->r_id_gen++;
542 vr->env =
543 GNUNET_MQ_msg_extra (v_msg, nlen, GNUNET_MESSAGE_TYPE_ABD_VERIFY);
544 v_msg->id = htonl (vr->r_id);
545 v_msg->subject_key = *subject_key;
546 v_msg->d_count = htonl (delegate_count);
547 v_msg->issuer_key = *issuer_key;
548 v_msg->issuer_attribute_len = htons (strlen (issuer_attribute));
549 v_msg->resolution_algo = htons (direction);
550
551 GNUNET_memcpy (&v_msg[1], issuer_attribute, strlen (issuer_attribute));
552 GNUNET_ABD_delegates_serialize (delegate_count,
553 delegates,
554 clen,
555 ((char *) &v_msg[1])
556 + strlen (issuer_attribute) + 1);
557 GNUNET_CONTAINER_DLL_insert (handle->request_head, handle->request_tail, vr);
558 if (NULL != handle->mq)
559 GNUNET_MQ_send_copy (handle->mq, vr->env);
560 return vr;
561}
562
563
564/* end of abd_api.c */
diff --git a/src/abd/abd_serialization.c b/src/abd/abd_serialization.c
deleted file mode 100644
index c03fab7dc..000000000
--- a/src/abd/abd_serialization.c
+++ /dev/null
@@ -1,516 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20
21
22/**
23 * @file abd/abd_serialization.c
24 * @brief API to serialize and deserialize delegation chains
25 * and abds
26 * @author Martin Schanzenbach
27 */
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_constants.h"
31#include "gnunet_abd_service.h"
32#include "gnunet_signatures.h"
33#include "abd.h"
34
35/**
36 * Calculate how many bytes we will need to serialize
37 * the given delegation chain
38 *
39 * @param ds_count number of delegation chain entries
40 * @param dsr array of #GNUNET_ABD_DelegationSet
41 * @return the required size to serialize
42 */
43size_t
44GNUNET_ABD_delegation_set_get_size (
45 unsigned int ds_count,
46 const struct GNUNET_ABD_DelegationSet *dsr)
47{
48 unsigned int i;
49 size_t ret;
50
51 ret = sizeof (struct DelegationRecordData) * (ds_count);
52
53 for (i = 0; i < ds_count; i++)
54 {
55 GNUNET_assert ((ret + dsr[i].subject_attribute_len) >= ret);
56 ret += dsr[i].subject_attribute_len;
57 }
58 return ret;
59}
60
61
62/**
63 * Serizalize the given delegation chain entries and abd
64 *
65 * @param d_count number of delegation chain entries
66 * @param dsr array of #GNUNET_ABD_DelegationSet
67 * @param dest_size size of the destination
68 * @param dest where to store the result
69 * @return the size of the data, -1 on failure
70 */
71ssize_t
72GNUNET_ABD_delegation_set_serialize (
73 unsigned int d_count,
74 const struct GNUNET_ABD_DelegationSet *dsr,
75 size_t dest_size,
76 char *dest)
77{
78 struct DelegationRecordData rec;
79 unsigned int i;
80 size_t off;
81
82 off = 0;
83 for (i = 0; i < d_count; i++)
84 {
85 rec.subject_attribute_len = htonl ((uint32_t) dsr[i].subject_attribute_len);
86 rec.subject_key = dsr[i].subject_key;
87 if (off + sizeof (rec) > dest_size)
88 return -1;
89 GNUNET_memcpy (&dest[off], &rec, sizeof (rec));
90 off += sizeof (rec);
91 if (0 == dsr[i].subject_attribute_len)
92 continue;
93 if (off + dsr[i].subject_attribute_len > dest_size)
94 return -1;
95 GNUNET_memcpy (&dest[off],
96 dsr[i].subject_attribute,
97 dsr[i].subject_attribute_len);
98 off += dsr[i].subject_attribute_len;
99 }
100 return off;
101}
102
103
104/**
105 * Deserialize the given destination
106 *
107 * @param len size of the serialized delegation chain and cred
108 * @param src the serialized data
109 * @param d_count the number of delegation chain entries
110 * @param dsr where to put the delegation chain entries
111 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
112 */
113int
114GNUNET_ABD_delegation_set_deserialize (
115 size_t len,
116 const char *src,
117 unsigned int d_count,
118 struct GNUNET_ABD_DelegationSet *dsr)
119{
120 struct DelegationRecordData rec;
121 unsigned int i;
122 size_t off;
123
124 off = 0;
125 for (i = 0; i < d_count; i++)
126 {
127 if (off + sizeof (rec) > len)
128 return GNUNET_SYSERR;
129 GNUNET_memcpy (&rec, &src[off], sizeof (rec));
130 dsr[i].subject_key = rec.subject_key;
131 off += sizeof (rec);
132 dsr[i].subject_attribute_len = ntohl ((uint32_t) rec.subject_attribute_len);
133 if (off + dsr[i].subject_attribute_len > len)
134 return GNUNET_SYSERR;
135 dsr[i].subject_attribute = (char *) &src[off];
136 off += dsr[i].subject_attribute_len;
137 }
138 return GNUNET_OK;
139}
140
141
142/**
143 * Calculate how many bytes we will need to serialize
144 * the abds
145 *
146 * @param c_count number of abd entries
147 * @param cd a #GNUNET_ABD_Credential
148 * @return the required size to serialize
149 */
150size_t
151GNUNET_ABD_delegates_get_size (
152 unsigned int c_count,
153 const struct GNUNET_ABD_Delegate *cd)
154{
155 unsigned int i;
156 size_t ret;
157
158 ret = sizeof (struct DelegateEntry) * (c_count);
159
160 for (i = 0; i < c_count; i++)
161 {
162 GNUNET_assert ((ret + cd[i].issuer_attribute_len
163 + cd[i].subject_attribute_len) >= ret);
164 // subject_attribute_len should be 0
165 ret += cd[i].issuer_attribute_len + cd[i].subject_attribute_len;
166 }
167 return ret;
168}
169
170
171/**
172 * Serizalize the given abds
173 *
174 * @param c_count number of abd entries
175 * @param cd a #GNUNET_ABD_Credential
176 * @param dest_size size of the destination
177 * @param dest where to store the result
178 * @return the size of the data, -1 on failure
179 */
180ssize_t
181GNUNET_ABD_delegates_serialize (
182 unsigned int c_count,
183 const struct GNUNET_ABD_Delegate *cd,
184 size_t dest_size,
185 char *dest)
186{
187 struct DelegateEntry c_rec;
188 unsigned int i;
189 size_t off;
190
191 off = 0;
192 for (i = 0; i < c_count; i++)
193 {
194 // c_rec.subject_attribute_len = htonl ((uint32_t) cd[i].subject_attribute_len);
195 c_rec.issuer_attribute_len = htonl ((uint32_t) cd[i].issuer_attribute_len);
196 c_rec.issuer_key = cd[i].issuer_key;
197 c_rec.subject_key = cd[i].subject_key;
198 c_rec.signature = cd[i].signature;
199 c_rec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
200 c_rec.purpose.size =
201 htonl ((sizeof (struct DelegateEntry) + cd[i].issuer_attribute_len)
202 - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
203 c_rec.expiration = GNUNET_htonll (cd[i].expiration.abs_value_us);
204 if (off + sizeof (c_rec) > dest_size)
205 return -1;
206 GNUNET_memcpy (&dest[off], &c_rec, sizeof (c_rec));
207 off += sizeof (c_rec);
208 if (off + cd[i].issuer_attribute_len > dest_size)
209 return -1;
210 GNUNET_memcpy (&dest[off],
211 cd[i].issuer_attribute,
212 cd[i].issuer_attribute_len);
213 off += cd[i].issuer_attribute_len;
214 }
215
216 return off;
217}
218
219
220/**
221 * Deserialize the given destination
222 *
223 * @param len size of the serialized creds
224 * @param src the serialized data
225 * @param c_count the number of abd entries
226 * @param cd where to put the abd data
227 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
228 */
229int
230GNUNET_ABD_delegates_deserialize (size_t len,
231 const char *src,
232 unsigned int c_count,
233 struct GNUNET_ABD_Delegate *cd)
234{
235 struct DelegateEntry c_rec;
236 unsigned int i;
237 size_t off;
238
239 off = 0;
240 for (i = 0; i < c_count; i++)
241 {
242 if (off + sizeof (c_rec) > len)
243 return GNUNET_SYSERR;
244 GNUNET_memcpy (&c_rec, &src[off], sizeof (c_rec));
245 cd[i].issuer_attribute_len = ntohl ((uint32_t) c_rec.issuer_attribute_len);
246 cd[i].issuer_key = c_rec.issuer_key;
247 cd[i].subject_key = c_rec.subject_key;
248 cd[i].signature = c_rec.signature;
249 cd[i].expiration.abs_value_us = GNUNET_ntohll (c_rec.expiration);
250 off += sizeof (c_rec);
251 if (off + cd[i].issuer_attribute_len > len)
252 return GNUNET_SYSERR;
253 cd[i].issuer_attribute = &src[off];
254 off += cd[i].issuer_attribute_len;
255 cd[i].subject_attribute_len = 0;
256 }
257 return GNUNET_OK;
258}
259
260
261/**
262 * Calculate how many bytes we will need to serialize
263 * the given delegation chain and abd
264 *
265 * @param d_count number of delegation chain entries
266 * @param dd array of #GNUNET_ABD_Delegation
267 * @param c_count number of abd entries
268 * @param cd a #GNUNET_ABD_Credential
269 * @return the required size to serialize
270 */
271size_t
272GNUNET_ABD_delegation_chain_get_size (
273 unsigned int d_count,
274 const struct GNUNET_ABD_Delegation *dd,
275 unsigned int c_count,
276 const struct GNUNET_ABD_Delegate *cd)
277{
278 unsigned int i;
279 size_t ret;
280
281 ret = sizeof (struct ChainEntry) * (d_count);
282
283 for (i = 0; i < d_count; i++)
284 {
285 GNUNET_assert (
286 (ret + dd[i].issuer_attribute_len + dd[i].subject_attribute_len) >= ret);
287 ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len;
288 }
289 return ret + GNUNET_ABD_delegates_get_size (c_count, cd);
290}
291
292
293/**
294 * Serizalize the given delegation chain entries and abd
295 *
296 * @param d_count number of delegation chain entries
297 * @param dd array of #GNUNET_ABD_Delegation
298 * @param c_count number of abd entries
299 * @param cd a #GNUNET_ABD_Credential
300 * @param dest_size size of the destination
301 * @param dest where to store the result
302 * @return the size of the data, -1 on failure
303 */
304ssize_t
305GNUNET_ABD_delegation_chain_serialize (
306 unsigned int d_count,
307 const struct GNUNET_ABD_Delegation *dd,
308 unsigned int c_count,
309 const struct GNUNET_ABD_Delegate *cd,
310 size_t dest_size,
311 char *dest)
312{
313 struct ChainEntry rec;
314 unsigned int i;
315 size_t off;
316
317 off = 0;
318 for (i = 0; i < d_count; i++)
319 {
320 rec.issuer_attribute_len = htonl ((uint32_t) dd[i].issuer_attribute_len);
321 rec.subject_attribute_len = htonl ((uint32_t) dd[i].subject_attribute_len);
322 rec.issuer_key = dd[i].issuer_key;
323 rec.subject_key = dd[i].subject_key;
324 if (off + sizeof (rec) > dest_size)
325 return -1;
326 GNUNET_memcpy (&dest[off], &rec, sizeof (rec));
327 off += sizeof (rec);
328 if (off + dd[i].issuer_attribute_len > dest_size)
329 return -1;
330 GNUNET_memcpy (&dest[off],
331 dd[i].issuer_attribute,
332 dd[i].issuer_attribute_len);
333 off += dd[i].issuer_attribute_len;
334 if (0 == dd[i].subject_attribute_len)
335 continue;
336 if (off + dd[i].subject_attribute_len > dest_size)
337 return -1;
338 GNUNET_memcpy (&dest[off],
339 dd[i].subject_attribute,
340 dd[i].subject_attribute_len);
341 off += dd[i].subject_attribute_len;
342 }
343 return off + GNUNET_ABD_delegates_serialize (c_count,
344 cd,
345 dest_size - off,
346 &dest[off]);
347}
348
349
350/**
351 * Deserialize the given destination
352 *
353 * @param len size of the serialized delegation chain and cred
354 * @param src the serialized data
355 * @param d_count the number of delegation chain entries
356 * @param dd where to put the delegation chain entries
357 * @param c_count the number of abd entries
358 * @param cd where to put the abd data
359 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
360 */
361int
362GNUNET_ABD_delegation_chain_deserialize (
363 size_t len,
364 const char *src,
365 unsigned int d_count,
366 struct GNUNET_ABD_Delegation *dd,
367 unsigned int c_count,
368 struct GNUNET_ABD_Delegate *cd)
369{
370 struct ChainEntry rec;
371 unsigned int i;
372 size_t off;
373
374 off = 0;
375 for (i = 0; i < d_count; i++)
376 {
377 if (off + sizeof (rec) > len)
378 return GNUNET_SYSERR;
379 GNUNET_memcpy (&rec, &src[off], sizeof (rec));
380 dd[i].issuer_attribute_len = ntohl ((uint32_t) rec.issuer_attribute_len);
381 dd[i].issuer_key = rec.issuer_key;
382 dd[i].subject_key = rec.subject_key;
383 off += sizeof (rec);
384 if (off + dd[i].issuer_attribute_len > len)
385 return GNUNET_SYSERR;
386 dd[i].issuer_attribute = &src[off];
387 off += dd[i].issuer_attribute_len;
388 dd[i].subject_attribute_len = ntohl ((uint32_t) rec.subject_attribute_len);
389 if (off + dd[i].subject_attribute_len > len)
390 return GNUNET_SYSERR;
391 dd[i].subject_attribute = &src[off];
392 off += dd[i].subject_attribute_len;
393 }
394 return GNUNET_ABD_delegates_deserialize (len - off,
395 &src[off],
396 c_count,
397 cd);
398}
399
400
401int
402GNUNET_ABD_delegate_serialize (struct GNUNET_ABD_Delegate *dele,
403 char **data)
404{
405 size_t size;
406 struct DelegateEntry *cdata;
407 int attr_len;
408
409 // +1 for \0
410 if (0 == dele->subject_attribute_len)
411 {
412 attr_len = dele->issuer_attribute_len + 1;
413 }
414 else
415 {
416 attr_len = dele->issuer_attribute_len + dele->subject_attribute_len + 2;
417 }
418 size = sizeof (struct DelegateEntry) + attr_len;
419
420 char tmp_str[attr_len];
421 GNUNET_memcpy (tmp_str, dele->issuer_attribute, dele->issuer_attribute_len);
422 if (0 != dele->subject_attribute_len)
423 {
424 tmp_str[dele->issuer_attribute_len] = '\0';
425 GNUNET_memcpy (tmp_str + dele->issuer_attribute_len + 1,
426 dele->subject_attribute,
427 dele->subject_attribute_len);
428 }
429 tmp_str[attr_len - 1] = '\0';
430
431 *data = GNUNET_malloc (size);
432 cdata = (struct DelegateEntry *) *data;
433 cdata->subject_key = dele->subject_key;
434 cdata->issuer_key = dele->issuer_key;
435 cdata->expiration = GNUNET_htonll (dele->expiration.abs_value_us);
436 cdata->signature = dele->signature;
437 cdata->issuer_attribute_len = htonl (dele->issuer_attribute_len + 1);
438 if (0 == dele->subject_attribute_len)
439 {
440 cdata->subject_attribute_len = htonl (0);
441 }
442 else
443 {
444 cdata->subject_attribute_len = htonl (dele->subject_attribute_len + 1);
445 }
446 cdata->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
447 cdata->purpose.size =
448 htonl (size - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
449
450 GNUNET_memcpy (&cdata[1], tmp_str, attr_len);
451
452 if (GNUNET_OK !=
453 GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_DELEGATE,
454 cdata,
455 &cdata->signature,
456 &cdata->issuer_key))
457 {
458 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Serialize: Invalid delegate\n");
459 return 0;
460 }
461 return size;
462}
463
464
465struct GNUNET_ABD_Delegate *
466GNUNET_ABD_delegate_deserialize (const char *data, size_t data_size)
467{
468 struct GNUNET_ABD_Delegate *dele;
469 struct DelegateEntry *cdata;
470 char *attr_combo_str;
471
472 if (data_size < sizeof (struct DelegateEntry))
473 return NULL;
474 cdata = (struct DelegateEntry *) data;
475 if (GNUNET_OK !=
476 GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_DELEGATE,
477 cdata,
478 &cdata->signature,
479 &cdata->issuer_key))
480 {
481 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Deserialize: Invalid delegate\n");
482 return NULL;
483 }
484 attr_combo_str = (char *) &cdata[1];
485 int iss_len = ntohl (cdata->issuer_attribute_len);
486 int sub_len = ntohl (cdata->subject_attribute_len);
487 int attr_combo_len = iss_len + sub_len;
488
489 dele =
490 GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) + attr_combo_len);
491
492 dele->issuer_key = cdata->issuer_key;
493 dele->subject_key = cdata->subject_key;
494 GNUNET_memcpy (&dele[1], attr_combo_str, attr_combo_len);
495 dele->signature = cdata->signature;
496
497 // Set the pointers for the attributes
498 dele->issuer_attribute = (char *) &dele[1];
499 dele->issuer_attribute_len = iss_len;
500 dele->subject_attribute_len = sub_len;
501 if (0 == sub_len)
502 {
503 dele->subject_attribute = NULL;
504 }
505 else
506 {
507 dele->subject_attribute = (char *) &dele[1] + iss_len;
508 }
509
510 dele->expiration.abs_value_us = GNUNET_ntohll (cdata->expiration);
511
512 return dele;
513}
514
515
516/* end of abd_serialization.c */
diff --git a/src/abd/abd_serialization.h b/src/abd/abd_serialization.h
deleted file mode 100644
index 21dc45a7b..000000000
--- a/src/abd/abd_serialization.h
+++ /dev/null
@@ -1,167 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20
21
22/**
23 * @file abd/abd_serialization.h
24 * @brief API to serialize and deserialize delegation chains
25 * and abds
26 * @author Martin Schanzenbach
27 */
28#ifndef ABD_SERIALIZATION_H
29#define ABD_SERIALIZATION_H
30
31#include "platform.h"
32#include "gnunet_util_lib.h"
33#include "gnunet_constants.h"
34#include "gnunet_abd_service.h"
35
36/**
37 * Calculate how many bytes we will need to serialize
38 * the given delegation record
39 *
40 * @param ds_count number of delegation chain entries
41 * @param dsr array of #GNUNET_ABD_Delegation
42 * @return the required size to serialize
43 */
44size_t
45GNUNET_ABD_delegation_set_get_size (
46 unsigned int ds_count,
47 const struct GNUNET_ABD_DelegationSet *dsr);
48
49/**
50 * Serizalize the given delegation record entries
51 *
52 * @param d_count number of delegation chain entries
53 * @param dsr array of #GNUNET_ABD_Delegation
54 * @param dest_size size of the destination
55 * @param dest where to store the result
56 * @return the size of the data, -1 on failure
57 */
58ssize_t
59GNUNET_ABD_delegation_set_serialize (
60 unsigned int d_count,
61 const struct GNUNET_ABD_DelegationSet *dsr,
62 size_t dest_size,
63 char *dest);
64
65
66/**
67 * Deserialize the given destination
68 *
69 * @param len size of the serialized delegation recird
70 * @param src the serialized data
71 * @param d_count the number of delegation chain entries
72 * @param dsr where to put the delegation chain entries
73 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
74 */
75int
76GNUNET_ABD_delegation_set_deserialize (
77 size_t len,
78 const char *src,
79 unsigned int d_count,
80 struct GNUNET_ABD_DelegationSet *dsr);
81
82/**
83 * Calculate how many bytes we will need to serialize
84 * the given delegation chain and abd
85 *
86 * @param d_count number of delegation chain entries
87 * @param dd array of #GNUNET_ABD_Delegation
88 * @param c_count number of abd entries
89 * @param cd a #GNUNET_ABD_Delegate
90 * @return the required size to serialize
91 */
92size_t
93GNUNET_ABD_delegation_chain_get_size (
94 unsigned int d_count,
95 const struct GNUNET_ABD_Delegation *dd,
96 unsigned int c_count,
97 const struct GNUNET_ABD_Delegate *cd);
98
99/**
100 * Serizalize the given delegation chain entries and abd
101 *
102 * @param d_count number of delegation chain entries
103 * @param dd array of #GNUNET_ABD_Delegation
104 * @param c_count number of abd entries
105 * @param cd a #GNUNET_ABD_Delegate
106 * @param dest_size size of the destination
107 * @param dest where to store the result
108 * @return the size of the data, -1 on failure
109 */
110ssize_t
111GNUNET_ABD_delegation_chain_serialize (
112 unsigned int d_count,
113 const struct GNUNET_ABD_Delegation *dd,
114 unsigned int c_count,
115 const struct GNUNET_ABD_Delegate *cd,
116 size_t dest_size,
117 char *dest);
118
119
120/**
121 * Deserialize the given destination
122 *
123 * @param len size of the serialized delegation chain and cred
124 * @param src the serialized data
125 * @param d_count the number of delegation chain entries
126 * @param dd where to put the delegation chain entries
127 * @param c_count number of abd entries
128 * @param cd where to put the abd data
129 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
130 */
131int
132GNUNET_ABD_delegation_chain_deserialize (
133 size_t len,
134 const char *src,
135 unsigned int d_count,
136 struct GNUNET_ABD_Delegation *dd,
137 unsigned int c_count,
138 struct GNUNET_ABD_Delegate *cd);
139
140size_t
141GNUNET_ABD_delegates_get_size (
142 unsigned int c_count,
143 const struct GNUNET_ABD_Delegate *cd);
144
145ssize_t
146GNUNET_ABD_delegates_serialize (
147 unsigned int c_count,
148 const struct GNUNET_ABD_Delegate *cd,
149 size_t dest_size,
150 char *dest);
151
152
153int
154GNUNET_ABD_delegates_deserialize (size_t len,
155 const char *src,
156 unsigned int c_count,
157 struct GNUNET_ABD_Delegate *cd);
158
159int
160GNUNET_ABD_delegate_serialize (struct GNUNET_ABD_Delegate *cred,
161 char **data);
162
163struct GNUNET_ABD_Delegate *
164GNUNET_ABD_delegate_deserialize (const char *data, size_t data_size);
165
166#endif
167/* end of abd_serialization.h */
diff --git a/src/abd/delegate_misc.c b/src/abd/delegate_misc.c
deleted file mode 100644
index 4740a3e30..000000000
--- a/src/abd/delegate_misc.c
+++ /dev/null
@@ -1,270 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20
21
22/**
23 * @file abd/delegate_misc.c
24 * @brief Misc API for delegate
25 *
26 * @author Martin Schanzenbach
27 */
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_constants.h"
31#include "gnunet_abd_service.h"
32#include "gnunet_signatures.h"
33#include "abd.h"
34#include <inttypes.h>
35
36char *
37GNUNET_ABD_delegate_to_string (
38 const struct GNUNET_ABD_Delegate *cred)
39{
40 char *cred_str;
41 char *subject_pkey;
42 char *issuer_pkey;
43 char *signature;
44
45 subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key);
46 issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->issuer_key);
47 GNUNET_STRINGS_base64_encode ((char *) &cred->signature,
48 sizeof (struct GNUNET_CRYPTO_EcdsaSignature),
49 &signature);
50 if (0 == cred->subject_attribute_len)
51 {
52 GNUNET_asprintf (&cred_str,
53 "%s.%s -> %s | %s | %" SCNu64,
54 issuer_pkey,
55 cred->issuer_attribute,
56 subject_pkey,
57 signature,
58 cred->expiration.abs_value_us);
59 }
60 else
61 {
62 GNUNET_asprintf (&cred_str,
63 "%s.%s -> %s.%s | %s | %" SCNu64,
64 issuer_pkey,
65 cred->issuer_attribute,
66 subject_pkey,
67 cred->subject_attribute,
68 signature,
69 cred->expiration.abs_value_us);
70 }
71 GNUNET_free (subject_pkey);
72 GNUNET_free (issuer_pkey);
73 GNUNET_free (signature);
74
75 return cred_str;
76}
77
78
79struct GNUNET_ABD_Delegate *
80GNUNET_ABD_delegate_from_string (const char *s)
81{
82 struct GNUNET_ABD_Delegate *dele;
83 size_t enclen = (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)) * 8;
84 if (enclen % 5 > 0)
85 enclen += 5 - enclen % 5;
86 enclen /= 5; /* 260/5 = 52 */
87 char subject_pkey[enclen + 1];
88 char issuer_pkey[enclen + 1];
89 char iss_attr[253 + 1];
90 // Needs to be initialized, in case of Type 1 credential (A.a <- B)
91 char sub_attr[253 + 1] = "";
92 char signature[256]; // TODO max payload size
93
94 struct GNUNET_CRYPTO_EcdsaSignature *sig;
95 struct GNUNET_TIME_Absolute etime_abs;
96
97 // If it's A.a <- B.b...
98 if (6 != sscanf (s,
99 "%52s.%253s -> %52s.%253s | %s | %" SCNu64,
100 issuer_pkey,
101 iss_attr,
102 subject_pkey,
103 sub_attr,
104 signature,
105 &etime_abs.abs_value_us))
106 {
107 // Try if it's A.a <- B
108 if (5 != sscanf (s,
109 "%52s.%253s -> %52s | %s | %" SCNu64,
110 issuer_pkey,
111 iss_attr,
112 subject_pkey,
113 signature,
114 &etime_abs.abs_value_us))
115 {
116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
117 "Unable to parse DEL record string `%s'\n",
118 s);
119 return NULL;
120 }
121 }
122
123 // +1 for \0
124 int attr_len;
125 if (strcmp (sub_attr, "") == 0)
126 {
127 attr_len = strlen (iss_attr) + 1;
128 }
129 else
130 {
131 attr_len = strlen (iss_attr) + strlen (sub_attr) + 2;
132 }
133 dele = GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) + attr_len);
134
135 char tmp_str[attr_len];
136 GNUNET_memcpy (tmp_str, iss_attr, strlen (iss_attr));
137 if (strcmp (sub_attr, "") != 0)
138 {
139 tmp_str[strlen (iss_attr)] = '\0';
140 GNUNET_memcpy (tmp_str + strlen (iss_attr) + 1,
141 sub_attr,
142 strlen (sub_attr));
143 }
144 tmp_str[attr_len - 1] = '\0';
145
146 GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pkey,
147 strlen (subject_pkey),
148 &dele->subject_key);
149 GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey,
150 strlen (issuer_pkey),
151 &dele->issuer_key);
152 GNUNET_assert (sizeof (struct GNUNET_CRYPTO_EcdsaSignature) ==
153 GNUNET_STRINGS_base64_decode (signature,
154 strlen (signature),
155 (void **) &sig));
156 dele->signature = *sig;
157 dele->expiration = etime_abs;
158 GNUNET_free (sig);
159
160 GNUNET_memcpy (&dele[1], tmp_str, attr_len);
161
162 dele->issuer_attribute = (char *) &dele[1];
163 dele->issuer_attribute_len = strlen (iss_attr);
164 if (strcmp (sub_attr, "") == 0)
165 {
166 dele->subject_attribute = NULL;
167 dele->subject_attribute_len = 0;
168 }
169 else
170 {
171 dele->subject_attribute = (char *) &dele[1] + strlen (iss_attr) + 1;
172 dele->subject_attribute_len = strlen (sub_attr);
173 }
174
175 return dele;
176}
177
178
179/**
180 * Issue an attribute to a subject
181 *
182 * @param issuer the ego that should be used to issue the attribute
183 * @param subject the subject of the attribute
184 * @param iss_attr the name of the attribute
185 * @return handle to the queued request
186 */
187
188struct GNUNET_ABD_Delegate *
189GNUNET_ABD_delegate_issue (
190 const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
191 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
192 const char *iss_attr,
193 const char *sub_attr,
194 struct GNUNET_TIME_Absolute *expiration)
195{
196 struct DelegateEntry *del;
197 struct GNUNET_ABD_Delegate *dele;
198 size_t size;
199 int attr_len;
200
201 if (NULL == sub_attr)
202 {
203 // +1 for \0
204 attr_len = strlen (iss_attr) + 1;
205 }
206 else
207 {
208 // +2 for both strings need to be terminated with \0
209 attr_len = strlen (iss_attr) + strlen (sub_attr) + 2;
210 }
211 size = sizeof (struct DelegateEntry) + attr_len;
212
213 char tmp_str[attr_len];
214 GNUNET_memcpy (tmp_str, iss_attr, strlen (iss_attr));
215 if (NULL != sub_attr)
216 {
217 tmp_str[strlen (iss_attr)] = '\0';
218 GNUNET_memcpy (tmp_str + strlen (iss_attr) + 1,
219 sub_attr,
220 strlen (sub_attr));
221 }
222 tmp_str[attr_len - 1] = '\0';
223
224 del = GNUNET_malloc (size);
225 del->purpose.size =
226 htonl (size - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
227 del->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
228 GNUNET_CRYPTO_ecdsa_key_get_public (issuer, &del->issuer_key);
229 del->subject_key = *subject;
230 del->expiration = GNUNET_htonll (expiration->abs_value_us);
231 del->issuer_attribute_len = htonl (strlen (iss_attr) + 1);
232 if (NULL == sub_attr)
233 {
234 del->subject_attribute_len = htonl (0);
235 }
236 else
237 {
238 del->subject_attribute_len = htonl (strlen (sub_attr) + 1);
239 }
240
241 GNUNET_memcpy (&del[1], tmp_str, attr_len);
242
243 GNUNET_CRYPTO_ecdsa_sign (issuer, del, &del->signature);
244
245 dele = GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) + attr_len);
246 dele->signature = del->signature;
247 dele->expiration = *expiration;
248 GNUNET_CRYPTO_ecdsa_key_get_public (issuer, &dele->issuer_key);
249
250 dele->subject_key = *subject;
251
252 // Copy the combined string at the part in the memory where the struct ends
253 GNUNET_memcpy (&dele[1], tmp_str, attr_len);
254
255 dele->issuer_attribute = (char *) &dele[1];
256 dele->issuer_attribute_len = strlen (iss_attr);
257 if (NULL == sub_attr)
258 {
259 dele->subject_attribute = NULL;
260 dele->subject_attribute_len = 0;
261 }
262 else
263 {
264 dele->subject_attribute = (char *) &dele[1] + strlen (iss_attr) + 1;
265 dele->subject_attribute_len = strlen (sub_attr);
266 }
267
268 GNUNET_free (del);
269 return dele;
270}
diff --git a/src/abd/delegate_misc.h b/src/abd/delegate_misc.h
deleted file mode 100644
index 0a4ddd9eb..000000000
--- a/src/abd/delegate_misc.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012-2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file abd/delegate_misc.h
22 * @brief Delegate helper functions
23 */
24#ifndef DELEGATE_MISC_H
25#define DELEGATE_MISC_H
26
27#include "gnunet_abd_service.h"
28
29char *
30GNUNET_ABD_delegate_to_string (
31 const struct GNUNET_ABD_Delegate *cred);
32
33struct GNUNET_ABD_Delegate *
34GNUNET_ABD_delegate_from_string (const char *str);
35
36#endif
diff --git a/src/abd/gnunet-abd.c b/src/abd/gnunet-abd.c
deleted file mode 100644
index b1fb767e3..000000000
--- a/src/abd/gnunet-abd.c
+++ /dev/null
@@ -1,1100 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012-2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20/**
21 * @file gnunet-abd.c
22 * @brief command line tool to access command line Credential service
23 * @author Martin Schanzenbach
24 */
25#include "platform.h"
26#include <gnunet_util_lib.h>
27#include <gnunet_abd_service.h>
28#include <gnunet_gnsrecord_lib.h>
29#include <gnunet_namestore_service.h>
30#include "delegate_misc.h"
31#include "abd_serialization.h"
32
33/**
34 * Configuration we are using.
35 */
36static const struct GNUNET_CONFIGURATION_Handle *cfg;
37
38/**
39 * Handle to the namestore.
40 */
41static struct GNUNET_NAMESTORE_Handle *ns;
42
43/**
44 * Private key for the our zone.
45 */
46static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
47
48/**
49 * EgoLookup
50 */
51static struct GNUNET_IDENTITY_EgoLookup *el;
52
53/**
54 * Handle to Credential service.
55 */
56static struct GNUNET_ABD_Handle *abd;
57
58/**
59 * Desired timeout for the lookup (default is no timeout).
60 */
61static struct GNUNET_TIME_Relative timeout;
62
63/**
64 * Handle to verify request
65 */
66static struct GNUNET_ABD_Request *verify_request;
67
68/**
69 * Handle to collect request
70 */
71static struct GNUNET_ABD_Request *collect_request;
72
73/**
74 * Task scheduled to handle timeout.
75 */
76static struct GNUNET_SCHEDULER_Task *tt;
77
78/**
79 * Return value of the commandline.
80 */
81static int ret = 0;
82
83/**
84 * Subject pubkey string
85 */
86static char *subject;
87
88/**
89 * Subject delegate string
90 */
91static char *subject_delegate;
92
93/**
94 * Credential TTL
95 */
96static char *expiration;
97
98/**
99 * Subject key
100 */
101struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey;
102
103/**
104 * Issuer key
105 */
106struct GNUNET_CRYPTO_EcdsaPublicKey issuer_pkey;
107
108
109/**
110 * Issuer pubkey string
111 */
112static char *issuer_key;
113
114/**
115 * ego
116 */
117static char *ego_name;
118
119/**
120 * Issuer attribute
121 */
122static char *issuer_attr;
123
124/**
125 * Verify mode
126 */
127static int verify;
128
129/**
130 * Collect mode
131 */
132static int collect;
133
134/**
135 * Create mode
136 */
137static int create_is;
138
139/**
140 * Create mode
141 */
142static int create_ss;
143
144/**
145 * Create mode
146 */
147static int sign_ss;
148
149/**
150 * Signed issue credentials
151 */
152static char *import;
153
154/**
155 * Is record private
156 */
157static int is_private;
158
159/**
160 * Search direction: forward
161 */
162static int forward;
163
164/**
165 * Search direction: backward
166 */
167static int backward;
168
169/**
170 * API enum, filled and passed for collect/verify
171 */
172enum GNUNET_ABD_AlgoDirectionFlags direction = 0;
173
174/**
175 * Queue entry for the 'add' operation.
176 */
177static struct GNUNET_NAMESTORE_QueueEntry *add_qe;
178
179/**
180 * Value in binary format.
181 */
182static void *data;
183
184/**
185 * Number of bytes in #data.
186 */
187static size_t data_size;
188
189/**
190 * Type string converted to DNS type value.
191 */
192static uint32_t type;
193
194/**
195 * Type of the record to add/remove, NULL to remove all.
196 */
197static char *typestring;
198/**
199 * Expiration string converted to numeric value.
200 */
201static uint64_t etime;
202
203/**
204 * Is expiration time relative or absolute time?
205 */
206static int etime_is_rel = GNUNET_SYSERR;
207
208/**
209 * Fixed size of the public/private keys
210 */
211static const int key_length = 52;
212
213/**
214 * Record label for storing delegations
215 */
216static char *record_label;
217
218/**
219 * Task run on shutdown. Cleans up everything.
220 *
221 * @param cls unused
222 */
223static void
224do_shutdown (void *cls)
225{
226 if (NULL != verify_request)
227 {
228 GNUNET_ABD_request_cancel (verify_request);
229 verify_request = NULL;
230 }
231 if (NULL != abd)
232 {
233 GNUNET_ABD_disconnect (abd);
234 abd = NULL;
235 }
236 if (NULL != tt)
237 {
238 GNUNET_SCHEDULER_cancel (tt);
239 tt = NULL;
240 }
241 if (NULL != el)
242 {
243 GNUNET_IDENTITY_ego_lookup_cancel (el);
244 el = NULL;
245 }
246 if (NULL != add_qe)
247 {
248 GNUNET_NAMESTORE_cancel (add_qe);
249 add_qe = NULL;
250 }
251 if (NULL != ns)
252 {
253 GNUNET_NAMESTORE_disconnect (ns);
254 ns = NULL;
255 }
256}
257
258
259/**
260 * Task run on timeout. Triggers shutdown.
261 *
262 * @param cls unused
263 */
264static void
265do_timeout (void *cls)
266{
267 tt = NULL;
268 GNUNET_SCHEDULER_shutdown ();
269}
270
271
272static void
273handle_intermediate_result (void *cls,
274 struct GNUNET_ABD_Delegation *dd,
275 bool is_bw)
276{
277 char *prefix = "";
278 if (is_bw)
279 prefix = "Backward -";
280 else
281 prefix = "Forward -";
282
283 printf ("%s Intermediate result: %s.%s <- %s.%s\n",
284 prefix,
285 GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->issuer_key),
286 dd->issuer_attribute,
287 GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->subject_key),
288 dd->subject_attribute);
289}
290
291
292static void
293handle_collect_result (void *cls,
294 unsigned int d_count,
295 struct GNUNET_ABD_Delegation *dc,
296 unsigned int c_count,
297 struct GNUNET_ABD_Delegate *dele)
298{
299 int i;
300 char *line;
301
302 verify_request = NULL;
303 if (NULL != dele)
304 {
305 for (i = 0; i < c_count; i++)
306 {
307 line = GNUNET_ABD_delegate_to_string (&dele[i]);
308 printf ("%s\n", line);
309 GNUNET_free (line);
310 }
311 }
312 else
313 {
314 printf ("Received NULL\n");
315 }
316
317 GNUNET_SCHEDULER_shutdown ();
318}
319
320
321static void
322handle_verify_result (void *cls,
323 unsigned int d_count,
324 struct GNUNET_ABD_Delegation *dc,
325 unsigned int c_count,
326 struct GNUNET_ABD_Delegate *dele)
327{
328 int i;
329 char *iss_key;
330 char *sub_key;
331
332 verify_request = NULL;
333 if (NULL == dele)
334 ret = 1;
335 else
336 {
337 printf ("Delegation Chain:\n");
338 for (i = 0; i < d_count; i++)
339 {
340 iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key);
341 sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
342
343 if (0 != dc[i].subject_attribute_len)
344 {
345 printf ("(%d) %s.%s <- %s.%s\n",
346 i,
347 iss_key,
348 dc[i].issuer_attribute,
349 sub_key,
350 dc[i].subject_attribute);
351 }
352 else
353 {
354 printf ("(%d) %s.%s <- %s\n",
355 i,
356 iss_key,
357 dc[i].issuer_attribute,
358 sub_key);
359 }
360 GNUNET_free (iss_key);
361 GNUNET_free (sub_key);
362 }
363 printf ("\nDelegate(s):\n");
364 for (i = 0; i < c_count; i++)
365 {
366 iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].issuer_key);
367 sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].subject_key);
368 printf ("%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
369 GNUNET_free (iss_key);
370 GNUNET_free (sub_key);
371 }
372 printf ("Successful.\n");
373 }
374
375 GNUNET_SCHEDULER_shutdown ();
376}
377
378
379/**
380 * Callback invoked from identity service with ego information.
381 * An @a ego of NULL means the ego was not found.
382 *
383 * @param cls closure with the configuration
384 * @param ego an ego known to identity service, or NULL
385 */
386static void
387identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
388{
389 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
390
391 el = NULL;
392 if (NULL == ego)
393 {
394 if (NULL != ego_name)
395 {
396 fprintf (stderr,
397 _ ("Ego `%s' not known to identity service\n"),
398 ego_name);
399 }
400 GNUNET_SCHEDULER_shutdown ();
401 return;
402 }
403
404 if (GNUNET_YES == collect)
405 {
406
407 if (GNUNET_OK !=
408 GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_key,
409 strlen (issuer_key),
410 &issuer_pkey))
411 {
412 fprintf (stderr,
413 _ ("Issuer public key `%s' is not well-formed\n"),
414 issuer_key);
415 GNUNET_SCHEDULER_shutdown ();
416 }
417 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
418
419 collect_request = GNUNET_ABD_collect (abd,
420 &issuer_pkey,
421 issuer_attr,
422 privkey,
423 direction,
424 &handle_collect_result,
425 NULL,
426 &handle_intermediate_result,
427 NULL);
428 return;
429 }
430 GNUNET_SCHEDULER_shutdown ();
431}
432
433
434/**
435 * Parse expiration time.
436 *
437 * @param expirationstring text to parse
438 * @param etime_is_rel[out] set to #GNUNET_YES if time is relative
439 * @param etime[out] set to expiration time (abs or rel)
440 * @return #GNUNET_OK on success
441 */
442static int
443parse_expiration (const char *expirationstring,
444 int *etime_is_rel,
445 uint64_t *etime)
446{
447 // copied from namestore/gnunet-namestore.c
448 struct GNUNET_TIME_Relative etime_rel;
449 struct GNUNET_TIME_Absolute etime_abs;
450
451 if (0 == strcmp (expirationstring, "never"))
452 {
453 *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
454 *etime_is_rel = GNUNET_NO;
455 return GNUNET_OK;
456 }
457 if (GNUNET_OK ==
458 GNUNET_STRINGS_fancy_time_to_relative (expirationstring, &etime_rel))
459 {
460 *etime_is_rel = GNUNET_YES;
461 *etime = etime_rel.rel_value_us;
462 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
463 "Storing record with relative expiration time of %s\n",
464 GNUNET_STRINGS_relative_time_to_string (etime_rel, GNUNET_NO));
465 return GNUNET_OK;
466 }
467 if (GNUNET_OK ==
468 GNUNET_STRINGS_fancy_time_to_absolute (expirationstring, &etime_abs))
469 {
470 *etime_is_rel = GNUNET_NO;
471 *etime = etime_abs.abs_value_us;
472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
473 "Storing record with absolute expiration time of %s\n",
474 GNUNET_STRINGS_absolute_time_to_string (etime_abs));
475 return GNUNET_OK;
476 }
477 return GNUNET_SYSERR;
478}
479
480
481/**
482 * Function called if lookup fails.
483 */
484static void
485error_cb (void *cls)
486{
487 fprintf (stderr, "Error occurred during lookup, shutting down.\n");
488 GNUNET_SCHEDULER_shutdown ();
489 return;
490}
491
492
493static void
494add_continuation (void *cls, int32_t success, const char *emsg)
495{
496 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
497 *qe = NULL;
498
499 if (GNUNET_OK == success)
500 printf ("Adding successful.\n");
501 else
502 fprintf (stderr, "Error occurred during adding, shutting down.\n");
503
504 GNUNET_SCHEDULER_shutdown ();
505}
506
507
508static void
509get_existing_record (void *cls,
510 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
511 const char *rec_name,
512 unsigned int rd_count,
513 const struct GNUNET_GNSRECORD_Data *rd)
514{
515 struct GNUNET_GNSRECORD_Data *rde;
516 struct GNUNET_GNSRECORD_Data*rdn =
517 GNUNET_malloc (sizeof(*rdn) * (rd_count + 1));
518
519 memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
520 GNUNET_memcpy (&rdn[1], rd,
521 rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
522 rde = &rdn[0];
523 rde->data = data;
524 rde->data_size = data_size;
525 rde->record_type = type;
526
527 // Set flags
528 if (GNUNET_YES == is_private)
529 rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
530 rde->expiration_time = etime;
531 if (GNUNET_YES == etime_is_rel)
532 rde->flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
533 else if (GNUNET_NO != etime_is_rel)
534 rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
535
536 GNUNET_assert (NULL != rec_name);
537 add_qe = GNUNET_NAMESTORE_records_store (ns,
538 &zone_pkey,
539 rec_name,
540 rd_count + 1,
541 rde,
542 &add_continuation,
543 &add_qe);
544 GNUNET_free (rdn);
545 return;
546}
547
548
549static void
550store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
551{
552 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
553
554 el = NULL;
555
556 ns = GNUNET_NAMESTORE_connect (cfg);
557 if (NULL == ns)
558 {
559 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
560 _ ("Failed to connect to namestore\n"));
561 GNUNET_SCHEDULER_shutdown ();
562 return;
563 }
564
565 // Key handling
566 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
567
568 if (GNUNET_GNSRECORD_TYPE_DELEGATE == type)
569 {
570 // Parse import
571 struct GNUNET_ABD_Delegate *cred;
572 cred = GNUNET_ABD_delegate_from_string (import);
573
574 // Get import subject public key string
575 char *subject_pubkey_str =
576 GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key);
577
578 // Get zone public key string
579 struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey;
580 GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey);
581 char *zone_pubkey_str =
582 GNUNET_CRYPTO_ecdsa_public_key_to_string (&zone_pubkey);
583
584 // Check if the subject key in the signed import matches the zone's key it is issued to
585 if (strcmp (zone_pubkey_str, subject_pubkey_str) != 0)
586 {
587 fprintf (stderr,
588 "Import signed delegate does not match this ego's public key.\n");
589 GNUNET_SCHEDULER_shutdown ();
590 return;
591 }
592
593 // Expiration
594 etime = cred->expiration.abs_value_us;
595 etime_is_rel = GNUNET_NO;
596
597 // Prepare the data to be store in the record
598 data_size = GNUNET_ABD_delegate_serialize (cred, (char **) &data);
599 GNUNET_free (cred);
600 }
601 else
602 {
603 // For all other types e.g. GNUNET_GNSRECORD_TYPE_ATTRIBUTE
604 if (GNUNET_OK !=
605 GNUNET_GNSRECORD_string_to_value (type, subject, &data, &data_size))
606 {
607 if (typestring == NULL)
608 {
609 fputs ("No value for unknown record type\n", stderr);
610 }
611 else if (subject == NULL)
612 {
613 fprintf (stderr,
614 "No value for record type`%s'\n",
615 typestring);
616 }
617 else
618 {
619 fprintf (stderr,
620 "Value `%s' invalid for record type `%s'\n",
621 subject,
622 typestring);
623 }
624 GNUNET_SCHEDULER_shutdown ();
625 return;
626 }
627
628 // Take care of expiration
629 if (NULL == expiration)
630 {
631 fprintf (stderr, "Missing option -e for operation 'create'\n");
632 GNUNET_SCHEDULER_shutdown ();
633 return;
634 }
635 if (GNUNET_OK != parse_expiration (expiration, &etime_is_rel, &etime))
636 {
637 fprintf (stderr, "Invalid time format `%s'\n", expiration);
638 GNUNET_SCHEDULER_shutdown ();
639 return;
640 }
641 }
642
643 // Start lookup
644 add_qe = GNUNET_NAMESTORE_records_lookup (ns,
645 &zone_pkey,
646 record_label,
647 &error_cb,
648 NULL,
649 &get_existing_record,
650 NULL);
651 return;
652}
653
654
655static void
656sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
657{
658 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
659 struct GNUNET_ABD_Delegate *dele;
660 struct GNUNET_TIME_Absolute etime_abs;
661 char *res;
662
663 el = NULL;
664
665 // work on expiration time
666 if (NULL == expiration)
667 {
668 fprintf (stderr, "Please specify a TTL\n");
669 GNUNET_SCHEDULER_shutdown ();
670 return;
671 }
672 else if (GNUNET_OK !=
673 GNUNET_STRINGS_fancy_time_to_absolute (expiration, &etime_abs))
674 {
675 fprintf (stderr,
676 "%s is not a valid ttl! Only absolute times are accepted!\n",
677 expiration);
678 GNUNET_SCHEDULER_shutdown ();
679 return;
680 }
681
682 // If contains a space - split it by the first space only - assume first entry is subject followed by attribute(s)
683 char *subject_pubkey_str;
684 char *subject_attr = NULL;
685 char *token;
686
687 // Subject Public Key
688 token = strtok (subject, " ");
689 if (key_length == strlen (token))
690 {
691 subject_pubkey_str = token;
692 }
693 else
694 {
695 fprintf (stderr, "Key error, wrong length: %ld!\n", strlen (token));
696 GNUNET_SCHEDULER_shutdown ();
697 return;
698 }
699 // Subject Attribute(s)
700 token = strtok (NULL, " ");
701 if (NULL != token)
702 {
703 subject_attr = token;
704 }
705
706 // work on keys
707 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
708
709 if (GNUNET_OK !=
710 GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pubkey_str,
711 strlen (subject_pubkey_str),
712 &subject_pkey))
713 {
714 fprintf (stderr,
715 "Subject public key `%s' is not well-formed\n",
716 subject_pubkey_str);
717 GNUNET_SCHEDULER_shutdown ();
718 return;
719 }
720
721 // Sign delegate
722 dele = GNUNET_ABD_delegate_issue (privkey,
723 &subject_pkey,
724 issuer_attr,
725 subject_attr,
726 &etime_abs);
727 res = GNUNET_ABD_delegate_to_string (dele);
728 GNUNET_free (dele);
729 printf ("%s\n", res);
730
731 GNUNET_free (ego_name);
732 ego_name = NULL;
733
734 GNUNET_SCHEDULER_shutdown ();
735}
736
737
738/**
739 * Main function that will be run.
740 *
741 * @param cls closure
742 * @param args remaining command-line arguments
743 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
744 * @param c configuration
745 */
746static void
747run (void *cls,
748 char *const *args,
749 const char *cfgfile,
750 const struct GNUNET_CONFIGURATION_Handle *c)
751{
752 cfg = c;
753
754 tt = GNUNET_SCHEDULER_add_delayed (timeout, &do_timeout, NULL);
755 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
756
757 // Check relevant cmdline parameters
758 if (GNUNET_YES == create_is)
759 {
760 if (NULL == ego_name)
761 {
762 fprintf (stderr, "Missing option '-ego'\n");
763 GNUNET_SCHEDULER_shutdown ();
764 return;
765 }
766 if (NULL == issuer_attr)
767 {
768 fprintf (stderr, "Missing option '-attribute' for issuer attribute\n");
769 GNUNET_SCHEDULER_shutdown ();
770 return;
771 }
772 if (NULL == subject)
773 {
774 fprintf (stderr, "Missing option -subject for operation 'create'.'\n");
775 GNUNET_SCHEDULER_shutdown ();
776 return;
777 }
778
779 // Lookup ego, on success call store_cb and store as ATTRIBUTE type
780 type = GNUNET_GNSRECORD_TYPE_ATTRIBUTE;
781 record_label = issuer_attr;
782 el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &store_cb, (void *) cfg);
783 return;
784 }
785
786 if (GNUNET_YES == create_ss)
787 {
788
789 // check if signed parameter has been passed in cmd line call
790 if (NULL == import)
791 {
792 fprintf (stderr, "'import' required\n");
793 GNUNET_SCHEDULER_shutdown ();
794 return;
795 }
796
797 type = GNUNET_GNSRECORD_TYPE_DELEGATE;
798 record_label = GNUNET_GNS_EMPTY_LABEL_AT;
799 // Store subject side
800 el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &store_cb, (void *) cfg);
801
802 return;
803 }
804
805 if (GNUNET_YES == sign_ss)
806 {
807 if (NULL == ego_name)
808 {
809 fprintf (stderr, "ego required\n");
810 GNUNET_SCHEDULER_shutdown ();
811 return;
812 }
813 if (NULL == subject)
814 {
815 fprintf (stderr, "Subject public key needed\n");
816 GNUNET_SCHEDULER_shutdown ();
817 return;
818 }
819
820 // lookup ego and call function sign_cb on success
821 el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &sign_cb, (void *) cfg);
822 return;
823 }
824
825 if ((GNUNET_NO == forward) && (GNUNET_NO == backward))
826 {
827 // set default: bidirectional
828 forward = GNUNET_YES;
829 backward = GNUNET_YES;
830 }
831 if (GNUNET_YES == forward)
832 direction |= GNUNET_ABD_FLAG_FORWARD;
833 if (GNUNET_YES == backward)
834 direction |= GNUNET_ABD_FLAG_BACKWARD;
835
836 if (GNUNET_YES == collect)
837 {
838 if (NULL == issuer_key)
839 {
840 fprintf (stderr, _ ("Issuer public key not well-formed\n"));
841 GNUNET_SCHEDULER_shutdown ();
842 return;
843 }
844
845 abd = GNUNET_ABD_connect (cfg);
846
847 if (NULL == abd)
848 {
849 fprintf (stderr, _ ("Failed to connect to ABD\n"));
850 GNUNET_SCHEDULER_shutdown ();
851 return;
852 }
853 if (NULL == issuer_attr)
854 {
855 fprintf (stderr, _ ("You must provide issuer the attribute\n"));
856 GNUNET_SCHEDULER_shutdown ();
857 return;
858 }
859
860 if (NULL == ego_name)
861 {
862 fprintf (stderr, _ ("ego required\n"));
863 GNUNET_SCHEDULER_shutdown ();
864 return;
865 }
866 el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg);
867 return;
868 }
869
870 if (NULL == subject)
871 {
872 fprintf (stderr, _ ("Subject public key needed\n"));
873 GNUNET_SCHEDULER_shutdown ();
874 return;
875 }
876 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (subject,
877 strlen (subject),
878 &subject_pkey))
879 {
880 fprintf (stderr,
881 _ ("Subject public key `%s' is not well-formed\n"),
882 subject);
883 GNUNET_SCHEDULER_shutdown ();
884 return;
885 }
886
887 if (GNUNET_YES == verify)
888 {
889 if (NULL == issuer_key)
890 {
891 fprintf (stderr, _ ("Issuer public key not well-formed\n"));
892 GNUNET_SCHEDULER_shutdown ();
893 return;
894 }
895 if (GNUNET_OK !=
896 GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_key,
897 strlen (issuer_key),
898 &issuer_pkey))
899 {
900 fprintf (stderr,
901 _ ("Issuer public key `%s' is not well-formed\n"),
902 issuer_key);
903 GNUNET_SCHEDULER_shutdown ();
904 return;
905 }
906 abd = GNUNET_ABD_connect (cfg);
907
908 if (NULL == abd)
909 {
910 fprintf (stderr, _ ("Failed to connect to ABD\n"));
911 GNUNET_SCHEDULER_shutdown ();
912 return;
913 }
914 if ((NULL == issuer_attr) || (NULL == subject_delegate))
915 {
916 fprintf (stderr, _ ("You must provide issuer and subject attributes\n"));
917 GNUNET_SCHEDULER_shutdown ();
918 return;
919 }
920
921 // Subject credentials are comma separated
922 char *tmp = GNUNET_strdup (subject_delegate);
923 char *tok = strtok (tmp, ",");
924 if (NULL == tok)
925 {
926 fprintf (stderr, "Invalid subject credentials\n");
927 GNUNET_free (tmp);
928 GNUNET_SCHEDULER_shutdown ();
929 return;
930 }
931 int count = 1;
932 int i;
933 while (NULL != (tok = strtok (NULL, ",")))
934 count++;
935 struct GNUNET_ABD_Delegate*delegates =
936 GNUNET_malloc (sizeof(*delegates) * count);
937 struct GNUNET_ABD_Delegate *dele;
938 GNUNET_free (tmp);
939 tmp = GNUNET_strdup (subject_delegate);
940 tok = strtok (tmp, ",");
941 for (i = 0; i < count; i++)
942 {
943 dele = GNUNET_ABD_delegate_from_string (tok);
944 GNUNET_memcpy (&delegates[i],
945 dele,
946 sizeof (struct GNUNET_ABD_Delegate));
947 delegates[i].issuer_attribute = GNUNET_strdup (dele->issuer_attribute);
948 tok = strtok (NULL, ",");
949 GNUNET_free (dele);
950 }
951
952 verify_request = GNUNET_ABD_verify (abd,
953 &issuer_pkey,
954 issuer_attr,
955 &subject_pkey,
956 count,
957 delegates,
958 direction,
959 &handle_verify_result,
960 NULL,
961 &handle_intermediate_result,
962 NULL);
963 for (i = 0; i < count; i++)
964 {
965 GNUNET_free_nz ((char *) delegates[i].issuer_attribute);
966 delegates[i].issuer_attribute = NULL;
967 }
968 GNUNET_free (tmp);
969 GNUNET_free (delegates);
970 }
971 else
972 {
973 fprintf (stderr,
974 _ (
975 "Please specify name to lookup, subject key and issuer key!\n"));
976 GNUNET_SCHEDULER_shutdown ();
977 }
978 return;
979}
980
981
982/**
983 * The main function for gnunet-gns.
984 *
985 * @param argc number of arguments from the command line
986 * @param argv command line arguments
987 * @return 0 ok, 1 on error
988 */
989int
990main (int argc, char *const *argv)
991{
992 struct GNUNET_GETOPT_CommandLineOption options[] =
993 {GNUNET_GETOPT_option_flag ('V',
994 "verify",
995 gettext_noop (
996 "verify credential against attribute"),
997 &verify),
998 GNUNET_GETOPT_option_string (
999 's',
1000 "subject",
1001 "PKEY",
1002 gettext_noop (
1003 "The public key of the subject to lookup the"
1004 "credential for, or for issuer side storage: subject and its attributes"),
1005 &subject),
1006 GNUNET_GETOPT_option_string (
1007 'd',
1008 "delegate",
1009 "DELE",
1010 gettext_noop ("The private, signed delegate presented by the subject"),
1011 &subject_delegate),
1012 GNUNET_GETOPT_option_string (
1013 'i',
1014 "issuer",
1015 "PKEY",
1016 gettext_noop (
1017 "The public key of the authority to verify the credential against"),
1018 &issuer_key),
1019 GNUNET_GETOPT_option_string ('e',
1020 "ego",
1021 "EGO",
1022 gettext_noop ("The ego/zone name to use"),
1023 &ego_name),
1024 GNUNET_GETOPT_option_string (
1025 'a',
1026 "attribute",
1027 "ATTR",
1028 gettext_noop ("The issuer attribute to verify against or to issue"),
1029 &issuer_attr),
1030 GNUNET_GETOPT_option_string ('T',
1031 "ttl",
1032 "EXP",
1033 gettext_noop (
1034 "The time to live for the credential."
1035 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
1036 &expiration),
1037 GNUNET_GETOPT_option_flag ('g',
1038 "collect",
1039 gettext_noop ("collect credentials"),
1040 &collect),
1041 GNUNET_GETOPT_option_flag ('U',
1042 "createIssuerSide",
1043 gettext_noop (
1044 "Create and issue a credential issuer side."),
1045 &create_is),
1046 GNUNET_GETOPT_option_flag ('C',
1047 "createSubjectSide",
1048 gettext_noop (
1049 "Issue a credential subject side."),
1050 &create_ss),
1051 GNUNET_GETOPT_option_flag (
1052 'S',
1053 "signSubjectSide",
1054 gettext_noop ("Create, sign and return a credential subject side."),
1055 &sign_ss),
1056 GNUNET_GETOPT_option_string (
1057 'x',
1058 "import",
1059 "IMP",
1060 gettext_noop (
1061 "Import signed credentials that should be issued to a zone/ego"),
1062 &import),
1063 GNUNET_GETOPT_option_flag ('P',
1064 "private",
1065 gettext_noop ("Create private record entry."),
1066 &is_private),
1067 GNUNET_GETOPT_option_flag (
1068 'F',
1069 "forward",
1070 gettext_noop (
1071 "Indicates that the collect/verify process is done via forward search."),
1072 &forward),
1073 GNUNET_GETOPT_option_flag (
1074 'B',
1075 "backward",
1076 gettext_noop (
1077 "Indicates that the collect/verify process is done via forward search."),
1078 &backward),
1079 GNUNET_GETOPT_OPTION_END};
1080
1081
1082 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
1083 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1084 return 2;
1085
1086 GNUNET_log_setup ("gnunet-abd", "WARNING", NULL);
1087 if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
1088 argv,
1089 "gnunet-abd",
1090 _ ("GNUnet abd resolver tool"),
1091 options,
1092 &run,
1093 NULL))
1094 ret = 1;
1095 GNUNET_free_nz ((void *) argv);
1096 return ret;
1097}
1098
1099
1100/* end of gnunet-abd.c */
diff --git a/src/abd/gnunet-service-abd.c b/src/abd/gnunet-service-abd.c
deleted file mode 100644
index 93368da45..000000000
--- a/src/abd/gnunet-service-abd.c
+++ /dev/null
@@ -1,1775 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20/**
21 * @file abd/gnunet-service-abd.c
22 * @brief GNUnet Credential Service (main service)
23 * @author Martin Schanzenbach
24 */
25#include "platform.h"
26
27#include "gnunet_util_lib.h"
28
29#include "abd.h"
30#include "abd_serialization.h"
31#include "gnunet_abd_service.h"
32#include "gnunet_protocols.h"
33#include "gnunet_signatures.h"
34#include "gnunet_statistics_service.h"
35#include <gnunet_dnsparser_lib.h>
36#include <gnunet_gns_service.h>
37#include <gnunet_gnsrecord_lib.h>
38#include <gnunet_identity_service.h>
39#include <gnunet_namestore_service.h>
40
41
42#define GNUNET_ABD_MAX_LENGTH 255
43
44struct VerifyRequestHandle;
45
46struct DelegationSetQueueEntry;
47
48
49struct DelegationChainEntry
50{
51 /**
52 * DLL
53 */
54 struct DelegationChainEntry *next;
55
56 /**
57 * DLL
58 */
59 struct DelegationChainEntry *prev;
60
61 /**
62 * The issuer
63 */
64 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
65
66 /**
67 * The subject
68 */
69 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
70
71 /**
72 * The issued attribute
73 */
74 char *issuer_attribute;
75
76 /**
77 * The delegated attribute
78 */
79 char *subject_attribute;
80};
81
82/**
83 * DLL for record
84 */
85struct DelegateRecordEntry
86{
87 /**
88 * DLL
89 */
90 struct DelegateRecordEntry *next;
91
92 /**
93 * DLL
94 */
95 struct DelegateRecordEntry *prev;
96
97 /**
98 * Number of references in delegation chains
99 */
100 uint32_t refcount;
101
102 /**
103 * Payload
104 */
105 struct GNUNET_ABD_Delegate *delegate;
106};
107
108/**
109 * DLL used for delegations
110 * Used for OR delegations
111 */
112struct DelegationQueueEntry
113{
114 /**
115 * DLL
116 */
117 struct DelegationQueueEntry *next;
118
119 /**
120 * DLL
121 */
122 struct DelegationQueueEntry *prev;
123
124 /**
125 * Parent set
126 */
127 struct DelegationSetQueueEntry *parent_set;
128
129 /**
130 * Required solutions
131 */
132 uint32_t required_solutions;
133};
134
135/**
136 * DLL for delegation sets
137 * Used for AND delegation set
138 */
139struct DelegationSetQueueEntry
140{
141 /**
142 * DLL
143 */
144 struct DelegationSetQueueEntry *next;
145
146 /**
147 * DLL
148 */
149 struct DelegationSetQueueEntry *prev;
150
151 /**
152 * GNS handle
153 */
154 struct GNUNET_GNS_LookupRequest *lookup_request;
155
156 /**
157 * Verify handle
158 */
159 struct VerifyRequestHandle *handle;
160
161 /**
162 * Parent attribute delegation
163 */
164 struct DelegationQueueEntry *parent;
165
166 /**
167 * Issuer key
168 */
169 struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key;
170
171 /**
172 * Queue entries of this set
173 */
174 struct DelegationQueueEntry *queue_entries_head;
175
176 /**
177 * Queue entries of this set
178 */
179 struct DelegationQueueEntry *queue_entries_tail;
180
181 /**
182 * Parent QueueEntry
183 */
184 struct DelegationQueueEntry *parent_queue_entry;
185
186 /**
187 * Issuer attribute delegated to
188 */
189 char *issuer_attribute;
190
191 /**
192 * The current attribute to look up
193 */
194 char *lookup_attribute;
195
196 /**
197 * Trailing attribute context
198 */
199 char *attr_trailer;
200
201 /**
202 * Still to resolve delegation as string
203 */
204 char *unresolved_attribute_delegation;
205
206 /**
207 * The delegation chain entry
208 */
209 struct DelegationChainEntry *delegation_chain_entry;
210
211 /**
212 * True if added by backward resolution
213 */
214 bool from_bw;
215};
216
217
218/**
219 * Handle to a lookup operation from api
220 */
221struct VerifyRequestHandle
222{
223 /**
224 * True if created by a collect request.
225 */
226 bool is_collect;
227 /**
228 * We keep these in a DLL.
229 */
230 struct VerifyRequestHandle *next;
231
232 /**
233 * We keep these in a DLL.
234 */
235 struct VerifyRequestHandle *prev;
236
237 /**
238 * Handle to the requesting client
239 */
240 struct GNUNET_SERVICE_Client *client;
241
242 /**
243 * Size of delegation tree
244 */
245 uint32_t delegation_chain_size;
246
247 /**
248 * Children of this attribute
249 */
250 struct DelegationChainEntry *delegation_chain_head;
251
252 /**
253 * Children of this attribute
254 */
255 struct DelegationChainEntry *delegation_chain_tail;
256
257 /**
258 * List for bidirectional matching
259 */
260 struct DelegationSetQueueEntry *dsq_head;
261
262 /**
263 * List for bidirectional matching
264 */
265 struct DelegationSetQueueEntry *dsq_tail;
266
267 /**
268 * Issuer public key
269 */
270 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
271
272 /**
273 * Issuer attribute
274 */
275 char *issuer_attribute;
276
277 /**
278 * Subject public key
279 */
280 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
281
282 /**
283 * Delegate DLL
284 */
285 struct DelegateRecordEntry *del_chain_head;
286
287 /**
288 * Delegate DLL
289 */
290 struct DelegateRecordEntry *del_chain_tail;
291
292 /**
293 * Delegate DLL size
294 */
295 uint32_t del_chain_size;
296
297 /**
298 * Current Delegation Pointer
299 */
300 struct DelegationQueueEntry *current_delegation;
301
302 /**
303 * request id
304 */
305 uint32_t request_id;
306
307 /**
308 * Pending lookups
309 */
310 uint64_t pending_lookups;
311
312 /**
313 * Direction of the resolution algo
314 */
315 enum GNUNET_ABD_AlgoDirectionFlags resolution_algo;
316
317 /**
318 * Delegate iterator for lookup
319 */
320 struct GNUNET_NAMESTORE_QueueEntry *dele_qe;
321};
322
323
324/**
325 * Head of the DLL.
326 */
327static struct VerifyRequestHandle *vrh_head = NULL;
328
329/**
330 * Tail of the DLL.
331 */
332static struct VerifyRequestHandle *vrh_tail = NULL;
333
334/**
335 * Handle to the statistics service
336 */
337static struct GNUNET_STATISTICS_Handle *statistics;
338
339/**
340 * Handle to GNS service.
341 */
342static struct GNUNET_GNS_Handle *gns;
343
344/**
345 * Handle to namestore service
346 */
347static struct GNUNET_NAMESTORE_Handle *namestore;
348
349static void
350print_deleset (struct DelegationSetQueueEntry *dsentry, char *text)
351{
352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
353 "%s %s.%s <- %s.%s\n",
354 text,
355 GNUNET_CRYPTO_ecdsa_public_key_to_string (
356 &dsentry->delegation_chain_entry->issuer_key),
357 dsentry->delegation_chain_entry->issuer_attribute,
358 GNUNET_CRYPTO_ecdsa_public_key_to_string (
359 &dsentry->delegation_chain_entry->subject_key),
360 dsentry->delegation_chain_entry->subject_attribute);
361}
362
363
364static void
365cleanup_dsq_entry (struct DelegationSetQueueEntry *ds_entry)
366{
367 GNUNET_free (ds_entry->issuer_key);
368 GNUNET_free (ds_entry->issuer_attribute);
369 GNUNET_free (ds_entry->attr_trailer);
370 // those fields are only set/used in bw search
371 if (ds_entry->from_bw)
372 {
373 GNUNET_free (ds_entry->lookup_attribute);
374 GNUNET_free (ds_entry->unresolved_attribute_delegation);
375 }
376 if (NULL != ds_entry->lookup_request)
377 {
378 GNUNET_GNS_lookup_cancel (ds_entry->lookup_request);
379 ds_entry->lookup_request = NULL;
380 }
381 if (NULL != ds_entry->delegation_chain_entry)
382 {
383 GNUNET_free (
384 ds_entry->delegation_chain_entry->subject_attribute);
385 GNUNET_free (ds_entry->delegation_chain_entry->issuer_attribute);
386 GNUNET_free (ds_entry->delegation_chain_entry);
387 }
388 // Free DQ entries
389 for (struct DelegationQueueEntry *dq_entry = ds_entry->queue_entries_head;
390 NULL != ds_entry->queue_entries_head;
391 dq_entry = ds_entry->queue_entries_head)
392 {
393 GNUNET_CONTAINER_DLL_remove (ds_entry->queue_entries_head,
394 ds_entry->queue_entries_tail,
395 dq_entry);
396 GNUNET_free (dq_entry);
397 }
398 GNUNET_free (ds_entry);
399}
400
401
402static void
403cleanup_handle (struct VerifyRequestHandle *vrh)
404{
405 struct DelegateRecordEntry *del_entry;
406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n");
407
408 if (NULL != vrh->dsq_head)
409 {
410 for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL !=
411 vrh->dsq_head;
412 ds_entry = vrh->dsq_head)
413 {
414 GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry);
415 cleanup_dsq_entry (ds_entry);
416 }
417 }
418 if (NULL != vrh->del_chain_head)
419 {
420 for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
421 del_entry = vrh->del_chain_head)
422 {
423 GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
424 vrh->del_chain_tail,
425 del_entry);
426 GNUNET_free (del_entry->delegate);
427 GNUNET_free (del_entry);
428 }
429 }
430 GNUNET_free (vrh->issuer_attribute);
431 GNUNET_free (vrh);
432}
433
434
435static void
436shutdown_task (void *cls)
437{
438 struct VerifyRequestHandle *vrh;
439
440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down!\n");
441
442 while (NULL != (vrh = vrh_head))
443 {
444 // ABD_resolver_lookup_cancel (clh->lookup);
445 GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh);
446 cleanup_handle (vrh);
447 }
448
449 if (NULL != gns)
450 {
451 GNUNET_GNS_disconnect (gns);
452 gns = NULL;
453 }
454 if (NULL != namestore)
455 {
456 GNUNET_NAMESTORE_disconnect (namestore);
457 namestore = NULL;
458 }
459 if (NULL != statistics)
460 {
461 GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
462 statistics = NULL;
463 }
464}
465
466
467static void
468send_intermediate_response (struct VerifyRequestHandle *vrh, struct
469 DelegationChainEntry *ch_entry, bool is_bw)
470{
471 struct DelegationChainIntermediateMessage *rmsg;
472 struct GNUNET_MQ_Envelope *env;
473 struct GNUNET_ABD_Delegation *dd;
474 size_t size;
475
476 // Don't report immediate results during collect
477 if (vrh->is_collect)
478 return;
479
480 dd = GNUNET_new (struct GNUNET_ABD_Delegation);
481 dd->issuer_key = ch_entry->issuer_key;
482 dd->subject_key = ch_entry->subject_key;
483 dd->issuer_attribute = ch_entry->issuer_attribute;
484 dd->issuer_attribute_len = strlen (ch_entry->issuer_attribute) + 1;
485 dd->subject_attribute_len = 0;
486 dd->subject_attribute = NULL;
487 if (NULL != ch_entry->subject_attribute)
488 {
489 dd->subject_attribute = ch_entry->subject_attribute;
490 dd->subject_attribute_len = strlen (ch_entry->subject_attribute) + 1;
491 }
492
493
494 size = GNUNET_ABD_delegation_chain_get_size (1,
495 dd,
496 0,
497 NULL);
498
499 env = GNUNET_MQ_msg_extra (rmsg,
500 size,
501 GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT);
502 // Assign id so that client can find associated request
503 rmsg->id = vrh->request_id;
504 rmsg->is_bw = htons (is_bw);
505 rmsg->size = htonl (size);
506
507 GNUNET_assert (
508 -1 != GNUNET_ABD_delegation_chain_serialize (1,
509 dd,
510 0,
511 NULL,
512 size,
513 (char *) &rmsg[1]));
514 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env);
515}
516
517
518static void
519send_lookup_response (struct VerifyRequestHandle *vrh)
520{
521 struct GNUNET_MQ_Envelope *env;
522 struct DelegationChainResultMessage *rmsg;
523 struct DelegationChainEntry *dce;
524 struct GNUNET_ABD_Delegation dd[vrh->delegation_chain_size];
525 struct GNUNET_ABD_Delegate dele[vrh->del_chain_size];
526 struct DelegateRecordEntry *del;
527 struct DelegateRecordEntry *tmp;
528 size_t size;
529
530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending response\n");
531 dce = vrh->delegation_chain_head;
532 for (uint32_t i = 0; i < vrh->delegation_chain_size; i++)
533 {
534 dd[i].issuer_key = dce->issuer_key;
535 dd[i].subject_key = dce->subject_key;
536 dd[i].issuer_attribute = dce->issuer_attribute;
537 dd[i].issuer_attribute_len = strlen (dce->issuer_attribute) + 1;
538 dd[i].subject_attribute_len = 0;
539 dd[i].subject_attribute = NULL;
540 if (NULL != dce->subject_attribute)
541 {
542 dd[i].subject_attribute = dce->subject_attribute;
543 dd[i].subject_attribute_len = strlen (dce->subject_attribute) + 1;
544 }
545 dce = dce->next;
546 }
547
548 // Remove all not needed credentials
549 for (del = vrh->del_chain_head; NULL != del;)
550 {
551 if (del->refcount > 0)
552 {
553 del = del->next;
554 continue;
555 }
556 tmp = del;
557 del = del->next;
558 GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, vrh->del_chain_tail, tmp);
559 GNUNET_free (tmp->delegate);
560 GNUNET_free (tmp);
561 vrh->del_chain_size--;
562 }
563
564 // Get serialized record data
565 // Append at the end of rmsg
566 del = vrh->del_chain_head;
567 for (uint32_t i = 0; i < vrh->del_chain_size; i++)
568 {
569 dele[i].issuer_key = del->delegate->issuer_key;
570 dele[i].subject_key = del->delegate->subject_key;
571 dele[i].issuer_attribute_len = strlen (del->delegate->issuer_attribute) + 1;
572 dele[i].issuer_attribute = del->delegate->issuer_attribute;
573 dele[i].subject_attribute_len = del->delegate->subject_attribute_len;
574 dele[i].subject_attribute = del->delegate->subject_attribute;
575 dele[i].expiration = del->delegate->expiration;
576 dele[i].signature = del->delegate->signature;
577 del = del->next;
578 }
579 size =
580 GNUNET_ABD_delegation_chain_get_size (vrh->delegation_chain_size,
581 dd,
582 vrh->del_chain_size,
583 dele);
584 env = GNUNET_MQ_msg_extra (rmsg,
585 size,
586 GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT);
587 // Assign id so that client can find associated request
588 rmsg->id = vrh->request_id;
589 rmsg->d_count = htonl (vrh->delegation_chain_size);
590 rmsg->c_count = htonl (vrh->del_chain_size);
591
592 if (0 < vrh->del_chain_size)
593 rmsg->del_found = htonl (GNUNET_YES);
594 else
595 rmsg->del_found = htonl (GNUNET_NO);
596
597 GNUNET_assert (
598 -1 !=
599 GNUNET_ABD_delegation_chain_serialize (vrh->delegation_chain_size,
600 dd,
601 vrh->del_chain_size,
602 dele,
603 size,
604 (char *) &rmsg[1]));
605
606 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env);
607 GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh);
608 cleanup_handle (vrh);
609 GNUNET_STATISTICS_update (statistics,
610 "Completed verifications",
611 1,
612 GNUNET_NO);
613}
614
615
616static char *
617partial_match (char *tmp_trail,
618 char *tmp_subattr,
619 char *parent_trail,
620 char *issuer_attribute)
621{
622 char *saveptr1, *saveptr2;
623 char *trail_token;
624 char *sub_token;
625 char *attr_trailer;
626
627 // tok both, parent->attr_trailer and del->sub_attr to see how far they match,
628 // take rest of parent trailer (only when del->sub_attr token is null), and
629 // create new/actual trailer with del->iss_attr
630 trail_token = strtok_r (tmp_trail, ".", &saveptr1);
631 sub_token = strtok_r (tmp_subattr, ".", &saveptr2);
632 while (NULL != trail_token && NULL != sub_token)
633 {
634 if (0 == strcmp (trail_token, sub_token))
635 {
636 // good, matches, remove
637 }
638 else
639 {
640 // not relevant for solving the chain, end for iteration here
641 return NULL;
642 }
643
644 trail_token = strtok_r (NULL, ".", &saveptr1);
645 sub_token = strtok_r (NULL, ".", &saveptr2);
646 }
647 // skip this entry and go to next for if:
648 // 1. at some point the attr of the trailer and the subject dont match
649 // 2. the trailer is NULL, but the subject has more attributes
650 // Reason: This will lead to "startzone.attribute" but we're looking for a solution
651 // for "<- startzone"
652 if (NULL == trail_token)
653 {
654 return NULL;
655 }
656
657 // do not have to check sub_token == NULL, if both would be NULL
658 // at the same time, the complete match part above should have triggered already
659
660 // otherwise, above while only ends when sub_token == NULL
661 GNUNET_asprintf (&attr_trailer, "%s", trail_token);
662 trail_token = strtok_r (NULL, ".", &saveptr1);
663 while (NULL != trail_token)
664 {
665 GNUNET_asprintf (&attr_trailer, "%s.%s", parent_trail, trail_token);
666 trail_token = strtok_r (NULL, ".", &saveptr1);
667 }
668 GNUNET_asprintf (&attr_trailer, "%s.%s", issuer_attribute, attr_trailer);
669 return attr_trailer;
670}
671
672
673static int
674handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry,
675 struct DelegationSetQueueEntry *match_entry,
676 struct VerifyRequestHandle *vrh)
677{
678 struct DelegationSetQueueEntry *old_fw_parent;
679 struct DelegationSetQueueEntry *fw_entry = actual_entry;
680 struct DelegationSetQueueEntry *last_entry = match_entry;
681 // parent fixing, combine backward and forward chain parts
682 while (NULL != fw_entry->parent_queue_entry)
683 {
684 old_fw_parent = fw_entry->parent_queue_entry->parent_set;
685 // set parent
686 fw_entry->parent_queue_entry->parent_set = last_entry;
687
688 last_entry = fw_entry;
689 fw_entry = old_fw_parent;
690 }
691 // set last entry of chain as actual_entry
692 // actual_entry = last_entry;
693 // set refcount, loop all delegations
694 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
695 del_entry != NULL;
696 del_entry = del_entry->next)
697 {
698 if (0 != memcmp (&last_entry->delegation_chain_entry->subject_key,
699 &del_entry->delegate->issuer_key,
700 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
701 continue;
702 if (0 != strcmp (last_entry->delegation_chain_entry->subject_attribute,
703 del_entry->delegate->issuer_attribute))
704 continue;
705
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n");
707 // increase refcount of the start delegation
708 del_entry->refcount++;
709 }
710 // backtrack
711 for (struct DelegationSetQueueEntry *tmp_set = last_entry;
712 NULL != tmp_set->parent_queue_entry;
713 tmp_set = tmp_set->parent_queue_entry->parent_set)
714 {
715 tmp_set->parent_queue_entry->required_solutions--;
716
717 // add new found entry to vrh
718 vrh->delegation_chain_size++;
719 GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head,
720 vrh->delegation_chain_tail,
721 tmp_set->delegation_chain_entry);
722
723 // if one node on the path still needs solutions, this current
724 // patch cannot fulfill the conditions and therefore stops here
725 // however, it is in the vrh and can be used by the other paths
726 // related to this path/collection/verification
727 if (0 < tmp_set->parent_queue_entry->required_solutions)
728 {
729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
730 "Chain requires more solutions, waiting...\n");
731 return GNUNET_NO;
732 }
733 }
734 return GNUNET_YES;
735}
736
737
738static void
739forward_resolution (void *cls,
740 uint32_t rd_count,
741 const struct GNUNET_GNSRECORD_Data *rd)
742{
743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
744
745 struct VerifyRequestHandle *vrh;
746 struct DelegationSetQueueEntry *current_set;
747 struct DelegationSetQueueEntry *ds_entry;
748 struct DelegationQueueEntry *dq_entry;
749
750 current_set = cls;
751 // set handle to NULL (as el = NULL)
752 current_set->lookup_request = NULL;
753 vrh = current_set->handle;
754 vrh->pending_lookups--;
755
756 // Loop record entries
757 for (uint32_t i = 0; i < rd_count; i++)
758 {
759 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
760 continue;
761
762 // Start deserialize into Delegate
763 struct GNUNET_ABD_Delegate *del;
764 del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
765
766 // Start: Create DQ Entry
767 dq_entry = GNUNET_new (struct DelegationQueueEntry);
768 // AND delegations are not possible, only 1 solution
769 dq_entry->required_solutions = 1;
770 dq_entry->parent_set = current_set;
771
772 // Insert it into the current set
773 GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head,
774 current_set->queue_entries_tail,
775 dq_entry);
776
777 // Start: Create DS Entry
778 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
779 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
780 ds_entry->from_bw = false;
781
782 // (1) A.a <- A.b.c
783 // (2) A.b <- D.d
784 // (3) D.d <- E
785 // (4) E.c <- F.c
786 // (5) F.c <- G
787 // Possibilities:
788 // 1. complete match: trailer = 0, validate
789 // 2. partial match: replace
790 // 3. new solution: replace, add trailer
791
792 // At resolution chain start trailer of parent is NULL
793 if (NULL == current_set->attr_trailer)
794 {
795 // for (5) F.c <- G, remember .c when going upwards
796 ds_entry->attr_trailer = GNUNET_strdup (del->issuer_attribute);
797 }
798 else
799 {
800 if (0 == del->subject_attribute_len)
801 {
802 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: New solution\n");
803 // new solution
804 // create new trailer del->issuer_attribute, ds_entry->attr_trailer
805 GNUNET_asprintf (&ds_entry->attr_trailer,
806 "%s.%s",
807 del->issuer_attribute,
808 current_set->attr_trailer);
809 }
810 else if (0 == strcmp (del->subject_attribute, current_set->attr_trailer))
811 {
812 // complete match
813 // new trailer == issuer attribute (e.g. (5) to (4))
814 ds_entry->attr_trailer = GNUNET_strdup (del->issuer_attribute);
815 }
816 else
817 {
818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: Partial match\n");
819 // partial match
820
821 char *trail = partial_match (GNUNET_strdup (current_set->attr_trailer),
822 GNUNET_strdup (del->subject_attribute),
823 current_set->attr_trailer,
824 GNUNET_strdup (del->issuer_attribute));
825
826 // if null: skip this record entry (reasons: mismatch or overmatch, both not relevant)
827 if (NULL == trail)
828 {
829 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
830 "Entry not relevant, discarding: %s.%s <- %s.%s\n",
831 GNUNET_CRYPTO_ecdsa_public_key_to_string (
832 &del->issuer_key),
833 del->issuer_attribute,
834 GNUNET_CRYPTO_ecdsa_public_key_to_string (
835 &del->subject_key),
836 del->subject_attribute);
837 continue;
838 }
839 else
840 ds_entry->attr_trailer = trail;
841 }
842 }
843
844
845 // Start: Credential Chain Entry
846 // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject)
847 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
848 GNUNET_memcpy (ds_entry->issuer_key,
849 &del->subject_key,
850 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
851
852 ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry);
853 ds_entry->delegation_chain_entry->subject_key = del->subject_key;
854 if (0 < del->subject_attribute_len)
855 ds_entry->delegation_chain_entry->subject_attribute =
856 GNUNET_strdup (del->subject_attribute);
857 ds_entry->delegation_chain_entry->issuer_key = del->issuer_key;
858 ds_entry->delegation_chain_entry->issuer_attribute =
859 GNUNET_strdup (del->issuer_attribute);
860
861 // Found new entry, repoting intermediate result
862 send_intermediate_response (vrh, ds_entry->delegation_chain_entry, false);
863
864 // current delegation as parent
865 ds_entry->parent_queue_entry = dq_entry;
866
867 // Check for solution
868 // if: issuer key we looking for
869 if (0 == memcmp (&del->issuer_key,
870 &vrh->issuer_key,
871 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
872 {
873 // if: issuer attr we looking for
874 if (0 == strcmp (del->issuer_attribute, vrh->issuer_attribute))
875 {
876 // if: complete match, meaning new trailer == issuer attr
877 if (0 == strcmp (vrh->issuer_attribute, ds_entry->attr_trailer))
878 {
879 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: Solution\n");
880
881 // Add found solution into delegation_chain
882 struct DelegationSetQueueEntry *tmp_set;
883 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
884 tmp_set = tmp_set->parent_queue_entry->parent_set)
885 {
886 if (NULL != tmp_set->delegation_chain_entry)
887 {
888 vrh->delegation_chain_size++;
889 GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head,
890 vrh->delegation_chain_tail,
891 tmp_set->delegation_chain_entry);
892 }
893 }
894
895 // Increase refcount for this delegate
896 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
897 del_entry != NULL;
898 del_entry = del_entry->next)
899 {
900 if (0 == memcmp (&del_entry->delegate->issuer_key,
901 &vrh->delegation_chain_head->subject_key,
902 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
903 {
904 if (0 == strcmp (del_entry->delegate->issuer_attribute,
905 vrh->delegation_chain_head->subject_attribute))
906 {
907 del_entry->refcount++;
908 }
909 }
910 }
911
912 send_lookup_response (vrh);
913 return;
914 }
915 }
916 }
917
918 // Check for bidirectional crossmatch
919 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
920 del_entry != NULL;
921 del_entry = del_entry->next)
922 {
923 // only check entries not by backward algorithm
924 if (del_entry->from_bw)
925 {
926 // key of list entry matches actual key
927 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
928 &ds_entry->delegation_chain_entry->issuer_key,
929 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
930 {
931 // compare entry subject attributes to this trailer (iss attr + old trailer)
932 if (0 == strcmp (del_entry->unresolved_attribute_delegation,
933 ds_entry->attr_trailer))
934 {
935 print_deleset (del_entry, "Forward:");
936 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
937 "Forward: Found match with above!\n");
938
939 // one node on the path still needs solutions: return
940 if (GNUNET_NO ==
941 handle_bidirectional_match (ds_entry, del_entry, vrh))
942 return;
943
944 send_lookup_response (vrh);
945 return;
946 }
947 }
948 }
949 }
950
951 // Starting a new GNS lookup
952 vrh->pending_lookups++;
953 ds_entry->handle = vrh;
954
955 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
956 "Starting to look up trailer %s in zone %s\n",
957 ds_entry->attr_trailer,
958 GNUNET_CRYPTO_ecdsa_public_key_to_string (&del->issuer_key));
959
960 ds_entry->lookup_request =
961 GNUNET_GNS_lookup (gns,
962 GNUNET_GNS_EMPTY_LABEL_AT,
963 &del->issuer_key,
964 GNUNET_GNSRECORD_TYPE_DELEGATE,
965 GNUNET_GNS_LO_DEFAULT,
966 &forward_resolution,
967 ds_entry);
968 }
969
970 if (0 == vrh->pending_lookups)
971 {
972 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
973 send_lookup_response (vrh);
974 return;
975 }
976}
977
978
979static void
980backward_resolution (void *cls,
981 uint32_t rd_count,
982 const struct GNUNET_GNSRECORD_Data *rd)
983{
984 struct VerifyRequestHandle *vrh;
985 const struct GNUNET_ABD_DelegationRecord *sets;
986 struct DelegateRecordEntry *del_pointer;
987 struct DelegationSetQueueEntry *current_set;
988 struct DelegationSetQueueEntry *ds_entry;
989 struct DelegationSetQueueEntry *tmp_set;
990 struct DelegationQueueEntry *dq_entry;
991 char *expanded_attr;
992 char *lookup_attribute;
993
994 current_set = cls;
995 current_set->lookup_request = NULL;
996 vrh = current_set->handle;
997 vrh->pending_lookups--;
998
999 // Each OR
1000 for (uint32_t i = 0; i < rd_count; i++)
1001 {
1002 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
1003 continue;
1004
1005 sets = rd[i].data;
1006 struct GNUNET_ABD_DelegationSet set[ntohl (sets->set_count)];
1007 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1008 "Found new attribute delegation with %d sets. Creating new Job...\n",
1009 ntohl (sets->set_count));
1010
1011 if (GNUNET_OK !=
1012 GNUNET_ABD_delegation_set_deserialize (GNUNET_ntohll (
1013 sets->data_size),
1014 (const char *) &sets[1],
1015 ntohl (sets->set_count),
1016 set))
1017 {
1018 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to deserialize!\n");
1019 continue;
1020 }
1021 dq_entry = GNUNET_new (struct DelegationQueueEntry);
1022 dq_entry->required_solutions = ntohl (sets->set_count);
1023 dq_entry->parent_set = current_set;
1024
1025 GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head,
1026 current_set->queue_entries_tail,
1027 dq_entry);
1028 // Each AND
1029 for (uint32_t j = 0; j < ntohl (sets->set_count); j++)
1030 {
1031 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1032 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1033 ds_entry->from_bw = true;
1034
1035 if (NULL != current_set->attr_trailer)
1036 {
1037 if (0 == set[j].subject_attribute_len)
1038 {
1039 GNUNET_asprintf (&expanded_attr, "%s", current_set->attr_trailer);
1040 }
1041 else
1042 {
1043 GNUNET_asprintf (&expanded_attr,
1044 "%s.%s",
1045 set[j].subject_attribute,
1046 current_set->attr_trailer);
1047 }
1048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expanded to %s\n", expanded_attr);
1049 ds_entry->unresolved_attribute_delegation = expanded_attr;
1050 }
1051 else
1052 {
1053 if (0 != set[j].subject_attribute_len)
1054 {
1055 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1056 "Not Expanding %s\n",
1057 set[j].subject_attribute);
1058 ds_entry->unresolved_attribute_delegation =
1059 GNUNET_strdup (set[j].subject_attribute);
1060 }
1061 }
1062
1063 // Add a credential chain entry
1064 ds_entry->delegation_chain_entry =
1065 GNUNET_new (struct DelegationChainEntry);
1066 ds_entry->delegation_chain_entry->subject_key = set[j].subject_key;
1067 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
1068 GNUNET_memcpy (ds_entry->issuer_key,
1069 &set[j].subject_key,
1070 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
1071 if (0 < set[j].subject_attribute_len)
1072 ds_entry->delegation_chain_entry->subject_attribute =
1073 GNUNET_strdup (set[j].subject_attribute);
1074 ds_entry->delegation_chain_entry->issuer_key = *current_set->issuer_key;
1075 ds_entry->delegation_chain_entry->issuer_attribute =
1076 GNUNET_strdup (current_set->lookup_attribute);
1077
1078 // Found new entry, repoting intermediate result
1079 send_intermediate_response (vrh, ds_entry->delegation_chain_entry, true);
1080
1081 ds_entry->parent_queue_entry = dq_entry; // current_delegation;
1082
1083 /**
1084 * Check if this delegation already matches one of our credentials
1085 */
1086 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking for cred match\n");
1087
1088 for (del_pointer = vrh->del_chain_head; del_pointer != NULL;
1089 del_pointer = del_pointer->next)
1090 {
1091 // If key and attribute match credential: continue and backtrack
1092 if (0 != memcmp (&set[j].subject_key,
1093 &del_pointer->delegate->issuer_key,
1094 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1095 continue;
1096 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1097 "Checking if %s matches %s\n",
1098 ds_entry->unresolved_attribute_delegation,
1099 del_pointer->delegate->issuer_attribute);
1100
1101 if (0 != strcmp (ds_entry->unresolved_attribute_delegation,
1102 del_pointer->delegate->issuer_attribute))
1103 continue;
1104
1105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found issuer\n");
1106 // increase refcount of the start delegation
1107 del_pointer->refcount++;
1108
1109 // Backtrack
1110 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
1111 tmp_set = tmp_set->parent_queue_entry->parent_set)
1112 {
1113 tmp_set->parent_queue_entry->required_solutions--;
1114 if (NULL != tmp_set->delegation_chain_entry)
1115 {
1116 vrh->delegation_chain_size++;
1117 GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head,
1118 vrh->delegation_chain_tail,
1119 tmp_set->delegation_chain_entry);
1120 }
1121 if (0 < tmp_set->parent_queue_entry->required_solutions)
1122 break;
1123 }
1124
1125 // if the break above is not called the condition of the for is met
1126 if (NULL == tmp_set->parent_queue_entry)
1127 {
1128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n");
1129 // Found match
1130 send_lookup_response (vrh);
1131 return;
1132 }
1133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not all solutions found yet.\n");
1134 continue;
1135 }
1136
1137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1138 "Building new lookup request from %s\n",
1139 ds_entry->unresolved_attribute_delegation);
1140 // Continue with next/new backward resolution
1141 char issuer_attribute_name[strlen (
1142 ds_entry->unresolved_attribute_delegation)
1143 + 1];
1144 strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation);
1145 char *next_attr = strtok (issuer_attribute_name, ".");
1146 if (NULL == next_attr)
1147 {
1148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1149 "Failed to parse next attribute\n");
1150 continue;
1151 }
1152 GNUNET_asprintf (&lookup_attribute, "%s", next_attr);
1153 GNUNET_asprintf (&ds_entry->lookup_attribute, "%s", next_attr);
1154 if (strlen (next_attr) ==
1155 strlen (ds_entry->unresolved_attribute_delegation))
1156 {
1157 ds_entry->attr_trailer = NULL;
1158 }
1159 else
1160 {
1161 next_attr += strlen (next_attr) + 1;
1162 ds_entry->attr_trailer = GNUNET_strdup (next_attr);
1163 }
1164
1165 // Check for bidirectional crossmatch
1166 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
1167 del_entry != NULL;
1168 del_entry = del_entry->next)
1169 {
1170 // only check entries added by forward algorithm
1171 if (! del_entry->from_bw)
1172 {
1173 // key of list entry matches actual key
1174 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1175 &ds_entry->delegation_chain_entry->subject_key,
1176 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1177 {
1178 // compare entry subject attributes to this trailer (iss attr + old trailer)
1179 if (0 == strcmp (del_entry->attr_trailer,
1180 ds_entry->unresolved_attribute_delegation))
1181 {
1182 print_deleset (del_entry, "Backward:");
1183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1184 "Backward: Found match with above!\n");
1185
1186 // if one node on the path still needs solutions: return
1187 if (GNUNET_NO ==
1188 handle_bidirectional_match (del_entry, ds_entry, vrh))
1189 break;
1190
1191 // Send lookup response
1192 send_lookup_response (vrh);
1193 return;
1194 }
1195 }
1196 }
1197 }
1198
1199 // Starting a new GNS lookup
1200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1201 "Looking up %s\n",
1202 ds_entry->lookup_attribute);
1203 if (NULL != ds_entry->attr_trailer)
1204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1205 "%s still to go...\n",
1206 ds_entry->attr_trailer);
1207
1208 vrh->pending_lookups++;
1209 ds_entry->handle = vrh;
1210 ds_entry->lookup_request =
1211 GNUNET_GNS_lookup (gns,
1212 lookup_attribute,
1213 ds_entry->issuer_key, // issuer_key,
1214 GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
1215 GNUNET_GNS_LO_DEFAULT,
1216 &backward_resolution,
1217 ds_entry);
1218
1219 GNUNET_free (lookup_attribute);
1220 }
1221 }
1222
1223 if (0 == vrh->pending_lookups)
1224 {
1225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
1226 send_lookup_response (vrh);
1227 return;
1228 }
1229}
1230
1231
1232/**
1233 * Result from GNS lookup.
1234 *
1235 * @param cls the closure (our client lookup handle)
1236 */
1237static int
1238delegation_chain_bw_resolution_start (void *cls)
1239{
1240 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Backward Resolution...\n");
1241
1242 struct VerifyRequestHandle *vrh = cls;
1243 struct DelegationSetQueueEntry *ds_entry;
1244 struct DelegateRecordEntry *del_entry;
1245
1246 if (0 == vrh->del_chain_size)
1247 {
1248 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegates found\n");
1249 send_lookup_response (vrh);
1250 return 1;
1251 }
1252
1253 // Pre-check with vrh->dele_chain_.. if match issuer_key
1254 // Backward: check every cred entry if match issuer key
1255 // otherwise: start at issuer and go down till match
1256 // A.a <- ...
1257 // X.x <- C
1258 // Y.y <- C
1259 // if not X.x or Y.y == A.a start at A
1260 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1261 del_entry = del_entry->next)
1262 {
1263 if (0 != memcmp (&del_entry->delegate->issuer_key,
1264 &vrh->issuer_key,
1265 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1266 continue;
1267 if (0 !=
1268 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1269 continue;
1270 del_entry->refcount++;
1271 // Found match prematurely
1272 send_lookup_response (vrh);
1273 return 1;
1274 }
1275
1276
1277 // Check for attributes from the issuer and follow the chain
1278 // till you get the required subject's attributes
1279 char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
1280 strcpy (issuer_attribute_name, vrh->issuer_attribute);
1281 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1282 "Looking up %s\n",
1283 issuer_attribute_name);
1284 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1285 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1286 ds_entry->from_bw = true;
1287 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
1288 GNUNET_memcpy (ds_entry->issuer_key,
1289 &vrh->issuer_key,
1290 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
1291 ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute);
1292
1293 ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry);
1294 ds_entry->delegation_chain_entry->issuer_key = vrh->issuer_key;
1295 ds_entry->delegation_chain_entry->issuer_attribute =
1296 GNUNET_strdup (vrh->issuer_attribute);
1297
1298 ds_entry->handle = vrh;
1299 ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
1300 ds_entry->unresolved_attribute_delegation = NULL;
1301 vrh->pending_lookups = 1;
1302
1303 // Start with backward resolution
1304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Backward Resolution\n");
1305
1306 ds_entry->lookup_request = GNUNET_GNS_lookup (gns,
1307 issuer_attribute_name,
1308 &vrh->issuer_key, // issuer_key,
1309 GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
1310 GNUNET_GNS_LO_DEFAULT,
1311 &backward_resolution,
1312 ds_entry);
1313 return 0;
1314}
1315
1316
1317static int
1318delegation_chain_fw_resolution_start (void *cls)
1319{
1320 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Forward Resolution...\n");
1321
1322 struct VerifyRequestHandle *vrh = cls;
1323 struct DelegationSetQueueEntry *ds_entry;
1324 struct DelegateRecordEntry *del_entry;
1325
1326 // set to 0 and increase on each lookup: for fw multiple lookups (may be) started
1327 vrh->pending_lookups = 0;
1328
1329 if (0 == vrh->del_chain_size)
1330 {
1331 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n");
1332 send_lookup_response (vrh);
1333 return 1;
1334 }
1335
1336 // Pre-check with vrh->dele_chain_.. if match issuer_key
1337 // otherwise FW: start multiple lookups for each vrh->dele_chain
1338 // A.a <- ...
1339 // X.x <- C
1340 // Y.y <- C
1341 // if not X.x or Y.y == A.a start at X and at Y
1342 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1343 del_entry = del_entry->next)
1344 {
1345 if (0 != memcmp (&del_entry->delegate->issuer_key,
1346 &vrh->issuer_key,
1347 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1348 continue;
1349 if (0 !=
1350 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1351 continue;
1352 del_entry->refcount++;
1353 // Found match prematurely
1354 send_lookup_response (vrh);
1355 return 1;
1356 }
1357
1358 // None match, therefore start for every delegation found a lookup chain
1359 // Return and end collect process on first chain iss <-> sub found
1360
1361 // ds_entry created belongs to the first lookup, vrh still has the
1362 // issuer+attr we look for
1363 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1364 del_entry = del_entry->next)
1365 {
1366
1367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1368 "Looking for %s.%s\n",
1369 GNUNET_CRYPTO_ecdsa_public_key_to_string (
1370 &del_entry->delegate->issuer_key),
1371 del_entry->delegate->issuer_attribute);
1372
1373 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1374 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1375 ds_entry->from_bw = false;
1376 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
1377 GNUNET_memcpy (ds_entry->issuer_key,
1378 &del_entry->delegate->subject_key,
1379 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
1380
1381 ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry);
1382 ds_entry->delegation_chain_entry->subject_key =
1383 del_entry->delegate->subject_key;
1384 ds_entry->delegation_chain_entry->subject_attribute = NULL;
1385 ds_entry->delegation_chain_entry->issuer_key =
1386 del_entry->delegate->issuer_key;
1387 ds_entry->delegation_chain_entry->issuer_attribute =
1388 GNUNET_strdup (del_entry->delegate->issuer_attribute);
1389
1390 ds_entry->attr_trailer =
1391 GNUNET_strdup (del_entry->delegate->issuer_attribute);
1392 ds_entry->handle = vrh;
1393
1394 vrh->pending_lookups++;
1395 // Start with forward resolution
1396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n");
1397
1398 ds_entry->lookup_request =
1399 GNUNET_GNS_lookup (gns,
1400 GNUNET_GNS_EMPTY_LABEL_AT,
1401 &del_entry->delegate->issuer_key, // issuer_key,
1402 GNUNET_GNSRECORD_TYPE_DELEGATE,
1403 GNUNET_GNS_LO_DEFAULT,
1404 &forward_resolution,
1405 ds_entry);
1406 }
1407 return 0;
1408}
1409
1410
1411static int
1412check_verify (void *cls, const struct VerifyMessage *v_msg)
1413{
1414 size_t msg_size;
1415 const char *attr;
1416
1417 msg_size = ntohs (v_msg->header.size);
1418 if (msg_size < sizeof (struct VerifyMessage))
1419 {
1420 GNUNET_break (0);
1421 return GNUNET_SYSERR;
1422 }
1423 if (ntohs (v_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1424 {
1425 GNUNET_break (0);
1426 return GNUNET_SYSERR;
1427 }
1428 attr = (const char *) &v_msg[1];
1429
1430 if (strlen (attr) > GNUNET_ABD_MAX_LENGTH)
1431 {
1432 GNUNET_break (0);
1433 return GNUNET_SYSERR;
1434 }
1435 return GNUNET_OK;
1436}
1437
1438
1439static void
1440handle_verify (void *cls, const struct VerifyMessage *v_msg)
1441{
1442 struct VerifyRequestHandle *vrh;
1443 struct GNUNET_SERVICE_Client *client = cls;
1444 struct DelegateRecordEntry *del_entry;
1445 uint32_t delegate_count;
1446 uint32_t delegate_data_size;
1447 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1448 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1449 char *attrptr = attr;
1450 char *delegate_data;
1451 const char *utf_in;
1452
1453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n");
1454 utf_in = (const char *) &v_msg[1];
1455 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1456 GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len));
1457 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
1458 vrh = GNUNET_new (struct VerifyRequestHandle);
1459 vrh->is_collect = false;
1460 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
1461 vrh->client = client;
1462 vrh->request_id = v_msg->id;
1463 vrh->issuer_key = v_msg->issuer_key;
1464 vrh->subject_key = v_msg->subject_key;
1465 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1466 vrh->resolution_algo = ntohs (v_msg->resolution_algo);
1467
1468 vrh->del_chain_head = NULL;
1469 vrh->del_chain_tail = NULL;
1470 vrh->dsq_head = NULL;
1471 vrh->dsq_tail = NULL;
1472 vrh->del_chain_head = NULL;
1473 vrh->del_chain_tail = NULL;
1474
1475 GNUNET_SERVICE_client_continue (vrh->client);
1476 if (0 == strlen (issuer_attribute))
1477 {
1478 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1479 send_lookup_response (vrh);
1480 return;
1481 }
1482
1483 // Parse delegates from verifaction message
1484 delegate_count = ntohl (v_msg->d_count);
1485 delegate_data_size = ntohs (v_msg->header.size)
1486 - sizeof (struct VerifyMessage)
1487 - ntohs (v_msg->issuer_attribute_len) - 1;
1488 struct GNUNET_ABD_Delegate delegates[delegate_count];
1489 memset (delegates,
1490 0,
1491 sizeof (struct GNUNET_ABD_Delegate) * delegate_count);
1492 delegate_data = (char *) &v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
1493 if (GNUNET_OK != GNUNET_ABD_delegates_deserialize (delegate_data_size,
1494 delegate_data,
1495 delegate_count,
1496 delegates))
1497 {
1498 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n");
1499 send_lookup_response (vrh);
1500 return;
1501 }
1502
1503 // Prepare vrh delegation chain for later validation
1504 for (uint32_t i = 0; i < delegate_count; i++)
1505 {
1506 del_entry = GNUNET_new (struct DelegateRecordEntry);
1507 del_entry->delegate =
1508 GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate)
1509 + delegates[i].issuer_attribute_len + 1);
1510 GNUNET_memcpy (del_entry->delegate,
1511 &delegates[i],
1512 sizeof (struct GNUNET_ABD_Delegate));
1513 GNUNET_memcpy (&del_entry->delegate[1],
1514 delegates[i].issuer_attribute,
1515 delegates[i].issuer_attribute_len);
1516 del_entry->delegate->issuer_attribute_len =
1517 delegates[i].issuer_attribute_len;
1518 del_entry->delegate->issuer_attribute = (char *) &del_entry->delegate[1];
1519 GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
1520 vrh->del_chain_tail,
1521 del_entry);
1522 vrh->del_chain_size++;
1523 }
1524
1525 // Switch resolution algo
1526 if (GNUNET_ABD_FLAG_BACKWARD & vrh->resolution_algo &&
1527 GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo)
1528 {
1529 if (1 == delegation_chain_fw_resolution_start (vrh))
1530 return;
1531 delegation_chain_bw_resolution_start (vrh);
1532 }
1533 else if (GNUNET_ABD_FLAG_BACKWARD & vrh->resolution_algo)
1534 {
1535 delegation_chain_bw_resolution_start (vrh);
1536 }
1537 else if (GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo)
1538 {
1539 delegation_chain_fw_resolution_start (vrh);
1540 }
1541}
1542
1543
1544static void
1545handle_delegate_collection_error_cb (void *cls)
1546{
1547 struct VerifyRequestHandle *vrh = cls;
1548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1549 "Got disconnected from namestore database.\n");
1550 vrh->dele_qe = NULL;
1551 send_lookup_response (vrh);
1552}
1553
1554
1555static void
1556delegate_collection_finished (void *cls)
1557{
1558 struct VerifyRequestHandle *vrh = cls;
1559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n");
1560
1561 // if both are set: bidirectional search, meaning start both chain resolutions
1562 if (GNUNET_ABD_FLAG_BACKWARD & vrh->resolution_algo &&
1563 GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo)
1564 {
1565 // if premature match found don't start bw resolution
1566 if (1 == delegation_chain_fw_resolution_start (vrh))
1567 return;
1568 delegation_chain_bw_resolution_start (vrh);
1569 }
1570 else if (GNUNET_ABD_FLAG_BACKWARD & vrh->resolution_algo)
1571 {
1572 delegation_chain_bw_resolution_start (vrh);
1573 }
1574 else if (GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo)
1575 {
1576 delegation_chain_fw_resolution_start (vrh);
1577 }
1578}
1579
1580
1581static void
1582handle_delegate_collection_cb (void *cls,
1583 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
1584 const char *label,
1585 unsigned int rd_count,
1586 const struct GNUNET_GNSRECORD_Data *rd)
1587{
1588 struct VerifyRequestHandle *vrh = cls;
1589 struct GNUNET_ABD_Delegate *del;
1590 struct DelegateRecordEntry *del_entry;
1591 int cred_record_count;
1592 cred_record_count = 0;
1593 vrh->dele_qe = NULL;
1594
1595 for (uint32_t i = 0; i < rd_count; i++)
1596 {
1597 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
1598 continue;
1599 cred_record_count++;
1600 del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
1601 if (NULL == del)
1602 {
1603 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
1604 continue;
1605 }
1606 // only add the entries that are explicitly marked as private
1607 // and therefore symbolize the end of a chain
1608 if (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)
1609 {
1610 del_entry = GNUNET_new (struct DelegateRecordEntry);
1611 del_entry->delegate = del;
1612 GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
1613 vrh->del_chain_tail,
1614 del_entry);
1615 vrh->del_chain_size++;
1616 }
1617 }
1618
1619 delegate_collection_finished (vrh);
1620}
1621
1622
1623static void
1624handle_collect (void *cls, const struct CollectMessage *c_msg)
1625{
1626 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1627 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1628 struct VerifyRequestHandle *vrh;
1629 struct GNUNET_SERVICE_Client *client = cls;
1630 char *attrptr = attr;
1631 const char *utf_in;
1632
1633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received COLLECT message\n");
1634
1635 utf_in = (const char *) &c_msg[1];
1636 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1637
1638 GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len));
1639 issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
1640 vrh = GNUNET_new (struct VerifyRequestHandle);
1641 vrh->is_collect = true;
1642 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
1643 vrh->client = client;
1644 vrh->request_id = c_msg->id;
1645 vrh->issuer_key = c_msg->issuer_key;
1646 GNUNET_CRYPTO_ecdsa_key_get_public (&c_msg->subject_key, &vrh->subject_key);
1647 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1648 vrh->resolution_algo = ntohs (c_msg->resolution_algo);
1649
1650 vrh->del_chain_head = NULL;
1651 vrh->del_chain_tail = NULL;
1652 vrh->dsq_head = NULL;
1653 vrh->dsq_tail = NULL;
1654 vrh->del_chain_head = NULL;
1655 vrh->del_chain_tail = NULL;
1656
1657 if (0 == strlen (issuer_attribute))
1658 {
1659 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1660 send_lookup_response (vrh);
1661 return;
1662 }
1663 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n");
1664
1665 // Get all delegates from subject
1666 vrh->dele_qe =
1667 GNUNET_NAMESTORE_records_lookup (namestore,
1668 &c_msg->subject_key,
1669 GNUNET_GNS_EMPTY_LABEL_AT,
1670 &handle_delegate_collection_error_cb,
1671 vrh,
1672 &handle_delegate_collection_cb,
1673 vrh);
1674 GNUNET_SERVICE_client_continue (vrh->client);
1675}
1676
1677
1678static int
1679check_collect (void *cls, const struct CollectMessage *c_msg)
1680{
1681 size_t msg_size;
1682 const char *attr;
1683
1684 msg_size = ntohs (c_msg->header.size);
1685 if (msg_size < sizeof (struct CollectMessage))
1686 {
1687 GNUNET_break (0);
1688 return GNUNET_SYSERR;
1689 }
1690 if (ntohs (c_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1691 {
1692 GNUNET_break (0);
1693 return GNUNET_SYSERR;
1694 }
1695 attr = (const char *) &c_msg[1];
1696
1697 if (('\0' != attr[msg_size - sizeof (struct CollectMessage) - 1]) ||
1698 (strlen (attr) > GNUNET_ABD_MAX_LENGTH))
1699 {
1700 GNUNET_break (0);
1701 return GNUNET_SYSERR;
1702 }
1703 return GNUNET_OK;
1704}
1705
1706
1707static void
1708client_disconnect_cb (void *cls,
1709 struct GNUNET_SERVICE_Client *client,
1710 void *app_ctx)
1711{
1712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1713}
1714
1715
1716static void *
1717client_connect_cb (void *cls,
1718 struct GNUNET_SERVICE_Client *client,
1719 struct GNUNET_MQ_Handle *mq)
1720{
1721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1722 return client;
1723}
1724
1725
1726/**
1727 * Process Credential requests.
1728 *
1729 * @param cls closure
1730 * @param c configuration to use
1731 * @param handle service handle
1732 */
1733static void
1734run (void *cls,
1735 const struct GNUNET_CONFIGURATION_Handle *c,
1736 struct GNUNET_SERVICE_Handle *handle)
1737{
1738
1739 gns = GNUNET_GNS_connect (c);
1740 if (NULL == gns)
1741 {
1742 fprintf (stderr, _ ("Failed to connect to GNS\n"));
1743 }
1744 namestore = GNUNET_NAMESTORE_connect (c);
1745 if (NULL == namestore)
1746 {
1747 fprintf (stderr, _ ("Failed to connect to namestore\n"));
1748 }
1749
1750 statistics = GNUNET_STATISTICS_create ("abd", c);
1751 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
1752}
1753
1754
1755/**
1756 * Define "main" method using service macro
1757 */
1758GNUNET_SERVICE_MAIN (
1759 "abd",
1760 GNUNET_SERVICE_OPTION_NONE,
1761 &run,
1762 &client_connect_cb,
1763 &client_disconnect_cb,
1764 NULL,
1765 GNUNET_MQ_hd_var_size (verify,
1766 GNUNET_MESSAGE_TYPE_ABD_VERIFY,
1767 struct VerifyMessage,
1768 NULL),
1769 GNUNET_MQ_hd_var_size (collect,
1770 GNUNET_MESSAGE_TYPE_ABD_COLLECT,
1771 struct CollectMessage,
1772 NULL),
1773 GNUNET_MQ_handler_end ());
1774
1775/* end of gnunet-service-abd.c */
diff --git a/src/abd/plugin_gnsrecord_abd.c b/src/abd/plugin_gnsrecord_abd.c
deleted file mode 100644
index 25dc20152..000000000
--- a/src/abd/plugin_gnsrecord_abd.c
+++ /dev/null
@@ -1,353 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20
21/**
22 * @file abd/plugin_gnsrecord_abd.c
23 * @brief gnsrecord plugin to provide the API for ABD records
24 * @author Martin Schanzenbach
25 */
26#include "platform.h"
27
28#include "gnunet_util_lib.h"
29
30#include "delegate_misc.h"
31#include "abd_serialization.h"
32#include "gnunet_abd_service.h"
33#include "gnunet_gnsrecord_lib.h"
34#include "gnunet_gnsrecord_plugin.h"
35#include "gnunet_signatures.h"
36/**
37 * Convert the 'value' of a record to a string.
38 *
39 * @param cls closure, unused
40 * @param type type of the record
41 * @param data value in binary encoding
42 * @param data_size number of bytes in @a data
43 * @return NULL on error, otherwise human-readable representation of the value
44 */
45static char *
46abd_value_to_string (void *cls,
47 uint32_t type,
48 const void *data,
49 size_t data_size)
50{
51 const char *cdata;
52
53 switch (type)
54 {
55 case GNUNET_GNSRECORD_TYPE_ATTRIBUTE:
56 {
57 struct GNUNET_ABD_DelegationRecord sets;
58 char *attr_str;
59 char *subject_pkey;
60 char *tmp_str;
61 int i;
62 if (data_size < sizeof (struct GNUNET_ABD_DelegationRecord))
63 return NULL; /* malformed */
64
65 GNUNET_memcpy (&sets, data, sizeof (sets));
66 cdata = data;
67
68 struct GNUNET_ABD_DelegationSet set[ntohl (sets.set_count)];
69 if (GNUNET_OK !=
70 GNUNET_ABD_delegation_set_deserialize (GNUNET_ntohll (
71 sets.data_size),
72 &cdata[sizeof (sets)],
73 ntohl (sets.set_count),
74 set))
75 return NULL;
76
77 for (i = 0; i < ntohl (sets.set_count); i++)
78 {
79 subject_pkey =
80 GNUNET_CRYPTO_ecdsa_public_key_to_string (&set[i].subject_key);
81
82 if (0 == set[i].subject_attribute_len)
83 {
84 if (0 == i)
85 {
86 GNUNET_asprintf (&attr_str, "%s", subject_pkey);
87 }
88 else
89 {
90 GNUNET_asprintf (&tmp_str, "%s,%s", attr_str, subject_pkey);
91 GNUNET_free (attr_str);
92 attr_str = tmp_str;
93 }
94 }
95 else
96 {
97 if (0 == i)
98 {
99 GNUNET_asprintf (&attr_str,
100 "%s %s",
101 subject_pkey,
102 set[i].subject_attribute);
103 }
104 else
105 {
106 GNUNET_asprintf (&tmp_str,
107 "%s,%s %s",
108 attr_str,
109 subject_pkey,
110 set[i].subject_attribute);
111 GNUNET_free (attr_str);
112 attr_str = tmp_str;
113 }
114 }
115 GNUNET_free (subject_pkey);
116 }
117 return attr_str;
118 }
119 case GNUNET_GNSRECORD_TYPE_DELEGATE:
120 {
121 struct GNUNET_ABD_Delegate *cred;
122 char *cred_str;
123
124 cred = GNUNET_ABD_delegate_deserialize (data, data_size);
125 cred_str = GNUNET_ABD_delegate_to_string (cred);
126 GNUNET_free (cred);
127 return cred_str;
128 }
129 default:
130 return NULL;
131 }
132}
133
134
135/**
136 * Convert human-readable version of a 'value' of a record to the binary
137 * representation.
138 *
139 * @param cls closure, unused
140 * @param type type of the record
141 * @param s human-readable string
142 * @param data set to value in binary encoding (will be allocated)
143 * @param data_size set to number of bytes in @a data
144 * @return #GNUNET_OK on success
145 */
146static int
147abd_string_to_value (void *cls,
148 uint32_t type,
149 const char *s,
150 void **data,
151 size_t *data_size)
152{
153 if (NULL == s)
154 return GNUNET_SYSERR;
155 switch (type)
156 {
157 case GNUNET_GNSRECORD_TYPE_ATTRIBUTE:
158 {
159 struct GNUNET_ABD_DelegationRecord *sets;
160 char attr_str[253 + 1];
161 char subject_pkey[52 + 1];
162 char *token;
163 char *tmp_str;
164 int matches = 0;
165 int entries;
166 size_t tmp_data_size;
167 int i;
168
169 tmp_str = GNUNET_strdup (s);
170 token = strtok (tmp_str, ",");
171 entries = 0;
172 tmp_data_size = 0;
173 *data_size = sizeof (struct GNUNET_ABD_DelegationRecord);
174 while (NULL != token)
175 {
176 // also fills the variables subject_pley and attr_str if "regex"-like match
177 matches = sscanf (token, "%s %s", subject_pkey, attr_str);
178
179 if (0 == matches)
180 {
181 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
182 _ ("Unable to parse ATTR record string `%s'\n"),
183 s);
184 GNUNET_free (tmp_str);
185 return GNUNET_SYSERR;
186 }
187
188 entries++;
189 token = strtok (NULL, ",");
190 }
191 GNUNET_free (tmp_str);
192
193 tmp_str = GNUNET_strdup (s);
194 token = strtok (tmp_str, ",");
195 if (NULL == token)
196 {
197 GNUNET_free (tmp_str);
198 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed string %s\n", s);
199 return GNUNET_SYSERR;
200 }
201
202 struct GNUNET_ABD_DelegationSet set[entries];
203 // sets memory to be 0, starting at *set for the size of struct * entries
204 memset (set, 0, sizeof (struct GNUNET_ABD_DelegationSet) * entries);
205 for (i = 0; i < entries; i++)
206 {
207 matches = sscanf (token, "%s %s", subject_pkey, attr_str);
208
209 // sets the public key for the set entry
210 GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pkey,
211 strlen (subject_pkey),
212 &set[i].subject_key);
213
214 // If not just key, also set subject attribute (Not A.a <- B but A.a <- B.b)
215 if (2 == matches)
216 {
217 set[i].subject_attribute_len = strlen (attr_str) + 1;
218 set[i].subject_attribute = GNUNET_strdup (attr_str);
219 }
220 // If more entries, then token string can take the next entry (separated by ',') by calling strtok again
221 token = strtok (NULL, ",");
222 }
223 tmp_data_size = GNUNET_ABD_delegation_set_get_size (entries, set);
224
225 if (-1 == tmp_data_size)
226 {
227 GNUNET_free (tmp_str);
228 return GNUNET_SYSERR;
229 }
230 *data_size += tmp_data_size;
231 *data = sets = GNUNET_malloc (*data_size);
232 GNUNET_ABD_delegation_set_serialize (entries,
233 set,
234 tmp_data_size,
235 (char *) &sets[1]);
236 for (i = 0; i < entries; i++)
237 {
238 if (0 != set[i].subject_attribute_len)
239 {
240 GNUNET_free_nz ((char *) set[i].subject_attribute);
241 set[i].subject_attribute = NULL;
242 }
243 }
244 sets->set_count = htonl (entries);
245 sets->data_size = GNUNET_htonll (tmp_data_size);
246
247 GNUNET_free (tmp_str);
248 return GNUNET_OK;
249 }
250 case GNUNET_GNSRECORD_TYPE_DELEGATE:
251 {
252 struct GNUNET_ABD_Delegate *cred;
253 cred = GNUNET_ABD_delegate_from_string (s);
254
255 *data_size = GNUNET_ABD_delegate_serialize (cred, (char **) data);
256
257 return GNUNET_OK;
258 }
259 default:
260 return GNUNET_SYSERR;
261 }
262}
263
264
265/**
266 * Mapping of record type numbers to human-readable
267 * record type names.
268 */
269static struct
270{
271 const char *name;
272 uint32_t number;
273} name_map[] = {{"ATTR", GNUNET_GNSRECORD_TYPE_ATTRIBUTE},
274 {"DEL", GNUNET_GNSRECORD_TYPE_DELEGATE},
275 {NULL, UINT32_MAX}};
276
277
278/**
279 * Convert a type name (e.g. "AAAA") to the corresponding number.
280 *
281 * @param cls closure, unused
282 * @param gns_typename name to convert
283 * @return corresponding number, UINT32_MAX on error
284 */
285static uint32_t
286abd_typename_to_number (void *cls, const char *gns_typename)
287{
288 unsigned int i;
289
290 i = 0;
291 while ((name_map[i].name != NULL) &&
292 (0 != strcasecmp (gns_typename, name_map[i].name)))
293 i++;
294 return name_map[i].number;
295}
296
297
298/**
299 * Convert a type number to the corresponding type string (e.g. 1 to "A")
300 *
301 * @param cls closure, unused
302 * @param type number of a type to convert
303 * @return corresponding typestring, NULL on error
304 */
305static const char *
306abd_number_to_typename (void *cls, uint32_t type)
307{
308 unsigned int i;
309
310 i = 0;
311 while ((name_map[i].name != NULL) && (type != name_map[i].number))
312 i++;
313 return name_map[i].name;
314}
315
316
317/**
318 * Entry point for the plugin.
319 *
320 * @param cls NULL
321 * @return the exported block API
322 */
323void *
324libgnunet_plugin_gnsrecord_abd_init (void *cls)
325{
326 struct GNUNET_GNSRECORD_PluginFunctions *api;
327
328 api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions);
329 api->value_to_string = &abd_value_to_string;
330 api->string_to_value = &abd_string_to_value;
331 api->typename_to_number = &abd_typename_to_number;
332 api->number_to_typename = &abd_number_to_typename;
333 return api;
334}
335
336
337/**
338 * Exit point from the plugin.
339 *
340 * @param cls the return value from #libgnunet_plugin_block_test_init
341 * @return NULL
342 */
343void *
344libgnunet_plugin_gnsrecord_abd_done (void *cls)
345{
346 struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
347
348 GNUNET_free (api);
349 return NULL;
350}
351
352
353/* end of plugin_gnsrecord_abd.c */
diff --git a/src/abd/test_abd_bi_and.sh b/src/abd/test_abd_bi_and.sh
deleted file mode 100755
index b32313636..000000000
--- a/src/abd/test_abd_bi_and.sh
+++ /dev/null
@@ -1,98 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31gnunet-identity -C h -c test_abd_lookup.conf
32AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
33BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
34CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
35DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
36EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
37FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
38GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
39HKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep h | awk '{print $3}')
40gnunet-identity -d
41
42# (1) (A.a) <- B.b
43# (2) (B.b) <- C.c AND G.g
44# (3) C.c <- (D.D)
45# (4) D.d <- (E.e)
46# (5) E.e <- (F) priv
47# (6) (G.g) <- H.h
48# (7) H.h <- (F) priv
49
50# BIDIRECTIONAL
51gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
52gnunet-namestore -D -z a
53gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
54gnunet-namestore -D -z b
55gnunet-abd --createIssuerSide --ego=g --attribute="g" --subject="$HKEY h" --ttl=5m -c test_abd_lookup.conf
56gnunet-namestore -D -z b
57
58SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
59gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
60gnunet-namestore -D -z d
61SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
62gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
63gnunet-namestore -D -z e
64SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
65gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
66gnunet-namestore -D -z f
67SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=h --attribute="h" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
68gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
69gnunet-namestore -D -z h
70
71# Starting to resolve
72echo "+++ Starting to Resolve +++"
73
74DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
75echo $DELS
76echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
77gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
78
79RES=$?
80
81# Cleanup properly
82gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
83gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
84gnunet-namestore -z g -d -n "g" -t ATTR -c test_abd_lookup.conf
85gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
86gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
87gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
88
89gnunet-arm -e -c test_abd_lookup.conf
90
91if [ "$RES" == 0 ]
92then
93 exit 0
94else
95 echo "FAIL: Failed to verify credential."
96 exit 1
97fi
98
diff --git a/src/abd/test_abd_bi_and2.sh b/src/abd/test_abd_bi_and2.sh
deleted file mode 100755
index 8d1601ef4..000000000
--- a/src/abd/test_abd_bi_and2.sh
+++ /dev/null
@@ -1,94 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31gnunet-identity -C h -c test_abd_lookup.conf
32AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
33BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
34CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
35DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
36EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
37FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
38GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
39HKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep h | awk '{print $3}')
40gnunet-identity -d
41
42# (1) (A.a) <- B.b
43# (2) (B.b) <- C.c AND G.g
44# (3) C.c <- (D.D)
45# (4) D.d <- (E.e)
46# (5) E.e <- (F) priv
47# (6) G.g <- (F) priv
48
49# BIDIRECTIONAL
50gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
51gnunet-namestore -D -z a
52gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
53gnunet-namestore -D -z b
54
55SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
56gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
57gnunet-namestore -D -z d
58SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
59gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
60gnunet-namestore -D -z e
61SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
62gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
63gnunet-namestore -D -z f
64SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
65gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
66gnunet-namestore -D -z h
67
68# Starting to resolve
69echo "+++ Starting to Resolve +++"
70
71DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f -c test_abd_lookup.conf | paste -d, -s - -`
72echo $DELS
73echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_abd_lookup.conf
74gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_abd_lookup.conf
75
76RES=$?
77
78# Cleanup properly
79gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
80gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
81gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
82gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
83gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
84
85gnunet-arm -e -c test_abd_lookup.conf
86
87if [ "$RES" == 0 ]
88then
89 exit 0
90else
91 echo "FAIL: Failed to verify credential."
92 exit 1
93fi
94
diff --git a/src/abd/test_abd_bi_and3.sh b/src/abd/test_abd_bi_and3.sh
deleted file mode 100755
index cde2a020b..000000000
--- a/src/abd/test_abd_bi_and3.sh
+++ /dev/null
@@ -1,96 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
21gnunet-arm -s -c test_abd_lookup.conf
22
23gnunet-identity -C a -c test_abd_lookup.conf
24gnunet-identity -C b -c test_abd_lookup.conf
25gnunet-identity -C c -c test_abd_lookup.conf
26gnunet-identity -C d -c test_abd_lookup.conf
27gnunet-identity -C e -c test_abd_lookup.conf
28gnunet-identity -C f -c test_abd_lookup.conf
29gnunet-identity -C g -c test_abd_lookup.conf
30gnunet-identity -C h -c test_abd_lookup.conf
31AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
32BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
33CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
34DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
35EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
36FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
37GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
38HKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep h | awk '{print $3}')
39gnunet-identity -d
40
41# (1) (A.a) <- B.b
42# (2) (B.b) <- C.c AND G.g
43# (3) C.c <- (D.d)
44# (4) D.d <- (E.e)
45# (5) E.e <- (F) priv
46# (6) G.g <- (H.h)
47# (7) H.h <- (F) priv
48
49# BIDIRECTIONAL
50gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
51gnunet-namestore -D -z a
52gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
53gnunet-namestore -D -z b
54
55SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
56gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
57gnunet-namestore -D -z d
58SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
59gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
60gnunet-namestore -D -z e
61SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=g --attribute="g" --subject="$HKEY h" --ttl="2019-12-12 10:00:00"`
62gnunet-abd --createSubjectSide --ego=h --import="$SIGNED"
63gnunet-namestore -D -z h
64SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
65gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
66SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=h --attribute="h" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
67gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
68gnunet-namestore -D -z f
69
70# Starting to resolve
71echo "+++ Starting to Resolve +++"
72
73DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f -c test_abd_lookup.conf | paste -d, -s - -`
74echo $DELS
75echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_abd_lookup.conf
76gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_abd_lookup.conf
77
78RES=$?
79
80# Cleanup properly
81gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
82gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
83gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
84gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
85gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
86gnunet-namestore -z h -d -n "@" -t DEL -c test_abd_lookup.conf
87
88gnunet-arm -e -c test_abd_lookup.conf
89
90if [ "$RES" == 0 ]
91then
92 exit 0
93else
94 echo "FAIL: Failed to verify credential."
95 exit 1
96fi
diff --git a/src/abd/test_abd_bi_and4.sh b/src/abd/test_abd_bi_and4.sh
deleted file mode 100755
index e8cd6efd6..000000000
--- a/src/abd/test_abd_bi_and4.sh
+++ /dev/null
@@ -1,83 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31gnunet-identity -C h -c test_abd_lookup.conf
32AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
33BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
34CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
35DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
36EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
37FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
38GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
39HKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep h | awk '{print $3}')
40gnunet-identity -d
41
42# (1) (A.a) <- B.b
43# (2) (B.b) <- C.c AND G.g
44# (3) C.c <- (F) priv
45# (4) G.g <- (F) priv
46
47# BIDIRECTIONAL
48gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
49gnunet-namestore -D -z a
50gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
51gnunet-namestore -D -z b
52
53SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
54gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
55SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
56gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
57gnunet-namestore -D -z f
58
59# Starting to resolve
60echo "+++ Starting to Resolve +++"
61
62DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --backward -c test_abd_lookup.conf | paste -d, -s - -`
63echo $DELS
64echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --backward -c test_abd_lookup.conf
65gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --backward -c test_abd_lookup.conf
66
67RES=$?
68
69# Cleanup properly
70gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
71gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
72gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
73
74gnunet-arm -e -c test_abd_lookup.conf
75
76if [ "$RES" == 0 ]
77then
78 exit 0
79else
80 echo "FAIL: Failed to verify credential."
81 exit 1
82fi
83
diff --git a/src/abd/test_abd_bi_bw.sh b/src/abd/test_abd_bi_bw.sh
deleted file mode 100755
index 6b0e51722..000000000
--- a/src/abd/test_abd_bi_bw.sh
+++ /dev/null
@@ -1,87 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
32BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
33CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
34DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
35EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
36FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
37GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
38gnunet-identity -d
39
40# (1) (A.a) <- B.b
41# (2) (B.b) <- C.c
42# (3) C.c <- (D.D)
43# (4) D.d <- (E.e)
44# (5) E.e <- (F)
45
46# BIDIRECTIONAL
47gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
48gnunet-namestore -D -z a
49gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c" --ttl=5m -c test_abd_lookup.conf
50gnunet-namestore -D -z b
51
52SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
53gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
54gnunet-namestore -D -z d
55SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
56gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
57gnunet-namestore -D -z e
58SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
59gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
60gnunet-namestore -D -z f
61
62# Starting to resolve
63echo "+++ Starting to Resolve +++"
64
65DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
66echo $DELS
67echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
68gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
69
70RES=$?
71
72# Cleanup properly
73gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
74gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
75gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
76gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
77gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
78
79gnunet-arm -e -c test_abd_lookup.conf
80
81if [ "$RES" == 0 ]
82then
83 exit 0
84else
85 echo "FAIL: Failed to verify credential."
86 exit 1
87fi
diff --git a/src/abd/test_abd_bi_bw_link.sh b/src/abd/test_abd_bi_bw_link.sh
deleted file mode 100755
index f60f78827..000000000
--- a/src/abd/test_abd_bi_bw_link.sh
+++ /dev/null
@@ -1,92 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
32BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
33CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
34DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
35EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
36FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
37GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
38gnunet-identity -d
39
40# (1) (A.a) <- B.b
41# (2) (B.b) <- G.g.c
42# (3) (G.g) <- C
43# (3) C.c <- (D.D)
44# (4) D.d <- (E.e)
45# (5) E.e <- (F)
46
47# BIDIRECTIONAL
48gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
49gnunet-namestore -D -z a
50gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$GKEY g.c" --ttl=5m -c test_abd_lookup.conf
51gnunet-namestore -D -z b
52gnunet-abd --createIssuerSide --ego=g --attribute="g" --subject="$CKEY" --ttl=5m -c test_abd_lookup.conf
53gnunet-namestore -D -z b
54
55SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
56gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
57gnunet-namestore -D -z d
58SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
59gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
60gnunet-namestore -D -z e
61SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
62gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
63gnunet-namestore -D -z f
64
65# Starting to resolve
66echo "+++ Starting to Resolve +++"
67
68DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
69echo $DELS
70echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
71gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
72
73RES=$?
74
75# Cleanup properly
76gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
77gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
78gnunet-namestore -z g -d -n "g" -t ATTR -c test_abd_lookup.conf
79gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
80gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
81gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
82
83gnunet-arm -e -c test_abd_lookup.conf
84
85if [ "$RES" == 0 ]
86then
87 exit 0
88else
89 echo "FAIL: Failed to verify credential."
90 exit 1
91fi
92
diff --git a/src/abd/test_abd_bi_bw_link2.sh b/src/abd/test_abd_bi_bw_link2.sh
deleted file mode 100755
index b0fb49b8e..000000000
--- a/src/abd/test_abd_bi_bw_link2.sh
+++ /dev/null
@@ -1,93 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
32BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
33CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
34DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
35EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
36FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
37GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
38gnunet-identity -d
39
40# (1) (A.a) <- B.b
41# (2) (B.b) <- G.g.c
42# (3) G.g <- (C)
43# (3) C.c <- (D.d)
44# (4) D.d <- (E.e)
45# (5) E.e <- (F)
46
47# BIDIRECTIONAL
48gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
49gnunet-namestore -D -z a
50gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$GKEY g.c" --ttl=5m -c test_abd_lookup.conf
51gnunet-namestore -D -z b
52
53SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=g --attribute="g" --subject="$CKEY" --ttl="2019-12-12 10:00:00"`
54gnunet-abd --createSubjectSide --ego=c --import="$SIGNED"
55gnunet-namestore -D -z c
56SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
57gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
58gnunet-namestore -D -z d
59SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
60gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
61gnunet-namestore -D -z e
62SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
63gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
64gnunet-namestore -D -z f
65
66# Starting to resolve
67echo "+++ Starting to Resolve +++"
68
69DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
70echo $DELS
71echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
72gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
73
74RES=$?
75
76# Cleanup properly
77gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
78gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
79gnunet-namestore -z c -d -n "@" -t DEL -c test_abd_lookup.conf
80gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
81gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
82gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
83
84gnunet-arm -e -c test_abd_lookup.conf
85
86if [ "$RES" == 0 ]
87then
88 exit 0
89else
90 echo "FAIL: Failed to verify credential."
91 exit 1
92fi
93
diff --git a/src/abd/test_abd_bi_fw.sh b/src/abd/test_abd_bi_fw.sh
deleted file mode 100755
index 75a940fbe..000000000
--- a/src/abd/test_abd_bi_fw.sh
+++ /dev/null
@@ -1,92 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22gnunet-arm -s -c test_abd_lookup.conf
23
24gnunet-identity -C a -c test_abd_lookup.conf
25gnunet-identity -C b -c test_abd_lookup.conf
26gnunet-identity -C c -c test_abd_lookup.conf
27gnunet-identity -C d -c test_abd_lookup.conf
28gnunet-identity -C e -c test_abd_lookup.conf
29gnunet-identity -C f -c test_abd_lookup.conf
30gnunet-identity -C g -c test_abd_lookup.conf
31AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
32BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
33CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
34DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
35EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
36FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
37GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
38gnunet-identity -d
39
40# (1) (A.a) <- B.b
41# (2) (B.b) <- C.c
42# (3) C.c <- (D.D)
43# (4) D.d <- (E.e)
44# (5) E.e <- (F.f)
45# (6) F.f <- (G)
46
47# BIDIRECTIONAL
48gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
49gnunet-namestore -D -z a
50gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c" --ttl=5m -c test_abd_lookup.conf
51gnunet-namestore -D -z b
52
53SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
54gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
55gnunet-namestore -D -z d
56SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
57gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
58gnunet-namestore -D -z e
59SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY f" --ttl="2019-12-12 10:00:00"`
60gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
61gnunet-namestore -D -z f
62SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=f --attribute="f" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
63gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
64gnunet-namestore -D -z g
65
66# Starting to resolve
67echo "+++ Starting to Resolve +++"
68
69DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=g --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
70echo $DELS
71echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
72gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
73
74RES=$?
75
76# Cleanup properly
77gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
78gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
79gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
80gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
81gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
82gnunet-namestore -z g -d -n "@" -t DEL -c test_abd_lookup.conf
83
84gnunet-arm -e -c test_abd_lookup.conf
85
86if [ "$RES" == 0 ]
87then
88 exit 0
89else
90 echo "FAIL: Failed to verify credential."
91 exit 1
92fi
diff --git a/src/abd/test_abd_defaults.conf b/src/abd/test_abd_defaults.conf
deleted file mode 100644
index 7b4cb576d..000000000
--- a/src/abd/test_abd_defaults.conf
+++ /dev/null
@@ -1,24 +0,0 @@
1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2
3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-abd-testing/
5
6[namestore-sqlite]
7FILENAME = $GNUNET_TEST_HOME/namestore/sqlite_test.db
8
9[namecache-sqlite]
10FILENAME=$GNUNET_TEST_HOME/namecache/namecache.db
11
12[identity]
13# Directory where we store information about our egos
14EGODIR = $GNUNET_TEST_HOME/identity/egos/
15
16[dhtcache]
17DATABASE = heap
18
19[transport]
20PLUGINS = tcp
21
22[transport-tcp]
23BINDTO = 127.0.0.1
24
diff --git a/src/abd/test_abd_issue.sh b/src/abd/test_abd_issue.sh
deleted file mode 100755
index 8076aa921..000000000
--- a/src/abd/test_abd_issue.sh
+++ /dev/null
@@ -1,46 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18# (1) PKEY1.user -> PKEY2.resu.user
19# (2) PKEY2.resu -> PKEY3
20# (3) PKEY3.user -> PKEY4
21
22
23which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
24
25TEST_ATTR="test"
26gnunet-arm -s -c test_abd_lookup.conf
27gnunet-identity -C testissuer -c test_abd_lookup.conf
28gnunet-identity -C testsubject -c test_abd_lookup.conf
29SUBJECT_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep testsubject | awk '{print $3}')
30ISSUER_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep testissuer | awk '{print $3}')
31
32# Get abd and store it with subject (3)
33SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=testissuer --attribute=$TEST_ATTR --subject=$SUBJECT_KEY --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf`
34
35STATUS=$?
36
37if test $? != 0
38then
39 echo "Error issuing..."
40 exit 1
41fi
42#Try import
43$DO_TIMEOUT gnunet-abd --createSubjectSide --ego=testsubject --import="$SIGNED" --private -c test_abd_lookup.conf
44RES=$?
45gnunet-arm -e -c test_abd_lookup.conf
46exit $RES
diff --git a/src/abd/test_abd_lookup.conf b/src/abd/test_abd_lookup.conf
deleted file mode 100644
index 4072ba23b..000000000
--- a/src/abd/test_abd_lookup.conf
+++ /dev/null
@@ -1,28 +0,0 @@
1@INLINE@ test_abd_defaults.conf
2
3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-abd-peer-1/
5
6[dht]
7START_ON_DEMAND = YES
8
9[transport]
10PLUGINS =
11
12[abd]
13START_ON_DEMAND = YES
14#PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/credlog
15
16[rest]
17PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/restlog
18
19[gns]
20#PREFIX = valgrind --leak-check=full --track-origins=yes
21START_ON_DEMAND = YES
22AUTO_IMPORT_PKEY = YES
23MAX_PARALLEL_BACKGROUND_QUERIES = 10
24DEFAULT_LOOKUP_TIMEOUT = 15 s
25RECORD_PUT_INTERVAL = 1 h
26ZONE_PUBLISH_TIME_WINDOW = 1 h
27DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0
28
diff --git a/src/abd/test_abd_own.sh b/src/abd/test_abd_own.sh
deleted file mode 100755
index 3fc210284..000000000
--- a/src/abd/test_abd_own.sh
+++ /dev/null
@@ -1,139 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
21gnunet-arm -s -c test_abd_lookup.conf
22
23gnunet-identity -C a -c test_abd_lookup.conf
24gnunet-identity -C d -c test_abd_lookup.conf
25gnunet-identity -C e -c test_abd_lookup.conf
26gnunet-identity -C f -c test_abd_lookup.conf
27gnunet-identity -C g -c test_abd_lookup.conf
28AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
29DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
30EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
31FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
32GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
33
34############################################################################################
35# (1) EPub.discount <- EOrg.preferred
36# (2) EOrg.preferred <- StateU.student
37# (3) StateU.student <- RegistrarB.student
38# (4) RegistrarB.student <- Alice
39
40gnunet-identity -C epub -c test_abd_lookup.conf
41gnunet-identity -C eorg -c test_abd_lookup.conf
42gnunet-identity -C stateu -c test_abd_lookup.conf
43gnunet-identity -C registrarb -c test_abd_lookup.conf
44gnunet-identity -C alice -c test_abd_lookup.conf
45
46EPUB_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep epub | awk '{print $3}')
47EORG_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep eorg | awk '{print $3}')
48STATEU_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep stateu | awk '{print $3}')
49REGISTRARB_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep registrarb | awk '{print $3}')
50ALICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep alice | awk '{print $3}')
51
52
53DISC_ATTR="discount"
54PREF_ATTR="preferred"
55STATE_STUD_ATTR="student"
56REG_STUD_ATTR="student"
57END_ATTR="end"
58
59gnunet-identity -d
60
61# FORWARD, subject side stored (different constellations)
62SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="a" --subject="$AKEY b.c" --ttl="2019-12-12 10:00:00"`
63gnunet-abd --createSubjectSide --ego=a --import="$SIGNED"
64gnunet-namestore -D -z a
65
66SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="b" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
67gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
68gnunet-namestore -D -z d
69
70SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY" --ttl="2019-12-12 10:00:00"`
71gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
72gnunet-namestore -D -z e
73
74SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="c" --subject="$FKEY c" --ttl="2019-12-12 10:00:00"`
75gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
76SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="k" --subject="$FKEY c.k" --ttl="2019-12-12 10:00:00"`
77gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
78gnunet-namestore -D -z f
79
80SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=f --attribute="c" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
81gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
82SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="c" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
83gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
84SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="h.o" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
85gnunet-abd --createSubjectSide --ego=g --import="$SIGNED"
86gnunet-namestore -D -z g
87
88
89# BACKWARD, issuer side stored
90# (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg
91gnunet-abd --createIssuerSide --ego=epub --attribute=$DISC_ATTR --subject="$EORG_KEY $PREF_ATTR" --ttl=5m -c test_abd_lookup.conf
92
93# (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU
94gnunet-abd --createIssuerSide --ego=eorg --attribute=$PREF_ATTR --subject="$STATEU_KEY $STATE_STUD_ATTR" --ttl=5m -c test_abd_lookup.conf
95
96# (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB
97gnunet-abd --createIssuerSide --ego=stateu --attribute=$STATE_STUD_ATTR --subject="$REGISTRARB_KEY $REG_STUD_ATTR" --ttl=5m -c test_abd_lookup.conf
98
99# (4) RegistrarB issues Alice the credential "student"
100SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=registrarb --attribute="$REG_STUD_ATTR" --subject="$ALICE_KEY" --ttl="2019-12-12 10:00:00"`
101gnunet-abd --createSubjectSide --ego=alice --import="$SIGNED" --private
102
103# Starting to resolve
104echo "+++ Starting to Resolve +++"
105
106# FORWARD
107#DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=g --forward -c test_abd_lookup.conf | paste -d, -s - -`
108#echo $DELS
109#echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate=\'$DELS\' --forward -c test_abd_lookup.conf
110#RES_DELS=`gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward -c test_abd_lookup.conf`
111
112# BACKWARD
113DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice --backward -c test_abd_lookup.conf | paste -d, -s - -`
114echo $DELS
115echo gnunet-abd --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_abd_lookup.conf
116gnunet-abd --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_abd_lookup.conf
117
118RES=$?
119
120# Cleanup properly
121gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_abd_lookup.conf
122gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_abd_lookup.conf
123gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_abd_lookup.conf
124#gnunet-namestore -z a -d -n "@" -t DEL -c test_abd_lookup.conf
125#gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
126#gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
127#gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
128#gnunet-namestore -z g -d -n "@" -t DEL -c test_abd_lookup.conf
129
130
131gnunet-arm -e -c test_abd_lookup.conf
132
133if [ "$RES" == 0 ]
134then
135 exit 0
136else
137 echo "FAIL: Failed to verify credential."
138 exit 1
139fi
diff --git a/src/abd/test_abd_verify.sh b/src/abd/test_abd_verify.sh
deleted file mode 100755
index 9ece91c62..000000000
--- a/src/abd/test_abd_verify.sh
+++ /dev/null
@@ -1,87 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18# (1) Service.user -> GNU.project.member
19# (2) GNU.project -> GNUnet
20# (3) GNUnet.member -> GNUnet.developer
21# (4) GNUnet.member -> GNUnet.user
22# (5) GNUnet.developer -> Alice
23
24
25which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
26gnunet-arm -s -c test_abd_lookup.conf
27gnunet-identity -C service -c test_abd_lookup.conf
28gnunet-identity -C alice -c test_abd_lookup.conf
29gnunet-identity -C gnu -c test_abd_lookup.conf
30gnunet-identity -C gnunet -c test_abd_lookup.conf
31
32GNU_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep gnu | grep -v gnunet | awk '{print $3}')
33ALICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep alice | awk '{print $3}')
34GNUNET_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep gnunet | awk '{print $3}')
35SERVICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep service | awk '{print $3}')
36
37USER_ATTR="user"
38GNU_PROJECT_ATTR="project"
39MEMBER_ATTR="member"
40DEVELOPER_ATTR="developer"
41DEV_ATTR="developer"
42TEST_CREDENTIAL="mygnunetcreds"
43
44gnunet-identity -d
45
46# (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU
47gnunet-abd --createIssuerSide --ego=service --attribute="$USER_ATTR" --subject="$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
48gnunet-namestore -D -z service
49
50# (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute
51gnunet-abd --createIssuerSide --ego=gnu --attribute="$GNU_PROJECT_ATTR" --subject="$GNUNET_KEY" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
52gnunet-namestore -D -z gnu
53
54# (3+4) GNUnet assigns the attribute "member" to all entities gnunet has also assigned "developer" or "user"
55gnunet-abd --createIssuerSide --ego=gnunet --attribute="$MEMBER_ATTR" --subject="$GNUNET_KEY $DEVELOPER_ATTR" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
56gnunet-abd --createIssuerSide --ego=gnunet --attribute="$MEMBER_ATTR" --subject="$GNUNET_KEY $USER_ATTR" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
57gnunet-namestore -D -z gnunet
58
59# (5) GNUnet signes the delegate and Alice stores it
60SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=gnunet --attribute=$DEV_ATTR --subject=$ALICE_KEY --ttl="2019-12-12 10:00:00"`
61gnunet-abd --createSubjectSide --ego=alice --import="$SIGNED" --private
62gnunet-namestore -D -z alice
63
64# Starting to resolve
65echo "+++ Starting to Resolve +++"
66
67DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$SERVICE_KEY --attribute=$USER_ATTR --ego=alice --backward -c test_abd_lookup.conf | paste -d, -s - -`
68echo $DELS
69echo gnunet-abd --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_abd_lookup.conf
70gnunet-abd --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_abd_lookup.conf
71
72RES=$?
73
74# Cleanup properly
75gnunet-namestore -z alice -d -n "@" -t DEL -c test_abd_lookup.conf
76gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_abd_lookup.conf
77gnunet-namestore -z gnunet -d -n $MEMBER_ATTR -t ATTR -c test_abd_lookup.conf
78gnunet-namestore -z service -d -n $USER_ATTR -t ATTR -c test_abd_lookup.conf
79gnunet-arm -e -c test_abd_lookup.conf
80
81if [ "$RES" == 0 ]
82then
83 exit 0
84else
85 echo "FAIL: Failed to verify credential."
86 exit 1
87fi
diff --git a/src/abd/test_abd_verify_and.sh b/src/abd/test_abd_verify_and.sh
deleted file mode 100755
index c6287055e..000000000
--- a/src/abd/test_abd_verify_and.sh
+++ /dev/null
@@ -1,86 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18# (1) Service.user -> GNU.project.member
19# (2) GNU.project -> GNUnet
20# (3) GNUnet.member -> GNUnet.developer AND GNUnet.user
21# (4) GNUnet.developer -> Alice
22
23
24which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
25gnunet-arm -s -c test_abd_lookup.conf
26gnunet-identity -C service -c test_abd_lookup.conf
27gnunet-identity -C alice -c test_abd_lookup.conf
28gnunet-identity -C gnu -c test_abd_lookup.conf
29gnunet-identity -C gnunet -c test_abd_lookup.conf
30
31GNU_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep gnu | grep -v gnunet | awk '{print $3}')
32ALICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep alice | awk '{print $3}')
33GNUNET_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep gnunet | awk '{print $3}')
34SERVICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep service | awk '{print $3}')
35
36USER_ATTR="user"
37GNU_PROJECT_ATTR="project"
38MEMBER_ATTR="member"
39DEVELOPER_ATTR="developer"
40DEV_ATTR="developer"
41
42gnunet-identity -d
43
44# (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU
45gnunet-abd --createIssuerSide --ego=service --attribute="$USER_ATTR" --subject="$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
46gnunet-namestore -D -z service
47
48# (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute
49gnunet-abd --createIssuerSide --ego=gnu --attribute="$GNU_PROJECT_ATTR" --subject="$GNUNET_KEY" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
50gnunet-namestore -D -z gnu
51
52# (3+4) GNUnet assigns the attribute "member" to all entities gnunet has also assigned "developer" or "user"
53gnunet-abd --createIssuerSide --ego=gnunet --attribute="$MEMBER_ATTR" --subject="$GNUNET_KEY $DEVELOPER_ATTR, $GNUNET_KEY $USER_ATTR" --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf
54gnunet-namestore -D -z gnunet
55
56# (5) GNUnet signes the delegates and Alice stores it
57SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=gnunet --attribute=$DEV_ATTR --subject=$ALICE_KEY --ttl="2019-12-12 10:00:00"`
58gnunet-abd --createSubjectSide --ego=alice --import="$SIGNED" --private
59SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=gnunet --attribute=$USER_ATTR --subject=$ALICE_KEY --ttl="2019-12-12 10:00:00"`
60gnunet-abd --createSubjectSide --ego=alice --import="$SIGNED" --private
61gnunet-namestore -D -z alice
62
63# Starting to resolve
64echo "+++ Starting to Resolve +++"
65
66DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$SERVICE_KEY --attribute=$USER_ATTR --ego=alice --backward -c test_abd_lookup.conf | paste -d, -s - -`
67echo $DELS
68echo gnunet-abd --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_abd_lookup.conf
69gnunet-abd --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_abd_lookup.conf
70
71RES=$?
72
73# Cleanup properly
74gnunet-namestore -z alice -d -n "@" -t DEL -c test_abd_lookup.conf
75gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_abd_lookup.conf
76gnunet-namestore -z gnunet -d -n $MEMBER_ATTR -t ATTR -c test_abd_lookup.conf
77gnunet-namestore -z service -d -n $USER_ATTR -t ATTR -c test_abd_lookup.conf
78gnunet-arm -e -c test_abd_lookup.conf
79
80if [ "$RES" == 0 ]
81then
82 exit 0
83else
84 echo "FAIL: Failed to verify credentials."
85 exit 1
86fi
diff --git a/src/abd/test_abd_verify_simple.sh b/src/abd/test_abd_verify_simple.sh
deleted file mode 100755
index e917f8793..000000000
--- a/src/abd/test_abd_verify_simple.sh
+++ /dev/null
@@ -1,56 +0,0 @@
1#!/usr/bin/env bash
2trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18# (1) Issuer.user -> Subject
19
20
21which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
22gnunet-arm -s -c test_abd_lookup.conf
23gnunet-identity -C testissuer -c test_abd_lookup.conf
24gnunet-identity -C testsubject -c test_abd_lookup.conf
25
26TEST_ATTR="user"
27SUBJECT_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep testsubject | awk '{print $3}')
28ISSUER_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep testissuer | awk '{print $3}')
29
30gnunet-identity -d
31
32# Create delegate (1)
33SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=testissuer --attribute=$TEST_ATTR --subject=$SUBJECT_KEY --ttl="2019-12-12 10:00:00" -c test_abd_lookup.conf`
34gnunet-abd --createSubjectSide --ego=testsubject --import="$SIGNED" --private
35gnunet-namestore -D -z testsubject
36
37# Starting to resolve
38echo "+++ Starting to Resolve +++"
39
40DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$ISSUER_KEY --attribute=$TEST_ATTR --ego=testsubject -c test_abd_lookup.conf | paste -d, -s - -`
41echo $DELS
42gnunet-abd --verify --issuer=$ISSUER_KEY --attribute=$TEST_ATTR --subject=$SUBJECT_KEY --delegate="$DELS" -c test_abd_lookup.conf
43
44RES=$?
45
46# Cleanup properly
47gnunet-namestore -z testsubject -d -n "@" -t DEL -c test_abd_lookup.conf
48gnunet-arm -e -c test_abd_lookup.conf
49
50if [ "$RES" == 0 ]
51then
52 exit 0
53else
54 echo "FAIL: Failed to verify credential."
55 exit 1
56fi \ No newline at end of file