#include "gnunet_signatures.h"
#include "identity_token.h"
#include <jansson.h>
+#include <inttypes.h>
#define JWT_ALG "alg"
&enc_key,
&enc_iv,
str_buf);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted bytes: %d Expected bytes: %d\n", str_size, cyphertext_len);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Decrypted bytes: %zd Expected bytes: %zd\n",
+ str_size,
+ cyphertext_len);
if (-1 == str_size)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ECDH invalid\n");
pub_key,
&new_key_hash));
create_sym_key_from_ecdh(&new_key_hash, &skey, &iv);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting string %s\n (len=%d)",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting string %s\n (len=%zd)",
plaintext,
strlen (plaintext));
enc_size = GNUNET_CRYPTO_symmetric_encrypt (plaintext,
strlen (plaintext),
&skey, &iv,
*cyphertext);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted (len=%d)", enc_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted (len=%zd)", enc_size);
return GNUNET_OK;
}
}
struct TokenTicketPayload*
-ticket_payload_create (const char* nonce,
+ticket_payload_create (uint64_t nonce,
const struct GNUNET_CRYPTO_EcdsaPublicKey* identity_pkey,
const char* lbl_str)
{
struct TokenTicketPayload* payload;
payload = GNUNET_malloc (sizeof (struct TokenTicketPayload));
- GNUNET_asprintf (&payload->nonce, nonce, strlen (nonce));
+ payload->nonce = nonce;
payload->identity_key = *identity_pkey;
GNUNET_asprintf (&payload->label, lbl_str, strlen (lbl_str));
return payload;
void
ticket_payload_destroy (struct TokenTicketPayload* payload)
{
- if (NULL != payload->nonce)
- GNUNET_free (payload->nonce);
if (NULL != payload->label)
GNUNET_free (payload->label);
GNUNET_free (payload);
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
GNUNET_asprintf (result,
- "{\"nonce\": \"%u\",\"identity\": \"%s\",\"label\": \"%s\"}",
+ "{\"nonce\": \"%"SCNu64"\",\"identity\": \"%s\",\"label\": \"%s\"}",
payload->nonce, identity_key_str, payload->label);
GNUNET_free (identity_key_str);
* data and E
*/
struct TokenTicket*
-ticket_create (const char* nonce_str,
+ticket_create (uint64_t nonce,
const struct GNUNET_CRYPTO_EcdsaPublicKey* identity_pkey,
const char* lbl_str,
const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key)
struct TokenTicketPayload *code_payload;
ticket = GNUNET_malloc (sizeof (struct TokenTicket));
- code_payload = ticket_payload_create (nonce_str,
+ code_payload = ticket_payload_create (nonce,
identity_pkey,
lbl_str);
ticket->aud_key = *aud_key;
json_t *nonce_json;
json_error_t err_json;
char* data_str;
+ uint64_t nonce;
struct GNUNET_CRYPTO_EcdsaPublicKey id_pkey;
if (GNUNET_OK != decrypt_str_ecdhe (priv_key,
nonce_str = json_string_value (nonce_json);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found nonce: %s\n", nonce_str);
+
+ GNUNET_assert (0 != sscanf (nonce_str, "%"SCNu64, &nonce));
- *result = ticket_payload_create (nonce_str,
+ *result = ticket_payload_create (nonce,
(const struct GNUNET_CRYPTO_EcdsaPublicKey*)&id_pkey,
label_str);
GNUNET_free (data_str);