aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-08-17 17:06:36 +0200
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-08-17 17:06:36 +0200
commit31487d74b36541f0d97caf6d844da52a7667cd97 (patch)
treeff42114d4167d823140d2d4e814703467ac7bad0
parenta6581f9ede6cae352c71a4a632513d74bb45695a (diff)
downloadgnunet-31487d74b36541f0d97caf6d844da52a7667cd97.tar.gz
gnunet-31487d74b36541f0d97caf6d844da52a7667cd97.zip
issue done
-rw-r--r--src/include/gnunet_zklaim_service.h17
-rw-r--r--src/zklaim/Makefile.am16
-rw-r--r--src/zklaim/gnunet-service-zklaim.c19
-rw-r--r--src/zklaim/gnunet-zklaim.c91
-rw-r--r--src/zklaim/plugin_gnsrecord_zklaim.c178
-rw-r--r--src/zklaim/zklaim_api.c30
-rw-r--r--src/zklaim/zklaim_functions.c14
-rw-r--r--src/zklaim/zklaim_functions.h2
8 files changed, 336 insertions, 31 deletions
diff --git a/src/include/gnunet_zklaim_service.h b/src/include/gnunet_zklaim_service.h
index 0a551e703..f4337966b 100644
--- a/src/include/gnunet_zklaim_service.h
+++ b/src/include/gnunet_zklaim_service.h
@@ -146,6 +146,23 @@ GNUNET_ZKLAIM_context_create (struct GNUNET_ZKLAIM_Handle *h,
146 GNUNET_ZKLAIM_ContinuationWithStatus cont, 146 GNUNET_ZKLAIM_ContinuationWithStatus cont,
147 void *cont_cls); 147 void *cont_cls);
148 148
149int
150GNUNET_ZKLAIM_issue_from_context (struct GNUNET_ZKLAIM_Context *ctx,
151 struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
152 GNUNET_ZKLAIM_PayloadIterator iter,
153 void* iter_cls);
154
155/**
156 * Lookup context
157 */
158struct GNUNET_ZKLAIM_Operation*
159GNUNET_ZKLAIM_lookup_context (struct GNUNET_ZKLAIM_Handle *h,
160 const char *name,
161 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
162 GNUNET_ZKLAIM_ContextResult cont,
163 void* cont_cls);
164
165
149/** 166/**
150 * Disconnect from service. 167 * Disconnect from service.
151 * 168 *
diff --git a/src/zklaim/Makefile.am b/src/zklaim/Makefile.am
index b28683d1a..22600c882 100644
--- a/src/zklaim/Makefile.am
+++ b/src/zklaim/Makefile.am
@@ -12,8 +12,12 @@ if USE_COVERAGE
12 XLIB = -lgcov 12 XLIB = -lgcov
13endif 13endif
14 14
15pkgcfg_DATA = \
16 zklaim.conf
17
15plugin_LTLIBRARIES = \ 18plugin_LTLIBRARIES = \
16 libgnunet_plugin_reclaim_attribute_zklaim.la 19 libgnunet_plugin_reclaim_attribute_zklaim.la \
20 libgnunet_plugin_gnsrecord_zklaim.la
17 21
18lib_LTLIBRARIES = \ 22lib_LTLIBRARIES = \
19 libgnunetzklaim.la 23 libgnunetzklaim.la
@@ -21,6 +25,16 @@ lib_LTLIBRARIES = \
21libexec_PROGRAMS = \ 25libexec_PROGRAMS = \
22 gnunet-service-zklaim 26 gnunet-service-zklaim
23 27
28libgnunet_plugin_gnsrecord_zklaim_la_SOURCES = \
29 plugin_gnsrecord_zklaim.c
30libgnunet_plugin_gnsrecord_zklaim_la_LIBADD = \
31 $(top_builddir)/src/util/libgnunetutil.la \
32 $(LTLIBINTL)
33libgnunet_plugin_gnsrecord_zklaim_la_LDFLAGS = \
34 $(GN_PLUGIN_LDFLAGS)
35
36
37
24libgnunetzklaim_la_SOURCES = \ 38libgnunetzklaim_la_SOURCES = \
25 zklaim_api.c \ 39 zklaim_api.c \
26 zklaim_functions.c 40 zklaim_functions.c
diff --git a/src/zklaim/gnunet-service-zklaim.c b/src/zklaim/gnunet-service-zklaim.c
index 100a87f07..baf6b20de 100644
--- a/src/zklaim/gnunet-service-zklaim.c
+++ b/src/zklaim/gnunet-service-zklaim.c
@@ -221,7 +221,6 @@ cleanup_create_handle (struct CreateContextHandle *handle)
221 if (NULL != handle->ns_qe) 221 if (NULL != handle->ns_qe)
222 GNUNET_NAMESTORE_cancel (handle->ns_qe); 222 GNUNET_NAMESTORE_cancel (handle->ns_qe);
223 GNUNET_free_non_null (handle->name); 223 GNUNET_free_non_null (handle->name);
224 GNUNET_free_non_null (handle->name);
225 GNUNET_free_non_null (handle->attrs); 224 GNUNET_free_non_null (handle->attrs);
226 GNUNET_free (handle); 225 GNUNET_free (handle);
227} 226}
@@ -241,10 +240,10 @@ send_result (int32_t status,
241 r_msg->result_code = htonl (status); 240 r_msg->result_code = htonl (status);
242 GNUNET_MQ_send (cch->client->mq, 241 GNUNET_MQ_send (cch->client->mq,
243 env); 242 env);
244 cleanup_create_handle (cch);
245 GNUNET_CONTAINER_DLL_remove (cch->client->create_op_head, 243 GNUNET_CONTAINER_DLL_remove (cch->client->create_op_head,
246 cch->client->create_op_tail, 244 cch->client->create_op_tail,
247 cch); 245 cch);
246 cleanup_create_handle (cch);
248} 247}
249 248
250static void 249static void
@@ -299,7 +298,7 @@ handle_create_context_message (void *cls,
299 int i; 298 int i;
300 zklaim_ctx *ctx; 299 zklaim_ctx *ctx;
301 300
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 301 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
303 "Received CREATE_REQUEST message\n"); 302 "Received CREATE_REQUEST message\n");
304 303
305 str_len = ntohs (crm->name_len); 304 str_len = ntohs (crm->name_len);
@@ -307,6 +306,7 @@ handle_create_context_message (void *cls,
307 cch = GNUNET_new (struct CreateContextHandle); 306 cch = GNUNET_new (struct CreateContextHandle);
308 cch->name = GNUNET_strndup ((char*)&crm[1], str_len-1); 307 cch->name = GNUNET_strndup ((char*)&crm[1], str_len-1);
309 str_len = ntohs(crm->attrs_len); 308 str_len = ntohs(crm->attrs_len);
309 fprintf(stderr, "%s\n", cch->name);
310 cch->attrs = GNUNET_strndup (((char*)&crm[1]) + strlen (cch->name) + 1, 310 cch->attrs = GNUNET_strndup (((char*)&crm[1]) + strlen (cch->name) + 1,
311 str_len-1); 311 str_len-1);
312 cch->private_key = crm->private_key; 312 cch->private_key = crm->private_key;
@@ -336,12 +336,14 @@ handle_create_context_message (void *cls,
336 pos = strtok(NULL, ","); 336 pos = strtok(NULL, ",");
337 } 337 }
338 GNUNET_free (tmp); 338 GNUNET_free (tmp);
339 num_pl = num_attrs / 5; 339 num_pl = (num_attrs / 5) + 1;
340 zklaim_payload pl[num_pl]; 340 zklaim_payload *pl = GNUNET_malloc (num_pl * sizeof (zklaim_payload));
341 ctx = zklaim_context_new (); 341 ctx = zklaim_context_new ();
342 for (i = 0; i < num_pl; i++) 342 for (i = 0; i < num_pl; i++)
343 zklaim_add_pl (ctx, pl[i]); 343 zklaim_add_pl (ctx, pl[i]);
344 zklaim_hash_ctx (ctx); 344 zklaim_hash_ctx (ctx);
345 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
346 "Starting trusted setup (%d payloads)... this might take a while...\n", num_pl);
345 if (0 != zklaim_trusted_setup (ctx)) 347 if (0 != zklaim_trusted_setup (ctx))
346 { 348 {
347 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 349 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -350,6 +352,8 @@ handle_create_context_message (void *cls,
350 zklaim_ctx_free (ctx); 352 zklaim_ctx_free (ctx);
351 return; 353 return;
352 } 354 }
355 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
356 "Finished trusted setup.\n");
353 data_len = zklaim_ctx_serialize (ctx, &data); 357 data_len = zklaim_ctx_serialize (ctx, &data);
354 rdata_len = data_len + strlen (cch->attrs) + 1; 358 rdata_len = data_len + strlen (cch->attrs) + 1;
355 zklaim_ctx_free (ctx); 359 zklaim_ctx_free (ctx);
@@ -411,10 +415,11 @@ send_ctx_result (struct LookupHandle *lh,
411 len); 415 len);
412 GNUNET_MQ_send (lh->client->mq, 416 GNUNET_MQ_send (lh->client->mq,
413 env); 417 env);
414 cleanup_lookup_handle (lh);
415 GNUNET_CONTAINER_DLL_remove (lh->client->lookup_op_head, 418 GNUNET_CONTAINER_DLL_remove (lh->client->lookup_op_head,
416 lh->client->lookup_op_tail, 419 lh->client->lookup_op_tail,
417 lh); 420 lh);
421
422 cleanup_lookup_handle (lh);
418} 423}
419 424
420 425
@@ -439,7 +444,7 @@ ctx_found_cb (void *cls,
439 const struct GNUNET_GNSRECORD_Data *rd) 444 const struct GNUNET_GNSRECORD_Data *rd)
440{ 445{
441 struct LookupHandle *lh = cls; 446 struct LookupHandle *lh = cls;
442 447 lh->ns_qe = NULL;
443 send_ctx_result (lh, (char*) rd->data, rd->data_size); 448 send_ctx_result (lh, (char*) rd->data, rd->data_size);
444} 449}
445 450
diff --git a/src/zklaim/gnunet-zklaim.c b/src/zklaim/gnunet-zklaim.c
index 053482362..a97bca5d4 100644
--- a/src/zklaim/gnunet-zklaim.c
+++ b/src/zklaim/gnunet-zklaim.c
@@ -55,6 +55,11 @@ static char* context_name;
55static char* issue_attrs; 55static char* issue_attrs;
56 56
57/** 57/**
58 * Attribute names for issuer context data
59 */
60static char* create_attrs;
61
62/**
58 * Ego name 63 * Ego name
59 */ 64 */
60static char* ego_name; 65static char* ego_name;
@@ -119,25 +124,97 @@ context_create_cb (void *cls,
119 int32_t success, 124 int32_t success,
120 const char* emsg) 125 const char* emsg)
121{ 126{
127 if (GNUNET_OK == success)
128 fprintf (stdout,
129 "Created.\n");
130 else
131 fprintf(stderr,
132 "Failed.\n");
133 if (NULL == cleanup_task)
134 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
135 return;
136}
137
138static void
139issue_iter (void *cls,
140 const char* attr_name,
141 uint64_t *data)
142{
143 char *tmp;
144 char *key;
145 char *val;
146 tmp = GNUNET_strdup (issue_attrs);
147 key = strtok (tmp, "=");
148 while (NULL != key)
149 {
150 val = strtok (NULL, ";");
151 if (0 != strcmp (attr_name, key))
152 {
153 key = strtok (NULL, "=");
154 continue;
155 }
156 if (1 != sscanf (val, "%lu", data))
157 fprintf (stderr,
158 "Failed to fill %s with %s\n",
159 key, val);
160 key = strtok (NULL, "=");
161 }
162 GNUNET_free (tmp);
163 fprintf (stdout, "Setting %s=%lu\n", attr_name, *data);
164}
165
166static void
167context_cb (void *cls,
168 const struct GNUNET_ZKLAIM_Context *ctx)
169{
170 int ret;
171 if (NULL == ctx)
172 {
173 fprintf (stderr,
174 "Context does not exist!\n");
175 }
176 else
177 {
178 ret = GNUNET_ZKLAIM_issue_from_context ((struct GNUNET_ZKLAIM_Context*)ctx,
179 (struct GNUNET_CRYPTO_EcdsaPrivateKey*)pkey,
180 &issue_iter,
181 NULL);
182 fprintf (stdout,
183 "Issued (%d)\n", ret);
184 }
185 if (NULL == cleanup_task)
186 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
122 return; 187 return;
188
123} 189}
124 190
125static void 191static void
126handle_arguments () 192handle_arguments ()
127{ 193{
128 timeout = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), 194 timeout = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60),
129 &timeout_task, 195 &timeout_task,
130 NULL); 196 NULL);
131 if (create) 197 if (create)
132 { 198 {
199 fprintf (stdout,
200 "Creating context...\n");
133 zklaim_op = GNUNET_ZKLAIM_context_create (zklaim_handle, 201 zklaim_op = GNUNET_ZKLAIM_context_create (zklaim_handle,
134 pkey, 202 pkey,
135 context_name, 203 context_name,
136 issue_attrs, 204 create_attrs,
137 &context_create_cb, 205 &context_create_cb,
138 NULL); 206 NULL);
139 return; 207 return;
140 } 208 }
209 if (issue_attrs)
210 {
211 zklaim_op = GNUNET_ZKLAIM_lookup_context (zklaim_handle,
212 context_name,
213 pkey,
214 &context_cb,
215 NULL);
216 return;
217 }
141 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 218 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
142} 219}
143 220
@@ -182,7 +259,7 @@ run (void *cls,
182 _("Context name missing!\n")); 259 _("Context name missing!\n"));
183 return; 260 return;
184 } 261 }
185 if ( (create) && (NULL == issue_attrs) ) 262 if ( (create) && (NULL == create_attrs) )
186 { 263 {
187 ret = 1; 264 ret = 1;
188 fprintf (stderr, 265 fprintf (stderr,
@@ -192,6 +269,7 @@ run (void *cls,
192 269
193 zklaim_handle = GNUNET_ZKLAIM_connect (c); 270 zklaim_handle = GNUNET_ZKLAIM_connect (c);
194 //Get Ego 271 //Get Ego
272 init = GNUNET_YES;
195 identity_handle = GNUNET_IDENTITY_connect (c, 273 identity_handle = GNUNET_IDENTITY_connect (c,
196 &ego_cb, 274 &ego_cb,
197 NULL); 275 NULL);
@@ -215,7 +293,7 @@ main(int argc, char *const argv[])
215 "attributes", 293 "attributes",
216 NULL, 294 NULL,
217 gettext_noop ("Context attributes (comma separated)"), 295 gettext_noop ("Context attributes (comma separated)"),
218 &issue_attrs), 296 &create_attrs),
219 GNUNET_GETOPT_option_string ('e', 297 GNUNET_GETOPT_option_string ('e',
220 "ego", 298 "ego",
221 NULL, 299 NULL,
@@ -225,6 +303,11 @@ main(int argc, char *const argv[])
225 "create", 303 "create",
226 gettext_noop ("Create new issuer context"), 304 gettext_noop ("Create new issuer context"),
227 &create), 305 &create),
306 GNUNET_GETOPT_option_string ('I',
307 "issue",
308 gettext_noop ("Issue a credential with the given attributes and given zklaim context"),
309 NULL,
310 &issue_attrs),
228 GNUNET_GETOPT_OPTION_END 311 GNUNET_GETOPT_OPTION_END
229 }; 312 };
230 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "ct", 313 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "ct",
diff --git a/src/zklaim/plugin_gnsrecord_zklaim.c b/src/zklaim/plugin_gnsrecord_zklaim.c
new file mode 100644
index 000000000..7e032d210
--- /dev/null
+++ b/src/zklaim/plugin_gnsrecord_zklaim.c
@@ -0,0 +1,178 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2013, 2014 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
19/**
20 * @file zklaim/plugin_gnsrecord_zklaim.c
21 * @brief gnsrecord plugin to provide the API for identity records
22 * @author Martin Schanzenbach
23 */
24#include "platform.h"
25#include "gnunet_util_lib.h"
26#include "gnunet_gnsrecord_lib.h"
27#include "gnunet_gnsrecord_plugin.h"
28
29
30/**
31 * Convert the 'value' of a record to a string.
32 *
33 * @param cls closure, unused
34 * @param type type of the record
35 * @param data value in binary encoding
36 * @param data_size number of bytes in @a data
37 * @return NULL on error, otherwise human-readable representation of the value
38 */
39static char *
40value_to_string (void *cls,
41 uint32_t type,
42 const void *data,
43 size_t data_size)
44{
45 switch (type)
46 {
47 case GNUNET_GNSRECORD_TYPE_ZKLAIM_CTX:
48 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
49 default:
50 return NULL;
51 }
52}
53
54
55/**
56 * Convert human-readable version of a 'value' of a record to the binary
57 * representation.
58 *
59 * @param cls closure, unused
60 * @param type type of the record
61 * @param s human-readable string
62 * @param data set to value in binary encoding (will be allocated)
63 * @param data_size set to number of bytes in @a data
64 * @return #GNUNET_OK on success
65 */
66static int
67string_to_value (void *cls,
68 uint32_t type,
69 const char *s,
70 void **data,
71 size_t *data_size)
72{
73 if (NULL == s)
74 return GNUNET_SYSERR;
75 switch (type)
76 {
77 case GNUNET_GNSRECORD_TYPE_ZKLAIM_CTX:
78 return GNUNET_STRINGS_string_to_data (s,
79 strlen (s),
80 *data,
81 *data_size);
82 default:
83 return GNUNET_SYSERR;
84 }
85}
86
87
88/**
89 * Mapping of record type numbers to human-readable
90 * record type names.
91 */
92static struct {
93 const char *name;
94 uint32_t number;
95} name_map[] = {
96 { "ZKLAIM_CTX", GNUNET_GNSRECORD_TYPE_ZKLAIM_CTX },
97 { NULL, UINT32_MAX }
98};
99
100
101/**
102 * Convert a type name (i.e. "AAAA") to the corresponding number.
103 *
104 * @param cls closure, unused
105 * @param dns_typename name to convert
106 * @return corresponding number, UINT32_MAX on error
107 */
108static uint32_t
109typename_to_number (void *cls,
110 const char *dns_typename)
111{
112 unsigned int i;
113
114 i=0;
115 while ( (NULL != name_map[i].name) &&
116 (0 != strcasecmp (dns_typename, name_map[i].name)) )
117 i++;
118 return name_map[i].number;
119}
120
121
122/**
123 * Convert a type number (i.e. 1) to the corresponding type string (i.e. "A")
124 *
125 * @param cls closure, unused
126 * @param type number of a type to convert
127 * @return corresponding typestring, NULL on error
128 */
129static const char *
130number_to_typename (void *cls,
131 uint32_t type)
132{
133 unsigned int i;
134
135 i=0;
136 while ( (NULL != name_map[i].name) &&
137 (type != name_map[i].number) )
138 i++;
139 return name_map[i].name;
140}
141
142
143/**
144 * Entry point for the plugin.
145 *
146 * @param cls NULL
147 * @return the exported block API
148 */
149void *
150libgnunet_plugin_gnsrecord_zklaim_init (void *cls)
151{
152 struct GNUNET_GNSRECORD_PluginFunctions *api;
153
154 api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions);
155 api->value_to_string = &value_to_string;
156 api->string_to_value = &string_to_value;
157 api->typename_to_number = &typename_to_number;
158 api->number_to_typename = &number_to_typename;
159 return api;
160}
161
162
163/**
164 * Exit point from the plugin.
165 *
166 * @param cls the return value from #libgnunet_plugin_block_test_init
167 * @return NULL
168 */
169void *
170libgnunet_plugin_gnsrecord_zklaim_done (void *cls)
171{
172 struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
173
174 GNUNET_free (api);
175 return NULL;
176}
177
178/* end of plugin_gnsrecord_dns.c */
diff --git a/src/zklaim/zklaim_api.c b/src/zklaim/zklaim_api.c
index 73998925b..6e9da67f3 100644
--- a/src/zklaim/zklaim_api.c
+++ b/src/zklaim/zklaim_api.c
@@ -247,7 +247,7 @@ handle_zklaim_result_code (void *cls,
247 op); 247 op);
248 if (NULL != op->cont) 248 if (NULL != op->cont)
249 op->cont (op->cls, 249 op->cont (op->cls,
250 GNUNET_OK, 250 ntohl(rcm->result_code),
251 str); 251 str);
252 GNUNET_free (op); 252 GNUNET_free (op);
253} 253}
@@ -282,7 +282,7 @@ handle_zklaim_result_ctx (void *cls,
282 struct GNUNET_ZKLAIM_Handle *h = cls; 282 struct GNUNET_ZKLAIM_Handle *h = cls;
283 struct GNUNET_ZKLAIM_Operation *op; 283 struct GNUNET_ZKLAIM_Operation *op;
284 struct GNUNET_ZKLAIM_Context ctx; 284 struct GNUNET_ZKLAIM_Context ctx;
285 uint16_t ctx_len = ntohs (cm->ctx_len); 285 uint16_t ctx_len = ntohl (cm->ctx_len);
286 286
287 op = h->op_head; 287 op = h->op_head;
288 if (NULL == op) 288 if (NULL == op)
@@ -297,8 +297,8 @@ handle_zklaim_result_ctx (void *cls,
297 ctx.attrs = (char*)&cm[1]; 297 ctx.attrs = (char*)&cm[1];
298 ctx.ctx = zklaim_context_new (); 298 ctx.ctx = zklaim_context_new ();
299 zklaim_ctx_deserialize (ctx.ctx, 299 zklaim_ctx_deserialize (ctx.ctx,
300 (unsigned char *) &cm[1]+ strlen (ctx.attrs) + 1, 300 (unsigned char *) &cm[1] + strlen (ctx.attrs) + 1,
301 ctx_len); 301 ctx_len - strlen (ctx.attrs) - 1);
302 if (NULL != op->ctx_cont) 302 if (NULL != op->ctx_cont)
303 { 303 {
304 if (0 > ctx_len) 304 if (0 > ctx_len)
@@ -395,11 +395,13 @@ GNUNET_ZKLAIM_context_create (struct GNUNET_ZKLAIM_Handle *h,
395 struct GNUNET_MQ_Envelope *env; 395 struct GNUNET_MQ_Envelope *env;
396 struct CreateRequestMessage *crm; 396 struct CreateRequestMessage *crm;
397 size_t slen; 397 size_t slen;
398 size_t alen;
398 399
399 if (NULL == h->mq) 400 if (NULL == h->mq)
400 return NULL; 401 return NULL;
401 slen = strlen (name) + 1; 402 slen = strlen (name) + 1;
402 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage)) 403 alen = strlen (attr_list) + 1;
404 if (slen+alen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage))
403 { 405 {
404 GNUNET_break (0); 406 GNUNET_break (0);
405 return NULL; 407 return NULL;
@@ -412,14 +414,18 @@ GNUNET_ZKLAIM_context_create (struct GNUNET_ZKLAIM_Handle *h,
412 h->op_tail, 414 h->op_tail,
413 op); 415 op);
414 env = GNUNET_MQ_msg_extra (crm, 416 env = GNUNET_MQ_msg_extra (crm,
415 slen, 417 slen + alen,
416 GNUNET_MESSAGE_TYPE_ZKLAIM_CREATE); 418 GNUNET_MESSAGE_TYPE_ZKLAIM_CREATE);
417 crm->name_len = htons (slen); 419 crm->name_len = htons (slen);
420 crm->attrs_len = htons (alen);
418 crm->reserved = htons (0); 421 crm->reserved = htons (0);
419 crm->private_key = *pk; 422 crm->private_key = *pk;
420 GNUNET_memcpy (&crm[1], 423 GNUNET_memcpy (&crm[1],
421 name, 424 name,
422 slen); 425 slen);
426 GNUNET_memcpy (((char*)&crm[1]) + slen,
427 attr_list,
428 alen);
423 GNUNET_MQ_send (h->mq, 429 GNUNET_MQ_send (h->mq,
424 env); 430 env);
425 //TODO add attrs 431 //TODO add attrs
@@ -506,7 +512,7 @@ GNUNET_ZKLAIM_lookup_context (struct GNUNET_ZKLAIM_Handle *h,
506 op); 512 op);
507 env = GNUNET_MQ_msg_extra (lm, 513 env = GNUNET_MQ_msg_extra (lm,
508 slen, 514 slen,
509 GNUNET_MESSAGE_TYPE_ZKLAIM_CREATE); 515 GNUNET_MESSAGE_TYPE_ZKLAIM_LOOKUP_CTX);
510 lm->name_len = htons (slen); 516 lm->name_len = htons (slen);
511 lm->reserved = htons (0); 517 lm->reserved = htons (0);
512 lm->private_key = *key; 518 lm->private_key = *key;
@@ -518,16 +524,16 @@ GNUNET_ZKLAIM_lookup_context (struct GNUNET_ZKLAIM_Handle *h,
518 return op; 524 return op;
519} 525}
520 526
521void 527int
522GNUNET_ZKLAIM_issue_from_context (struct GNUNET_ZKLAIM_Context *ctx, 528GNUNET_ZKLAIM_issue_from_context (struct GNUNET_ZKLAIM_Context *ctx,
523 struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 529 struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
524 GNUNET_ZKLAIM_PayloadIterator iter, 530 GNUNET_ZKLAIM_PayloadIterator iter,
525 void* iter_cls) 531 void* iter_cls)
526{ 532{
527 ZKLAIM_context_issue (ctx, 533 return ZKLAIM_context_issue (ctx,
528 key, 534 key,
529 iter, 535 iter,
530 iter_cls); 536 iter_cls);
531} 537}
532 538
533/* end of zklaim_api.c */ 539/* end of zklaim_api.c */
diff --git a/src/zklaim/zklaim_functions.c b/src/zklaim/zklaim_functions.c
index 3c968cfea..7f83ecb22 100644
--- a/src/zklaim/zklaim_functions.c
+++ b/src/zklaim/zklaim_functions.c
@@ -67,18 +67,20 @@ ZKLAIM_context_attributes_iterate (const struct GNUNET_ZKLAIM_Context *ctx,
67 tmp = GNUNET_strdup (ctx->attrs); 67 tmp = GNUNET_strdup (ctx->attrs);
68 attr_name = strtok (tmp, ","); 68 attr_name = strtok (tmp, ",");
69 plw = ctx->ctx->pl_ctx_head; 69 plw = ctx->ctx->pl_ctx_head;
70
71 for (i = 0; i < ctx->ctx->num_of_payloads; i++) 70 for (i = 0; i < ctx->ctx->num_of_payloads; i++)
72 { 71 {
73 for (j = 0; j < ZKLAIM_MAX_PAYLOAD_ATTRIBUTES; j++) 72 for (j = 0; j < ZKLAIM_MAX_PAYLOAD_ATTRIBUTES; j++)
74 { 73 {
75 GNUNET_assert (NULL != attr_name); 74 if (NULL == attr_name)
75 break;
76 iter (iter_cls, attr_name, &data); 76 iter (iter_cls, attr_name, &data);
77 zklaim_set_attr (&plw->pl, 77 zklaim_set_attr (&plw->pl,
78 data, 78 data,
79 j); 79 j);
80 attr_name = strtok (NULL, ","); 80 attr_name = strtok (attr_name + strlen (attr_name) + 1, ",");
81 } 81 }
82 if (NULL == attr_name)
83 break;
82 plw = plw->next; 84 plw = plw->next;
83 GNUNET_assert (NULL != plw); 85 GNUNET_assert (NULL != plw);
84 } 86 }
@@ -86,7 +88,7 @@ ZKLAIM_context_attributes_iterate (const struct GNUNET_ZKLAIM_Context *ctx,
86 88
87} 89}
88 90
89void 91int
90ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx, 92ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx,
91 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 93 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
92 GNUNET_ZKLAIM_PayloadIterator iter, 94 GNUNET_ZKLAIM_PayloadIterator iter,
@@ -95,8 +97,8 @@ ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx,
95 ZKLAIM_context_attributes_iterate (ctx, 97 ZKLAIM_context_attributes_iterate (ctx,
96 iter, 98 iter,
97 iter_cls); 99 iter_cls);
98 ZKLAIM_context_sign (ctx, 100 return ZKLAIM_context_sign (ctx,
99 key); 101 key);
100} 102}
101 103
102void 104void
diff --git a/src/zklaim/zklaim_functions.h b/src/zklaim/zklaim_functions.h
index 0497d5eb7..8542023db 100644
--- a/src/zklaim/zklaim_functions.h
+++ b/src/zklaim/zklaim_functions.h
@@ -63,7 +63,7 @@ ZKLAIM_context_attributes_iterate (const struct GNUNET_ZKLAIM_Context *ctx,
63 void *iter_cls); 63 void *iter_cls);
64 64
65 65
66void 66int
67ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx, 67ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx,
68 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 68 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
69 GNUNET_ZKLAIM_PayloadIterator iter, 69 GNUNET_ZKLAIM_PayloadIterator iter,