/*
- This file is part of GNUnet
- Copyright (C) 2010-2015 GNUnet e.V.
+ This file is part of GNUnet
+ Copyright (C) 2010-2015 GNUnet e.V.
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- SPDX-License-Identifier: AGPL3.0-or-later
- */
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
/**
* @file reclaim/oidc_helper.c
#include "platform.h"
#include <inttypes.h>
#include <jansson.h>
-
#include "gnunet_util_lib.h"
-
#include "gnunet_reclaim_attribute_lib.h"
#include "gnunet_reclaim_service.h"
#include "gnunet_signatures.h"
#include "oidc_helper.h"
+
+
static char *
create_jwt_header (void)
{
NULL);
GNUNET_CRYPTO_kdf (iv,
sizeof (
- struct GNUNET_CRYPTO_SymmetricInitializationVector),
+ struct GNUNET_CRYPTO_SymmetricInitializationVector),
ctx_iv,
strlen (ctx_iv),
key_material,
calculate_key_pub (&key, &iv, ecdsa_pub, ecdh_priv);
GNUNET_break (
- GNUNET_CRYPTO_symmetric_encrypt (payload, payload_len, &key, &iv, buf));
+ GNUNET_CRYPTO_symmetric_encrypt (payload, payload_len, &key, &iv, buf));
}
attrs_ser = NULL;
signature_payload_len =
sizeof (struct GNUNET_RECLAIM_Ticket) + sizeof (uint32_t);
+
if (NULL != attrs)
{
attr_list_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
attrs_ser = GNUNET_malloc (attr_list_len);
GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, attrs_ser);
}
+
code_payload_len = sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
- sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) +
- signature_payload_len +
- sizeof (struct GNUNET_CRYPTO_EcdsaSignature);
+ sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) +
+ signature_payload_len +
+ sizeof (struct GNUNET_CRYPTO_EcdsaSignature);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Length of data to encode: %lu\n",
code_payload_len);
buf_ptr = plaintext;
memcpy (buf_ptr, ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
buf_ptr += sizeof (struct GNUNET_RECLAIM_Ticket);
+
// Then copy nonce
nonce = 0;
- if (NULL != nonce_str)
+ if (NULL != nonce_str && strcmp("", nonce_str) != 0)
{
if ((1 != SSCANF (nonce_str, "%u", &nonce)) || (nonce > UINT32_MAX))
{
nonce_tmp = htonl (nonce);
memcpy (buf_ptr, &nonce_tmp, sizeof (uint32_t));
buf_ptr += sizeof (uint32_t);
+
// Finally, attributes
if (NULL != attrs_ser)
{
memcpy (buf_ptr, attrs_ser, attr_list_len);
- buf_ptr += attr_list_len;
GNUNET_free (attrs_ser);
}
// Generate ECDH key
GNUNET_CRYPTO_ecdsa_sign (issuer,
purpose,
(struct GNUNET_CRYPTO_EcdsaSignature *)
- buf_ptr))
+ buf_ptr))
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to sign code\n");
code_payload_len =
GNUNET_STRINGS_base64_decode (code, strlen (code), (void **) &code_payload);
if (code_payload_len < sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
- sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) +
- sizeof (struct GNUNET_RECLAIM_Ticket) +
- sizeof (uint32_t) +
- sizeof (struct GNUNET_CRYPTO_EcdsaSignature))
+ sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) +
+ sizeof (struct GNUNET_RECLAIM_Ticket) +
+ sizeof (uint32_t) +
+ sizeof (struct GNUNET_CRYPTO_EcdsaSignature))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Authorization code malformed\n");
GNUNET_free_non_null (code_payload);