- fix
[oweals/gnunet.git] / src / identity-provider / gnunet-service-identity-provider.c
index db23c179b292fda0c7811ff301754d23af9b1700..3328035e6ff299a774bc2e09aff0422487623293 100644 (file)
@@ -1,6 +1,6 @@
 /*
    This file is part of GNUnet.
-   Copyright (C) 2012-2015 Christian Grothoff (and other contributing authors)
+   Copyright (C) 2012-2015 GNUnet e.V.
 
    GNUnet is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
@@ -35,6 +35,7 @@
 #include "gnunet_signatures.h"
 #include "identity_provider.h"
 #include "identity_token.h"
+#include <inttypes.h>
 
 /**
  * First pass state
@@ -368,11 +369,11 @@ handle_token_update (void *cls,
     if (0 == strcmp (attr->name, "exp"))
     {
       sscanf (attr->val_head->value,
-              "%lu",
+              "%"SCNu64,
               &token_exp.abs_value_us);
     } else if (0 == strcmp (attr->name, "nbf")) {
       sscanf (attr->val_head->value,
-              "%lu",
+              "%"SCNu64,
               &token_nbf.abs_value_us);
     }
   }
@@ -876,7 +877,8 @@ do_shutdown (void *cls,
 
 static struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage*
 create_exchange_result_message (const char* token,
-                                const char* label)
+                                const char* label,
+                                uint64_t ticket_nonce)
 {
   struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage *erm;
   uint16_t token_len = strlen (token) + 1;
@@ -885,6 +887,7 @@ create_exchange_result_message (const char* token,
   erm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT);
   erm->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage) 
                             + token_len);
+  erm->ticket_nonce = htonl (ticket_nonce);
   memcpy (&erm[1], token, token_len);
   return erm;
 }
@@ -1007,12 +1010,12 @@ sign_and_return_token (void *cls,
 
   //Remote nonce 
   nonce_str = NULL;
-  GNUNET_asprintf (&nonce_str, "%d", handle->nonce);
+  GNUNET_asprintf (&nonce_str, "%lu", handle->nonce);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request nonce: %s\n", nonce_str);
 
   GNUNET_CRYPTO_ecdsa_key_get_public (&handle->iss_key,
                                       &pub_key);
-  handle->ticket = ticket_create (nonce_str,
+  handle->ticket = ticket_create (handle->nonce,
                                   &pub_key,
                                   handle->label,
                                   &handle->aud_key);
@@ -1190,7 +1193,8 @@ process_lookup_result (void *cls, uint32_t rd_count,
                                                &token_str));
 
   erm = create_exchange_result_message (token_str,
-                                        handle->label);
+                                        handle->label,
+                                        handle->ticket->payload->nonce);
   GNUNET_SERVER_notification_context_unicast (nc,
                                               handle->client,
                                               &erm->header,
@@ -1248,7 +1252,7 @@ handle_exchange_message (void *cls,
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Looking for token under %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for token under %s\n",
               xchange_handle->ticket->payload->label);
   GNUNET_asprintf (&lookup_query,
                    "%s.gnu",
@@ -1349,7 +1353,7 @@ find_existing_token (void *cls,
     char *tmp = GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA,
                                                   token_metadata_record->data,
                                                   token_metadata_record->data_size);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Token does not match audience %s vs %s. Moving on\n",
                 tmp2,
                 tmp);
@@ -1369,7 +1373,7 @@ find_existing_token (void *cls,
     if ((NULL != handle->attr_map) &&
         (GNUNET_YES != GNUNET_CONTAINER_multihashmap_contains (handle->attr_map, &key)))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Issued token does not include `%s'. Moving on\n", scope);
       GNUNET_free (tmp_scopes);
       GNUNET_NAMESTORE_zone_iterator_next (handle->ns_it);