diff options
Diffstat (limited to 'src/zklaim/zklaim_api.c')
-rw-r--r-- | src/zklaim/zklaim_api.c | 30 |
1 files changed, 18 insertions, 12 deletions
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 | ||
521 | void | 527 | int |
522 | GNUNET_ZKLAIM_issue_from_context (struct GNUNET_ZKLAIM_Context *ctx, | 528 | GNUNET_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 */ |