/**
* Record type for identity attributes (of RECLAIM).
*/
-#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR 65544
+#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544
/**
* Record type for local ticket references
/**
* Record type for reclaim records
*/
-#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF 65550
+#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550
/**
* Record type for RECLAIM master
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553
/**
- * Record type for reclaim identity attestation
+ * Record type for an attribute attestation
*/
-#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR 65554
+#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION 65554
/**
- * Record type for reclaim identity references
+ * Record type for an attestation reference in a ticket
*/
-#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE 65555
+#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF 65555
/**
static const struct GNUNET_RECLAIM_Identifier GNUNET_RECLAIM_ID_ZERO;
#define GNUNET_RECLAIM_id_is_equal(a,b) ((0 == \
- memcmp (a,\
- b,\
- sizeof (GNUNET_RECLAIM_ID_ZERO))) ?\
- GNUNET_YES : GNUNET_NO)
+ memcmp (a, \
+ b, \
+ sizeof (GNUNET_RECLAIM_ID_ZERO))) \
+ ? \
+ GNUNET_YES : GNUNET_NO)
-#define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal(a,\
- &GNUNET_RECLAIM_ID_ZERO)
+#define GNUNET_RECLAIM_id_is_zero(a) GNUNET_RECLAIM_id_is_equal (a, \
+ & \
+ GNUNET_RECLAIM_ID_ZERO)
#define GNUNET_RECLAIM_id_generate(id) \
- (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,\
- id,\
+ (GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, \
+ id, \
sizeof (GNUNET_RECLAIM_ID_ZERO)))
/**
* An attribute.
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim
+struct GNUNET_RECLAIM_Attribute
{
/**
* ID
*/
struct GNUNET_RECLAIM_Identifier id;
+ /**
+ * Referenced ID of Attestation (may be 0 if self-attested)
+ */
+ struct GNUNET_RECLAIM_Identifier attestation;
+
/**
* Type of Claim
*/
* Flags
*/
uint32_t flag;
+
/**
* The name of the attribute. Note "name" must never be individually
* free'd
/**
* An attestation.
*/
-struct GNUNET_RECLAIM_ATTESTATION_Claim
+struct GNUNET_RECLAIM_Attestation
{
/**
* ID
const void *data;
};
+
/**
- * A reference to an Attestatiom.
+ * A list of GNUNET_RECLAIM_Attribute structures.
*/
-struct GNUNET_RECLAIM_ATTESTATION_REFERENCE
+struct GNUNET_RECLAIM_AttributeList
{
/**
- * ID
+ * List head
*/
- struct GNUNET_RECLAIM_Identifier id;
+ struct GNUNET_RECLAIM_AttributeListEntry *list_head;
/**
- * Referenced ID of Attestation
+ * List tail
*/
- struct GNUNET_RECLAIM_Identifier id_attest;
+ struct GNUNET_RECLAIM_AttributeListEntry *list_tail;
+};
+
+struct GNUNET_RECLAIM_AttributeListEntry
+{
/**
- * The name of the attribute/attestation reference value. Note "name" must never be individually
- * free'd
+ * DLL
*/
- const char *name;
+ struct GNUNET_RECLAIM_AttributeListEntry *prev;
/**
- * The name of the attribute/attestation reference value. Note "name" must never be individually
- * free'd
+ * DLL
+ */
+ struct GNUNET_RECLAIM_AttributeListEntry *next;
+
+ /**
+ * The attribute claim
*/
- const char *reference_value;
+ struct GNUNET_RECLAIM_Attribute *attribute;
+
};
/**
- * A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
+ * A list of GNUNET_RECLAIM_Attestation structures.
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList
+struct GNUNET_RECLAIM_AttestationList
{
/**
* List head
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_head;
+ struct GNUNET_RECLAIM_AttestationListEntry *list_head;
/**
* List tail
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail;
+ struct GNUNET_RECLAIM_AttestationListEntry *list_tail;
};
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
+struct GNUNET_RECLAIM_AttestationListEntry
{
/**
* DLL
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *prev;
+ struct GNUNET_RECLAIM_AttestationListEntry *prev;
/**
* DLL
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *next;
+ struct GNUNET_RECLAIM_AttestationListEntry *next;
/**
- * The attribute claim
+ * The attestation
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
- /**
- * The attestation claim
- */
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
+ struct GNUNET_RECLAIM_Attestation *attestation;
- /**
- * The reference
- */
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
-};
-
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType
-{
- uint32_t type;
};
* Create a new attribute claim.
*
* @param attr_name the attribute name
+ * @param attestation ID of the attestation (may be NULL)
* @param type the attribute type
- * @param data the attribute value
+ * @param data the attribute value. Must be the mapped name if attestation not NULL
* @param data_size the attribute value size
* @return the new attribute
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
- uint32_t type,
- const void *data,
- size_t data_size);
+struct GNUNET_RECLAIM_Attribute *
+GNUNET_RECLAIM_attribute_new (const char *attr_name,
+ const struct GNUNET_RECLAIM_Identifier *attestation,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
/**
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+GNUNET_RECLAIM_attribute_list_serialize_get_size (
+ const struct GNUNET_RECLAIM_AttributeList *attrs);
/**
* @param attrs list to destroy
*/
void
-GNUNET_RECLAIM_ATTRIBUTE_list_destroy (
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+GNUNET_RECLAIM_attribute_list_destroy (
+ struct GNUNET_RECLAIM_AttributeList *attrs);
/**
* Add a new attribute to a claim list
*
+ * @param attrs the attribute list to add to
* @param attr_name the name of the new attribute claim
+ * @param attestation attestation ID (may be NULL)
* @param type the type of the claim
* @param data claim payload
* @param data_size claim payload size
*/
void
-GNUNET_RECLAIM_ATTRIBUTE_list_add (
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+GNUNET_RECLAIM_attribute_list_add (
+ struct GNUNET_RECLAIM_AttributeList *attrs,
const char *attr_name,
+ const struct GNUNET_RECLAIM_Identifier *attestation,
uint32_t type,
const void *data,
size_t data_size);
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+GNUNET_RECLAIM_attribute_list_serialize (
+ const struct GNUNET_RECLAIM_AttributeList *attrs,
char *result);
* @param data_size the length of the serialized data
* @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
-GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size);
-
-/**
- * Count attestations in claim list
- *
- * @param attrs list
- */
-int
-GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+struct GNUNET_RECLAIM_AttributeList *
+GNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size);
/**
* Get required size for serialization buffer
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr);
+GNUNET_RECLAIM_attribute_serialize_get_size (
+ const struct GNUNET_RECLAIM_Attribute *attr);
/**
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_serialize (
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- char *result);
+GNUNET_RECLAIM_attribute_serialize (const struct GNUNET_RECLAIM_Attribute *attr,
+ char *result);
/**
*
* @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size);
+struct GNUNET_RECLAIM_Attribute *
+GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size);
/**
* @param attrs claim list to copy
* @return copied claim list
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
-GNUNET_RECLAIM_ATTRIBUTE_list_dup (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+struct GNUNET_RECLAIM_AttributeList *
+GNUNET_RECLAIM_attribute_list_dup (
+ const struct GNUNET_RECLAIM_AttributeList *attrs);
/**
* @return corresponding number, UINT32_MAX on error
*/
uint32_t
-GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename);
+GNUNET_RECLAIM_attribute_typename_to_number (const char *typename);
/**
* Convert human-readable version of a 'claim' of an attribute to the binary
* @return #GNUNET_OK on success
*/
int
-GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
+GNUNET_RECLAIM_attribute_string_to_value (uint32_t type,
const char *s,
void **data,
size_t *data_size);
* @return NULL on error, otherwise human-readable representation of the claim
*/
char *
-GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
+GNUNET_RECLAIM_attribute_value_to_string (uint32_t type,
const void *data,
size_t data_size);
-
/**
* Convert a type number to the corresponding type string
*
* @return corresponding typestring, NULL on error
*/
const char *
-GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type);
-
-/**
- * Get required size for serialization buffer
- * FIXME:
- * 1. The naming convention is violated here.
- * It should GNUNET_RECLAIM_ATTRIBUTE_<lowercase from here>.
- * It might make sense to refactor attestations into a separate folder.
- * 2. The struct should be called GNUNET_RECLAIM_ATTESTATION_Data or
- * GNUNET_RECLAIM_ATTRIBUTE_Attestation depending on location in source.
- *
- * @param attr the attestation to serialize
+GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type);
+
+
+/**
+ * Get required size for serialization buffer
+ *
+ * @param attrs the attribute list to serialize
+ * @return the required buffer size
+ */
+size_t
+GNUNET_RECLAIM_attestation_list_serialize_get_size (
+ const struct GNUNET_RECLAIM_AttestationList *attestations);
+
+
+/**
+ * Destroy claim list
+ *
+ * @param attrs list to destroy
+ */
+void
+GNUNET_RECLAIM_attestation_list_destroy (
+ struct GNUNET_RECLAIM_AttestationList *attestations);
+
+
+/**
+ * Add a new attribute to a claim list
+ *
+ * @param attr_name the name of the new attribute claim
+ * @param type the type of the claim
+ * @param data claim payload
+ * @param data_size claim payload size
+ */
+void
+GNUNET_RECLAIM_attestation_list_add (
+ struct GNUNET_RECLAIM_AttestationList *attrs,
+ const char *att_name,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
+
+
+/**
+ * Serialize an attribute list
+ *
+ * @param attrs the attribute list to serialize
+ * @param result the serialized attribute
+ * @return length of serialized data
+ */
+size_t
+GNUNET_RECLAIM_attestation_list_serialize (
+ const struct GNUNET_RECLAIM_AttestationList *attrs,
+ char *result);
+
+
+/**
+ * Deserialize an attribute list
+ *
+ * @param data the serialized attribute list
+ * @param data_size the length of the serialized data
+ * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
+ */
+struct GNUNET_RECLAIM_AttestationList *
+GNUNET_RECLAIM_attestation_list_deserialize (const char *data,
+ size_t data_size);
+
+
+
+/**
+ * @param attestation the attestation to serialize
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTESTATION_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr);
+GNUNET_RECLAIM_attestation_serialize_get_size (
+ const struct GNUNET_RECLAIM_Attestation *attestation);
/**
* Serialize an attestation
*
- * @param attr the attestation to serialize
+ * @param attestation the attestation to serialize
* @param result the serialized attestation
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTESTATION_serialize (
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
+GNUNET_RECLAIM_attestation_serialize (
+ const struct GNUNET_RECLAIM_Attestation *attestation,
char *result);
*
* @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
*/
-struct GNUNET_RECLAIM_ATTESTATION_Claim *
-GNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size);
+struct GNUNET_RECLAIM_Attestation *
+GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size);
/**
- * Create a new attestation.
- *
- * @param attr_name the attestation name
- * @param type the attestation type
- * @param data the attestation value
- * @param data_size the attestation value size
- * @return the new attestation
- */
-struct GNUNET_RECLAIM_ATTESTATION_Claim *
-GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name,
- uint32_t type,
- const void *data,
- size_t data_size);
+ * Create a new attestation.
+ *
+ * @param name the attestation name
+ * @param type the attestation type
+ * @param data the attestation value
+ * @param data_size the attestation value size
+ * @return the new attestation
+ */
+struct GNUNET_RECLAIM_Attestation *
+GNUNET_RECLAIM_attestation_new (const char *name,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
/**
* Convert the 'claim' of an attestation to a string
* @return NULL on error, otherwise human-readable representation of the claim
*/
char *
-GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type,
+GNUNET_RECLAIM_attestation_value_to_string (uint32_t type,
const void *data,
size_t data_size);
* @return #GNUNET_OK on success
*/
int
-GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type,
+GNUNET_RECLAIM_attestation_string_to_value (uint32_t type,
const char *s,
void **data,
size_t *data_size);
* @return corresponding typestring, NULL on error
*/
const char *
-GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type);
+GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type);
/**
* Convert an attestation type name to the corresponding number
* @return corresponding number, UINT32_MAX on error
*/
uint32_t
-GNUNET_RECLAIM_ATTESTATION_typename_to_number (const char *typename);
-
-/**
- * Create a new attestation reference.
- *
- * @param attr_name the referenced claim name
- * @param ref_value the claim name in the attestation
- * @return the new reference
- */
-struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
-GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name,
- const char *ref_value);
-
-
-/**
- * Get required size for serialization buffer
- *
- * @param attr the reference to serialize
- * @return the required buffer size
- */
-size_t
-GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr);
+GNUNET_RECLAIM_attestation_typename_to_number (const char *typename);
-/**
- * Serialize a reference
- *
- * @param attr the reference to serialize
- * @param result the serialized reference
- * @return length of serialized data
- */
-size_t
-GNUNET_RECLAIM_ATTESTATION_REF_serialize (
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
- char *result);
-
-/**
- * Deserialize a reference
- *
- * @param data the serialized reference
- * @param data_size the length of the serialized data
- *
- * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
- */
-struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
-GNUNET_RECLAIM_ATTESTATION_REF_deserialize (const char *data, size_t data_size);
#if 0 /* keep Emacsens' auto-indent happy */
{
+++ /dev/null
-/*
- This file is part of GNUnet
- Copyright (C) 2012, 2013 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 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @author Martin Schanzenbach
- *
- * @file
- * Plugin API for reclaim attribute types
- *
- * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims
- * @{
- */
-#ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
-#define GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
-
-#include "gnunet_util_lib.h"
-#include "gnunet_reclaim_attribute_lib.h"
-
-#ifdef __cplusplus
-extern "C" {
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-/**
- * Function called to convert the binary value @a data of an attribute of
- * type @a type to a human-readable string.
- *
- * @param cls closure
- * @param type type of the attribute
- * @param data value in binary encoding
- * @param data_size number of bytes in @a data
- * @return NULL on error, otherwise human-readable representation of the value
- */
-typedef char *(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (
- void *cls,
- uint32_t type,
- const void *data,
- size_t data_size);
-
-
-/**
- * Function called to convert human-readable version of the value @a s
- * of an attribute of type @a type to the respective binary
- * representation.
- *
- * @param cls closure
- * @param type type of the attribute
- * @param s human-readable string
- * @param data set to value in binary encoding (will be allocated)
- * @param data_size set to number of bytes in @a data
- * @return #GNUNET_OK on success
- */
-typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (
- void *cls,
- uint32_t type,
- const char *s,
- void **data,
- size_t *data_size);
-
-
-/**
- * Function called to convert a type name to the
- * corresponding number.
- *
- * @param cls closure
- * @param typename name to convert
- * @return corresponding number, UINT32_MAX on error
- */
-typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (
- void *cls,
- const char *typename);
-
-
-/**
- * Function called to convert a type number (i.e. 1) to the
- * corresponding type string
- *
- * @param cls closure
- * @param type number of a type to convert
- * @return corresponding typestring, NULL on error
- */
-typedef const char *(*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) (
- void *cls,
- uint32_t type);
-
-
-/**
- * Each plugin is required to return a pointer to a struct of this
- * type as the return value from its entry point.
- */
-struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions
-{
- /**
- * Closure for all of the callbacks.
- */
- void *cls;
-
- /**
- * Conversion to string.
- */
- GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string;
-
- /**
- * Conversion to binary.
- */
- GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value;
-
- /**
- * Typename to number.
- */
- GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number;
-
- /**
- * Number to typename.
- */
- GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename;
-
- /**
- * FIXME: It is odd that attestation functions are withing the attribute
- * plugin. An attribute type may be backed by an attestation, but not
- * necessarily.
- * Maybe it would make more sense to refactor this into an attestation
- * plugin?
- *
- * Attestation Conversion to string.
- */
- GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string_attest;
-
- /**
- * Attestation Conversion to binary.
- */
- GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value_attest;
-
- /**
- * Attestation Typename to number.
- */
- GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number_attest;
-
- /**
- * Attestation Number to typename.
- */
- GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename_attest;
-
-};
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/** @} */ /* end of group */
--- /dev/null
+/*
+ This file is part of GNUnet
+ Copyright (C) 2012, 2013 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 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/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @author Martin Schanzenbach
+ *
+ * @file
+ * Plugin API for reclaim attribute types
+ *
+ * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims
+ * @{
+ */
+#ifndef GNUNET_RECLAIM_AttributePLUGIN_H
+#define GNUNET_RECLAIM_AttributePLUGIN_H
+
+#include "gnunet_util_lib.h"
+#include "gnunet_reclaim_attribute_lib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+/**
+ * Function called to convert the binary value @a data of an attribute of
+ * type @a type to a human-readable string.
+ *
+ * @param cls closure
+ * @param type type of the attribute
+ * @param data value in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the value
+ */
+typedef char *(*GNUNET_RECLAIM_AttributeValueToStringFunction) (
+ void *cls,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
+
+
+/**
+ * Function called to convert human-readable version of the value @a s
+ * of an attribute of type @a type to the respective binary
+ * representation.
+ *
+ * @param cls closure
+ * @param type type of the attribute
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+typedef int (*GNUNET_RECLAIM_AttributeStringToValueFunction) (
+ void *cls,
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size);
+
+
+/**
+ * Function called to convert a type name to the
+ * corresponding number.
+ *
+ * @param cls closure
+ * @param typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+typedef uint32_t (*GNUNET_RECLAIM_AttributeTypenameToNumberFunction) (
+ void *cls,
+ const char *typename);
+
+
+/**
+ * Function called to convert a type number (i.e. 1) to the
+ * corresponding type string
+ *
+ * @param cls closure
+ * @param type number of a type to convert
+ * @return corresponding typestring, NULL on error
+ */
+typedef const char *(*GNUNET_RECLAIM_AttributeNumberToTypenameFunction) (
+ void *cls,
+ uint32_t type);
+
+/**
+ * Function called to convert the binary value @a data of an attribute of
+ * type @a type to a human-readable string.
+ *
+ * @param cls closure
+ * @param type type of the attribute
+ * @param data value in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the value
+ */
+typedef char *(*GNUNET_RECLAIM_AttestationValueToStringFunction) (
+ void *cls,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
+
+
+/**
+ * Function called to convert human-readable version of the value @a s
+ * of an attribute of type @a type to the respective binary
+ * representation.
+ *
+ * @param cls closure
+ * @param type type of the attribute
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+typedef int (*GNUNET_RECLAIM_AttestationStringToValueFunction) (
+ void *cls,
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size);
+
+
+/**
+ * Function called to convert a type name to the
+ * corresponding number.
+ *
+ * @param cls closure
+ * @param typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+typedef uint32_t (*GNUNET_RECLAIM_AttestationTypenameToNumberFunction) (
+ void *cls,
+ const char *typename);
+
+
+/**
+ * Function called to convert a type number (i.e. 1) to the
+ * corresponding type string
+ *
+ * @param cls closure
+ * @param type number of a type to convert
+ * @return corresponding typestring, NULL on error
+ */
+typedef const char *(*GNUNET_RECLAIM_AttestationNumberToTypenameFunction) (
+ void *cls,
+ uint32_t type);
+
+
+
+/**
+ * Each plugin is required to return a pointer to a struct of this
+ * type as the return value from its entry point.
+ */
+struct GNUNET_RECLAIM_AttributePluginFunctions
+{
+ /**
+ * Closure for all of the callbacks.
+ */
+ void *cls;
+
+ /**
+ * Conversion to string.
+ */
+ GNUNET_RECLAIM_AttributeValueToStringFunction value_to_string;
+
+ /**
+ * Conversion to binary.
+ */
+ GNUNET_RECLAIM_AttributeStringToValueFunction string_to_value;
+
+ /**
+ * Typename to number.
+ */
+ GNUNET_RECLAIM_AttributeTypenameToNumberFunction typename_to_number;
+
+ /**
+ * Number to typename.
+ */
+ GNUNET_RECLAIM_AttributeNumberToTypenameFunction number_to_typename;
+
+};
+
+/**
+ * Each plugin is required to return a pointer to a struct of this
+ * type as the return value from its entry point.
+ */
+struct GNUNET_RECLAIM_AttestationPluginFunctions
+{
+ /**
+ * Closure for all of the callbacks.
+ */
+ void *cls;
+
+ /**
+ * Conversion to string.
+ */
+ GNUNET_RECLAIM_AttestationValueToStringFunction value_to_string;
+
+ /**
+ * Conversion to binary.
+ */
+ GNUNET_RECLAIM_AttestationStringToValueFunction string_to_value;
+
+ /**
+ * Typename to number.
+ */
+ GNUNET_RECLAIM_AttestationTypenameToNumberFunction typename_to_number;
+
+ /**
+ * Number to typename.
+ */
+ GNUNET_RECLAIM_AttestationNumberToTypenameFunction number_to_typename;
+
+};
+
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/** @} */ /* end of group */
* @param cls The callback closure
* @param identity The identity authoritative over the attributes
* @param attr The attribute
+ * @param attestation The attestation for the attribute (may be NULL)
*/
typedef void (*GNUNET_RECLAIM_AttributeResult) (
void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference);
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attestation);
+
+
+/**
+ * Callback used to notify the client of attestation results.
+ *
+ * @param cls The callback closure
+ * @param identity The identity authoritative over the attributes
+ * @param attr The attribute
+ */
+typedef void (*GNUNET_RECLAIM_AttestationResult) (
+ void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
+ const struct GNUNET_RECLAIM_Attestation *attestation);
/**
GNUNET_RECLAIM_attribute_store (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
+ const struct GNUNET_RECLAIM_Attribute *attr,
const struct GNUNET_TIME_Relative *exp_interval,
GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
GNUNET_RECLAIM_attestation_store (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
+ const struct GNUNET_RECLAIM_Attestation *attestation,
const struct GNUNET_TIME_Relative *exp_interval,
GNUNET_RECLAIM_ContinuationWithStatus cont,
void *cont_cls);
GNUNET_RECLAIM_attribute_delete (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
+ const struct GNUNET_RECLAIM_Attribute *attr,
GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
/**
GNUNET_RECLAIM_attestation_delete (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
+ const struct GNUNET_RECLAIM_Attestation *attr,
GNUNET_RECLAIM_ContinuationWithStatus cont,
void *cont_cls);
-/**
- * Delete an attestation reference. Tickets used to share this reference are updated
- * accordingly.
- *
- * @param h handle to the re:claimID service
- * @param pkey Private key of the identity to delete the reference from
- * @param attr The reference
- * @param cont Continuation to call when done
- * @param cont_cls Closure for @a cont
- * @return handle Used to to abort the request
- */
-struct GNUNET_RECLAIM_Operation *
-GNUNET_RECLAIM_attestation_reference_delete (
- struct GNUNET_RECLAIM_Handle *h,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
- GNUNET_RECLAIM_ContinuationWithStatus cont,
- void *cont_cls);
/**
* List all attributes for a local identity.
* This MUST lock the `struct GNUNET_RECLAIM_Handle`
GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
-/**
- * Store an attestation reference. If the reference is already present,
- * it is replaced with the new reference.
- *
- * @param h handle to the re:claimID service
- * @param pkey private key of the identity
- * @param attr the reference value
- * @param exp_interval the relative expiration interval for the reference
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_RECLAIM_Operation *
-GNUNET_RECLAIM_attestation_reference_store (
- struct GNUNET_RECLAIM_Handle *h,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
- const struct GNUNET_TIME_Relative *exp_interval,
- GNUNET_RECLAIM_ContinuationWithStatus cont,
- void *cont_cls);
/**
* Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ const struct GNUNET_RECLAIM_AttributeList *attrs,
GNUNET_RECLAIM_TicketCallback cb, void *cb_cls);
libgnunetreclaimattribute_la_SOURCES = \
reclaim_attribute.h \
- reclaim_attribute.c
+ reclaim_attribute.c \
+ reclaim_attestation.c
libgnunetreclaimattribute_la_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
plugin_LTLIBRARIES = \
- libgnunet_plugin_reclaim_attribute_gnuid.la
+ libgnunet_plugin_reclaim_attribute_basic.la \
+ libgnunet_plugin_reclaim_attestation_jwt.la
-libgnunet_plugin_reclaim_attribute_gnuid_la_SOURCES = \
- plugin_reclaim_attribute_gnuid.c
-libgnunet_plugin_reclaim_attribute_gnuid_la_LIBADD = \
+libgnunet_plugin_reclaim_attribute_basic_la_SOURCES = \
+ plugin_reclaim_attribute_basic.c
+libgnunet_plugin_reclaim_attribute_basic_la_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(LTLIBINTL)
-libgnunet_plugin_reclaim_attribute_gnuid_la_LDFLAGS = \
+libgnunet_plugin_reclaim_attribute_basic_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
+libgnunet_plugin_reclaim_attestation_jwt_la_SOURCES = \
+ plugin_reclaim_attestation_jwt.c
+libgnunet_plugin_reclaim_attestation_jwt_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunet_plugin_reclaim_attestation_jwt_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
--- /dev/null
+/*
+ This file is part of GNUnet
+ Copyright (C) 2013, 2014, 2016 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 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/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file reclaim-attribute/plugin_reclaim_attestation_gnuid.c
+ * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for
+ * fundamental
+ * attribute types.
+ *
+ * @author Martin Schanzenbach
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_reclaim_plugin.h"
+#include <inttypes.h>
+
+
+/**
+ * Convert the 'value' of an attestation to a string.
+ *
+ * @param cls closure, unused
+ * @param type type of the attestation
+ * @param data value in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the value
+ */
+static char *
+jwt_value_to_string (void *cls,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
+{
+ switch (type)
+ {
+ case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
+ return GNUNET_strndup (data, data_size);
+
+ default:
+ return NULL;
+ }
+}
+
+
+/**
+ * Convert human-readable version of a 'value' of an attestation to the binary
+ * representation.
+ *
+ * @param cls closure, unused
+ * @param type type of the attestation
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+static int
+jwt_string_to_value (void *cls,
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size)
+{
+ if (NULL == s)
+ return GNUNET_SYSERR;
+ switch (type)
+ {
+ case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
+ *data = GNUNET_strdup (s);
+ *data_size = strlen (s);
+ return GNUNET_OK;
+
+ default:
+ return GNUNET_SYSERR;
+ }
+}
+
+
+/**
+ * Mapping of attestation type numbers to human-readable
+ * attestation type names.
+ */
+static struct
+{
+ const char *name;
+ uint32_t number;
+} jwt_attest_name_map[] = { { "JWT", GNUNET_RECLAIM_ATTESTATION_TYPE_JWT },
+ { NULL, UINT32_MAX } };
+
+/**
+ * Convert a type name to the corresponding number.
+ *
+ * @param cls closure, unused
+ * @param jwt_typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+static uint32_t
+jwt_typename_to_number (void *cls, const char *jwt_typename)
+{
+ unsigned int i;
+
+ i = 0;
+ while ((NULL != jwt_attest_name_map[i].name) &&
+ (0 != strcasecmp (jwt_typename, jwt_attest_name_map[i].name)))
+ i++;
+ return jwt_attest_name_map[i].number;
+}
+
+
+/**
+ * Convert a type number (i.e. 1) to the corresponding type string
+ *
+ * @param cls closure, unused
+ * @param type number of a type to convert
+ * @return corresponding typestring, NULL on error
+ */
+static const char *
+jwt_number_to_typename (void *cls, uint32_t type)
+{
+ unsigned int i;
+
+ i = 0;
+ while ((NULL != jwt_attest_name_map[i].name) && (type !=
+ jwt_attest_name_map[i].
+ number))
+ i++;
+ return jwt_attest_name_map[i].name;
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_plugin_reclaim_attestation_jwt_init (void *cls)
+{
+ struct GNUNET_RECLAIM_AttestationPluginFunctions *api;
+
+ api = GNUNET_new (struct GNUNET_RECLAIM_AttestationPluginFunctions);
+ api->value_to_string = &jwt_value_to_string;
+ api->string_to_value = &jwt_string_to_value;
+ api->typename_to_number = &jwt_typename_to_number;
+ api->number_to_typename = &jwt_number_to_typename;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from #libgnunet_plugin_block_test_init()
+ * @return NULL
+ */
+void *
+libgnunet_plugin_reclaim_attestation_jwt_done (void *cls)
+{
+ struct GNUNET_RECLAIM_AttestationPluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+/* end of plugin_reclaim_attestation_type_gnuid.c */
--- /dev/null
+/*
+ This file is part of GNUnet
+ Copyright (C) 2013, 2014, 2016 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 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/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c
+ * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for
+ * fundamental
+ * attribute types.
+ *
+ * @author Martin Schanzenbach
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_reclaim_plugin.h"
+#include <inttypes.h>
+
+
+/**
+ * Convert the 'value' of an attribute to a string.
+ *
+ * @param cls closure, unused
+ * @param type type of the attribute
+ * @param data value in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the value
+ */
+static char *
+basic_value_to_string (void *cls,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
+{
+ switch (type)
+ {
+ case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
+ return GNUNET_strndup (data, data_size);
+
+ default:
+ return NULL;
+ }
+}
+
+
+/**
+ * Convert human-readable version of a 'value' of an attribute to the binary
+ * representation.
+ *
+ * @param cls closure, unused
+ * @param type type of the attribute
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+static int
+basic_string_to_value (void *cls,
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size)
+{
+ if (NULL == s)
+ return GNUNET_SYSERR;
+ switch (type)
+ {
+ case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
+ *data = GNUNET_strdup (s);
+ *data_size = strlen (s);
+ return GNUNET_OK;
+
+ default:
+ return GNUNET_SYSERR;
+ }
+}
+
+/**
+ * Mapping of attribute type numbers to human-readable
+ * attribute type names.
+ */
+static struct
+{
+ const char *name;
+ uint32_t number;
+} basic_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
+ { NULL, UINT32_MAX } };
+
+
+/**
+ * Convert a type name to the corresponding number.
+ *
+ * @param cls closure, unused
+ * @param basic_typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+static uint32_t
+basic_typename_to_number (void *cls, const char *basic_typename)
+{
+ unsigned int i;
+
+ i = 0;
+ while ((NULL != basic_name_map[i].name) &&
+ (0 != strcasecmp (basic_typename, basic_name_map[i].name)))
+ i++;
+ return basic_name_map[i].number;
+}
+
+
+/**
+ * Convert a type number (i.e. 1) to the corresponding type string
+ *
+ * @param cls closure, unused
+ * @param type number of a type to convert
+ * @return corresponding typestring, NULL on error
+ */
+static const char *
+basic_number_to_typename (void *cls, uint32_t type)
+{
+ unsigned int i;
+
+ i = 0;
+ while ((NULL != basic_name_map[i].name) && (type != basic_name_map[i].number))
+ i++;
+ return basic_name_map[i].name;
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_plugin_reclaim_attribute_basic_init (void *cls)
+{
+ struct GNUNET_RECLAIM_AttributePluginFunctions *api;
+
+ api = GNUNET_new (struct GNUNET_RECLAIM_AttributePluginFunctions);
+ api->value_to_string = &basic_value_to_string;
+ api->string_to_value = &basic_string_to_value;
+ api->typename_to_number = &basic_typename_to_number;
+ api->number_to_typename = &basic_number_to_typename;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from #libgnunet_plugin_block_test_init()
+ * @return NULL
+ */
+void *
+libgnunet_plugin_reclaim_attribute_basic_done (void *cls)
+{
+ struct GNUNET_RECLAIM_AttributePluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+/* end of plugin_reclaim_attribute_type_gnuid.c */
+++ /dev/null
-/*
- This file is part of GNUnet
- Copyright (C) 2013, 2014, 2016 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 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c
- * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for
- * fundamental
- * attribute types.
- *
- * @author Martin Schanzenbach
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_reclaim_attribute_plugin.h"
-#include <inttypes.h>
-
-
-/**
- * Convert the 'value' of an attribute to a string.
- *
- * @param cls closure, unused
- * @param type type of the attribute
- * @param data value in binary encoding
- * @param data_size number of bytes in @a data
- * @return NULL on error, otherwise human-readable representation of the value
- */
-static char *
-gnuid_value_to_string (void *cls,
- uint32_t type,
- const void *data,
- size_t data_size)
-{
- switch (type)
- {
- case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
- return GNUNET_strndup (data, data_size);
-
- default:
- return NULL;
- }
-}
-
-
-/**
- * Convert human-readable version of a 'value' of an attribute to the binary
- * representation.
- *
- * @param cls closure, unused
- * @param type type of the attribute
- * @param s human-readable string
- * @param data set to value in binary encoding (will be allocated)
- * @param data_size set to number of bytes in @a data
- * @return #GNUNET_OK on success
- */
-static int
-gnuid_string_to_value (void *cls,
- uint32_t type,
- const char *s,
- void **data,
- size_t *data_size)
-{
- if (NULL == s)
- return GNUNET_SYSERR;
- switch (type)
- {
- case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
- *data = GNUNET_strdup (s);
- *data_size = strlen (s);
- return GNUNET_OK;
-
- default:
- return GNUNET_SYSERR;
- }
-}
-
-/**
- * Convert the 'value' of an attestation to a string.
- *
- * @param cls closure, unused
- * @param type type of the attestation
- * @param data value in binary encoding
- * @param data_size number of bytes in @a data
- * @return NULL on error, otherwise human-readable representation of the value
- */
-static char *
-gnuid_value_to_string_attest (void *cls,
- uint32_t type,
- const void *data,
- size_t data_size)
-{
- switch (type)
- {
- case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
- return GNUNET_strndup (data, data_size);
-
- default:
- return NULL;
- }
-}
-
-
-/**
- * Convert human-readable version of a 'value' of an attestation to the binary
- * representation.
- *
- * @param cls closure, unused
- * @param type type of the attestation
- * @param s human-readable string
- * @param data set to value in binary encoding (will be allocated)
- * @param data_size set to number of bytes in @a data
- * @return #GNUNET_OK on success
- */
-static int
-gnuid_string_to_value_attest (void *cls,
- uint32_t type,
- const char *s,
- void **data,
- size_t *data_size)
-{
- if (NULL == s)
- return GNUNET_SYSERR;
- switch (type)
- {
- case GNUNET_RECLAIM_ATTESTATION_TYPE_JWT:
- *data = GNUNET_strdup (s);
- *data_size = strlen (s);
- return GNUNET_OK;
-
- default:
- return GNUNET_SYSERR;
- }
-}
-
-/**
- * Mapping of attribute type numbers to human-readable
- * attribute type names.
- */
-static struct
-{
- const char *name;
- uint32_t number;
-} gnuid_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
- { NULL, UINT32_MAX } };
-
-/**
- * Mapping of attestation type numbers to human-readable
- * attestation type names.
- */
-static struct
-{
- const char *name;
- uint32_t number;
-} gnuid_attest_name_map[] = { { "JWT", GNUNET_RECLAIM_ATTESTATION_TYPE_JWT },
- { NULL, UINT32_MAX } };
-
-/**
- * Convert a type name to the corresponding number.
- *
- * @param cls closure, unused
- * @param gnuid_typename name to convert
- * @return corresponding number, UINT32_MAX on error
- */
-static uint32_t
-gnuid_typename_to_number (void *cls, const char *gnuid_typename)
-{
- unsigned int i;
-
- i = 0;
- while ((NULL != gnuid_name_map[i].name) &&
- (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name)))
- i++;
- return gnuid_name_map[i].number;
-}
-
-
-/**
- * Convert a type number (i.e. 1) to the corresponding type string
- *
- * @param cls closure, unused
- * @param type number of a type to convert
- * @return corresponding typestring, NULL on error
- */
-static const char *
-gnuid_number_to_typename (void *cls, uint32_t type)
-{
- unsigned int i;
-
- i = 0;
- while ((NULL != gnuid_name_map[i].name) && (type != gnuid_name_map[i].number))
- i++;
- return gnuid_name_map[i].name;
-}
-
-/**
- * Convert a type name to the corresponding number.
- *
- * @param cls closure, unused
- * @param gnuid_typename name to convert
- * @return corresponding number, UINT32_MAX on error
- */
-static uint32_t
-gnuid_typename_to_number_attest (void *cls, const char *gnuid_typename)
-{
- unsigned int i;
-
- i = 0;
- while ((NULL != gnuid_attest_name_map[i].name) &&
- (0 != strcasecmp (gnuid_typename, gnuid_attest_name_map[i].name)))
- i++;
- return gnuid_attest_name_map[i].number;
-}
-
-/**
- * Convert a type number (i.e. 1) to the corresponding type string
- *
- * @param cls closure, unused
- * @param type number of a type to convert
- * @return corresponding typestring, NULL on error
- */
-static const char *
-gnuid_number_to_typename_attest (void *cls, uint32_t type)
-{
- unsigned int i;
-
- i = 0;
- while ((NULL != gnuid_attest_name_map[i].name) && (type !=
- gnuid_attest_name_map[i].
- number))
- i++;
- return gnuid_attest_name_map[i].name;
-}
-
-/**
- * Entry point for the plugin.
- *
- * @param cls NULL
- * @return the exported block API
- */
-void *
-libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls)
-{
- struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api;
-
- api = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions);
- api->value_to_string = &gnuid_value_to_string;
- api->string_to_value = &gnuid_string_to_value;
- api->typename_to_number = &gnuid_typename_to_number;
- api->number_to_typename = &gnuid_number_to_typename;
- api->value_to_string_attest = &gnuid_value_to_string_attest;
- api->string_to_value_attest = &gnuid_string_to_value_attest;
- api->typename_to_number_attest = &gnuid_typename_to_number_attest;
- api->number_to_typename_attest = &gnuid_number_to_typename_attest;
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls the return value from #libgnunet_plugin_block_test_init()
- * @return NULL
- */
-void *
-libgnunet_plugin_reclaim_attribute_gnuid_done (void *cls)
-{
- struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls;
-
- GNUNET_free (api);
- return NULL;
-}
-
-
-/* end of plugin_reclaim_attribute_type_gnuid.c */
--- /dev/null
+/*
+ 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 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/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file reclaim-attribute/reclaim_attestation.c
+ * @brief helper library to manage identity attribute attestations
+ * @author Martin Schanzenbach
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_reclaim_plugin.h"
+#include "reclaim_attestation.h"
+
+
+/**
+ * Handle for a plugin
+ */
+struct Plugin
+{
+ /**
+ * Name of the plugin
+ */
+ char *library_name;
+
+ /**
+ * Plugin API
+ */
+ struct GNUNET_RECLAIM_AttestationPluginFunctions *api;
+};
+
+
+/**
+ * Plugins
+ */
+static struct Plugin **attest_plugins;
+
+
+/**
+ * Number of plugins
+ */
+static unsigned int num_plugins;
+
+
+/**
+ * Init canary
+ */
+static int initialized;
+
+
+/**
+ * Add a plugin
+ *
+ * @param cls closure
+ * @param library_name name of the API library
+ * @param lib_ret the plugin API pointer
+ */
+static void
+add_plugin (void *cls, const char *library_name, void *lib_ret)
+{
+ struct GNUNET_RECLAIM_AttestationPluginFunctions *api = lib_ret;
+ struct Plugin *plugin;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Loading attestation plugin `%s'\n",
+ library_name);
+ plugin = GNUNET_new (struct Plugin);
+ plugin->api = api;
+ plugin->library_name = GNUNET_strdup (library_name);
+ GNUNET_array_append (attest_plugins, num_plugins, plugin);
+}
+
+
+/**
+ * Load plugins
+ */
+static void
+init ()
+{
+ if (GNUNET_YES == initialized)
+ return;
+ initialized = GNUNET_YES;
+ GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attestation_",
+ NULL,
+ &add_plugin,
+ NULL);
+}
+
+
+/**
+ * Convert an attestation type name to the corresponding number
+ *
+ * @param typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+uint32_t
+GNUNET_RECLAIM_attestation_typename_to_number (const char *typename)
+{
+ unsigned int i;
+ struct Plugin *plugin;
+ uint32_t ret;
+ init ();
+ for (i = 0; i < num_plugins; i++)
+ {
+ plugin = attest_plugins[i];
+ if (UINT32_MAX !=
+ (ret = plugin->api->typename_to_number (plugin->api->cls,
+ typename)))
+ return ret;
+ }
+ return UINT32_MAX;
+}
+
+
+/**
+ * Convert an attestation type number to the corresponding attestation type string
+ *
+ * @param type number of a type
+ * @return corresponding typestring, NULL on error
+ */
+const char *
+GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type)
+{
+ unsigned int i;
+ struct Plugin *plugin;
+ const char *ret;
+
+ init ();
+ for (i = 0; i < num_plugins; i++)
+ {
+ plugin = attest_plugins[i];
+ if (NULL !=
+ (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
+ return ret;
+ }
+ return NULL;
+}
+
+
+/**
+ * Convert human-readable version of a 'claim' of an attestation to the binary
+ * representation
+ *
+ * @param type type of the claim
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+int
+GNUNET_RECLAIM_attestation_string_to_value (uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size)
+{
+ unsigned int i;
+ struct Plugin *plugin;
+
+ init ();
+ for (i = 0; i < num_plugins; i++)
+ {
+ plugin = attest_plugins[i];
+ if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
+ type,
+ s,
+ data,
+ data_size))
+ return GNUNET_OK;
+ }
+ return GNUNET_SYSERR;
+}
+
+
+/**
+ * Convert the 'claim' of an attestation to a string
+ *
+ * @param type the type of attestation
+ * @param data claim in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the claim
+ */
+char *
+GNUNET_RECLAIM_attestation_value_to_string (uint32_t type,
+ const void *data,
+ size_t data_size)
+{
+ unsigned int i;
+ struct Plugin *plugin;
+ char *ret;
+
+ init ();
+ for (i = 0; i < num_plugins; i++)
+ {
+ plugin = attest_plugins[i];
+ if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
+ type,
+ data,
+ data_size)))
+ return ret;
+ }
+ return NULL;
+}
+
+
+/**
+ * Create a new attestation.
+ *
+ * @param attr_name the attestation name
+ * @param type the attestation type
+ * @param data the attestation value
+ * @param data_size the attestation value size
+ * @return the new attestation
+ */
+struct GNUNET_RECLAIM_Attestation *
+GNUNET_RECLAIM_attestation_new (const char *attr_name,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
+{
+ struct GNUNET_RECLAIM_Attestation *attr;
+ char *write_ptr;
+ char *attr_name_tmp = GNUNET_strdup (attr_name);
+
+ GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
+
+ attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
+ + strlen (attr_name_tmp) + 1 + data_size);
+ attr->type = type;
+ attr->data_size = data_size;
+ attr->flag = 0;
+ write_ptr = (char *) &attr[1];
+ GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
+ attr->name = write_ptr;
+ write_ptr += strlen (attr->name) + 1;
+ GNUNET_memcpy (write_ptr, data, data_size);
+ attr->data = write_ptr;
+ GNUNET_free (attr_name_tmp);
+ return attr;
+}
+
+
+/**
+ * Get required size for serialization buffer
+ *
+ * @param attrs the attribute list to serialize
+ * @return the required buffer size
+ */
+size_t
+GNUNET_RECLAIM_attestation_list_serialize_get_size (
+ const struct GNUNET_RECLAIM_AttestationList *attestations)
+{
+ struct GNUNET_RECLAIM_AttestationListEntry *le;
+ size_t len = 0;
+
+ for (le = attestations->list_head; NULL != le; le = le->next)
+ {
+ GNUNET_assert (NULL != le->attestation);
+ len += GNUNET_RECLAIM_attestation_serialize_get_size (le->attestation);
+ len += sizeof(struct GNUNET_RECLAIM_AttestationListEntry);
+ }
+ return len;
+}
+
+
+/**
+ * Serialize an attribute list
+ *
+ * @param attrs the attribute list to serialize
+ * @param result the serialized attribute
+ * @return length of serialized data
+ */
+size_t
+GNUNET_RECLAIM_attestation_list_serialize (
+ const struct GNUNET_RECLAIM_AttestationList *attestations,
+ char *result)
+{
+ struct GNUNET_RECLAIM_AttestationListEntry *le;
+ size_t len;
+ size_t total_len;
+ char *write_ptr;
+ write_ptr = result;
+ total_len = 0;
+ for (le = attestations->list_head; NULL != le; le = le->next)
+ {
+ GNUNET_assert (NULL != le->attestation);
+ len = GNUNET_RECLAIM_attestation_serialize (le->attestation, write_ptr);
+ total_len += len;
+ write_ptr += len;
+ }
+ return total_len;
+}
+
+
+/**
+ * Deserialize an attestation list
+ *
+ * @param data the serialized attribute list
+ * @param data_size the length of the serialized data
+ * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
+ */
+struct GNUNET_RECLAIM_AttestationList *
+GNUNET_RECLAIM_attestation_list_deserialize (const char *data, size_t data_size)
+{
+ struct GNUNET_RECLAIM_AttestationList *al;
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
+ size_t att_len;
+ const char *read_ptr;
+
+ al = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
+
+ if ((data_size < sizeof(struct
+ Attestation)
+ + sizeof(struct GNUNET_RECLAIM_AttestationListEntry)))
+ return al;
+
+ read_ptr = data;
+ while (((data + data_size) - read_ptr) >= sizeof(struct Attestation))
+ {
+ ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
+ ale->attestation =
+ GNUNET_RECLAIM_attestation_deserialize (read_ptr,
+ data_size - (read_ptr - data));
+ GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
+ att_len = GNUNET_RECLAIM_attestation_serialize_get_size (ale->attestation);
+ read_ptr += att_len;
+ }
+ return al;
+}
+
+
+/**
+ * Make a (deep) copy of the attestation list
+ * @param attrs claim list to copy
+ * @return copied claim list
+ */
+struct GNUNET_RECLAIM_AttestationList *
+GNUNET_RECLAIM_attestation_list_dup (
+ const struct GNUNET_RECLAIM_AttestationList *al)
+{
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
+ struct GNUNET_RECLAIM_AttestationListEntry *result_ale;
+ struct GNUNET_RECLAIM_AttestationList *result;
+
+ result = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
+ {
+ result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
+ GNUNET_assert (NULL != ale->attestation);
+ result_ale->attestation =
+ GNUNET_RECLAIM_attestation_new (ale->attestation->name,
+ ale->attestation->type,
+ ale->attestation->data,
+ ale->attestation->data_size);
+ result_ale->attestation->id = ale->attestation->id;
+ GNUNET_CONTAINER_DLL_insert (result->list_head,
+ result->list_tail,
+ result_ale);
+ }
+ return result;
+}
+
+
+/**
+ * Destroy attestation list
+ *
+ * @param attrs list to destroy
+ */
+void
+GNUNET_RECLAIM_attestation_list_destroy (
+ struct GNUNET_RECLAIM_AttestationList *al)
+{
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
+ struct GNUNET_RECLAIM_AttestationListEntry *tmp_ale;
+
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
+ {
+ if (NULL != ale->attestation)
+ GNUNET_free (ale->attestation);
+ tmp_ale = ale;
+ ale = ale->next;
+ GNUNET_free (tmp_ale);
+ }
+ GNUNET_free (al);
+}
+
+
+/**
+ * Get required size for serialization buffer
+ *
+ * @param attr the attestation to serialize
+ * @return the required buffer size
+ */
+size_t
+GNUNET_RECLAIM_attestation_serialize_get_size (
+ const struct GNUNET_RECLAIM_Attestation *attestation)
+{
+ return sizeof(struct Attestation) + strlen (attestation->name)
+ + attestation->data_size;
+}
+
+
+/**
+ * Serialize an attestation
+ *
+ * @param attr the attestation to serialize
+ * @param result the serialized attestation
+ * @return length of serialized data
+ */
+size_t
+GNUNET_RECLAIM_attestation_serialize (
+ const struct GNUNET_RECLAIM_Attestation *attestation,
+ char *result)
+{
+ size_t data_len_ser;
+ size_t name_len;
+ struct Attestation *atts;
+ char *write_ptr;
+
+ atts = (struct Attestation *) result;
+ atts->attestation_type = htons (attestation->type);
+ atts->attestation_flag = htonl (attestation->flag);
+ atts->attestation_id = attestation->id;
+ name_len = strlen (attestation->name);
+ atts->name_len = htons (name_len);
+ write_ptr = (char *) &atts[1];
+ GNUNET_memcpy (write_ptr, attestation->name, name_len);
+ write_ptr += name_len;
+ // TODO plugin-ize
+ // data_len_ser = plugin->serialize_attribute_value (attr,
+ // &attr_ser[1]);
+ data_len_ser = attestation->data_size;
+ GNUNET_memcpy (write_ptr, attestation->data, attestation->data_size);
+ atts->data_size = htons (data_len_ser);
+
+ return sizeof(struct Attestation) + strlen (attestation->name)
+ + attestation->data_size;
+}
+
+
+/**
+ * Deserialize an attestation
+ *
+ * @param data the serialized attestation
+ * @param data_size the length of the serialized data
+ *
+ * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
+ */
+struct GNUNET_RECLAIM_Attestation *
+GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size)
+{
+ struct GNUNET_RECLAIM_Attestation *attestation;
+ struct Attestation *atts;
+ size_t data_len;
+ size_t name_len;
+ char *write_ptr;
+
+ if (data_size < sizeof(struct Attestation))
+ return NULL;
+
+ atts = (struct Attestation *) data;
+ data_len = ntohs (atts->data_size);
+ name_len = ntohs (atts->name_len);
+ if (data_size < sizeof(struct Attestation) + data_len + name_len)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Buffer too small to deserialize\n");
+ return NULL;
+ }
+ attestation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attestation)
+ + data_len + name_len + 1);
+ attestation->type = ntohs (atts->attestation_type);
+ attestation->flag = ntohl (atts->attestation_flag);
+ attestation->id = atts->attestation_id;
+ attestation->data_size = data_len;
+
+ write_ptr = (char *) &attestation[1];
+ GNUNET_memcpy (write_ptr, &atts[1], name_len);
+ write_ptr[name_len] = '\0';
+ attestation->name = write_ptr;
+
+ write_ptr += name_len + 1;
+ GNUNET_memcpy (write_ptr, (char *) &atts[1] + name_len,
+ attestation->data_size);
+ attestation->data = write_ptr;
+ return attestation;
+}
--- /dev/null
+/*
+ This file is part of GNUnet.
+ 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 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.
+
+ 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
+ */
+/**
+ * @author Martin Schanzenbach
+ * @file reclaim-attribute/reclaim_attestation.h
+ * @brief GNUnet reclaim identity attribute attestations
+ *
+ */
+#ifndef RECLAIM_ATTESTATION_H
+#define RECLAIM_ATTESTATION_H
+
+#include "gnunet_reclaim_service.h"
+
+/**
+ * Serialized attestation claim
+ */
+struct Attestation
+{
+ /**
+ * Attestation type
+ */
+ uint32_t attestation_type;
+
+ /**
+ * Attestation flag
+ */
+ uint32_t attestation_flag;
+
+ /**
+ * Attestation ID
+ */
+ struct GNUNET_RECLAIM_Identifier attestation_id;
+
+ /**
+ * Name length
+ */
+ uint32_t name_len;
+
+ /**
+ * Data size
+ */
+ uint32_t data_size;
+
+ // followed by data_size Attestation value data
+};
+
+#endif
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_reclaim_attribute_plugin.h"
+#include "gnunet_reclaim_plugin.h"
#include "reclaim_attribute.h"
/**
* Plugin API
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api;
+ struct GNUNET_RECLAIM_AttributePluginFunctions *api;
};
static void
add_plugin (void *cls, const char *library_name, void *lib_ret)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret;
+ struct GNUNET_RECLAIM_AttributePluginFunctions *api = lib_ret;
struct Plugin *plugin;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
* @return corresponding number, UINT32_MAX on error
*/
uint32_t
-GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename)
+GNUNET_RECLAIM_attribute_typename_to_number (const char *typename)
{
unsigned int i;
struct Plugin *plugin;
* @return corresponding typestring, NULL on error
*/
const char *
-GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type)
+GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type)
{
unsigned int i;
struct Plugin *plugin;
* @return #GNUNET_OK on success
*/
int
-GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
+GNUNET_RECLAIM_attribute_string_to_value (uint32_t type,
const char *s,
void **data,
size_t *data_size)
* @return NULL on error, otherwise human-readable representation of the claim
*/
char *
-GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
+GNUNET_RECLAIM_attribute_value_to_string (uint32_t type,
const void *data,
size_t data_size)
{
return NULL;
}
-/**
- * Convert an attestation type name to the corresponding number
- *
- * @param typename name to convert
- * @return corresponding number, UINT32_MAX on error
- */
-uint32_t
-GNUNET_RECLAIM_ATTESTATION_typename_to_number (const char *typename)
-{
- unsigned int i;
- struct Plugin *plugin;
- uint32_t ret;
- init ();
- for (i = 0; i < num_plugins; i++)
- {
- plugin = attr_plugins[i];
- if (UINT32_MAX !=
- (ret = plugin->api->typename_to_number_attest (plugin->api->cls,
- typename)))
- return ret;
- }
- return UINT32_MAX;
-}
-
-/**
- * Convert an attestation type number to the corresponding attestation type string
- *
- * @param type number of a type
- * @return corresponding typestring, NULL on error
- */
-const char *
-GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type)
-{
- unsigned int i;
- struct Plugin *plugin;
- const char *ret;
-
- init ();
- for (i = 0; i < num_plugins; i++)
- {
- plugin = attr_plugins[i];
- if (NULL !=
- (ret = plugin->api->number_to_typename_attest (plugin->api->cls, type)))
- return ret;
- }
- return NULL;
-}
-/**
- * Convert human-readable version of a 'claim' of an attestation to the binary
- * representation
- *
- * @param type type of the claim
- * @param s human-readable string
- * @param data set to value in binary encoding (will be allocated)
- * @param data_size set to number of bytes in @a data
- * @return #GNUNET_OK on success
- */
-int
-GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type,
- const char *s,
- void **data,
- size_t *data_size)
-{
- unsigned int i;
- struct Plugin *plugin;
-
- init ();
- for (i = 0; i < num_plugins; i++)
- {
- plugin = attr_plugins[i];
- if (GNUNET_OK == plugin->api->string_to_value_attest (plugin->api->cls,
- type,
- s,
- data,
- data_size))
- return GNUNET_OK;
- }
- return GNUNET_SYSERR;
-}
-
-
-/**
- * Convert the 'claim' of an attestation to a string
- *
- * @param type the type of attestation
- * @param data claim in binary encoding
- * @param data_size number of bytes in @a data
- * @return NULL on error, otherwise human-readable representation of the claim
- */
-char *
-GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type,
- const void *data,
- size_t data_size)
-{
- unsigned int i;
- struct Plugin *plugin;
- char *ret;
-
- init ();
- for (i = 0; i < num_plugins; i++)
- {
- plugin = attr_plugins[i];
- if (NULL != (ret = plugin->api->value_to_string_attest (plugin->api->cls,
- type,
- data,
- data_size)))
- return ret;
- }
- return NULL;
-}
/**
* Create a new attribute.
*
* @param attr_name the attribute name
+ * @param attestation attestation ID of the attribute (maybe NULL)
* @param type the attribute type
* @param data the attribute value
* @param data_size the attribute value size
* @return the new attribute
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
- uint32_t type,
- const void *data,
- size_t data_size)
+struct GNUNET_RECLAIM_Attribute *
+GNUNET_RECLAIM_attribute_new (const char *attr_name,
+ const struct GNUNET_RECLAIM_Identifier *attestation,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
+ struct GNUNET_RECLAIM_Attribute *attr;
char *write_ptr;
char *attr_name_tmp = GNUNET_strdup (attr_name);
GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
- attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
+ attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
+ strlen (attr_name_tmp) + 1 + data_size);
+ if (NULL != attestation)
+ attr->attestation = *attestation;
attr->type = type;
attr->data_size = data_size;
attr->flag = 0;
return attr;
}
-/**
- * Create a new attestation.
- *
- * @param attr_name the attestation name
- * @param type the attestation type
- * @param data the attestation value
- * @param data_size the attestation value size
- * @return the new attestation
- */
-struct GNUNET_RECLAIM_ATTESTATION_Claim *
-GNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name,
- uint32_t type,
- const void *data,
- size_t data_size)
-{
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
- char *write_ptr;
- char *attr_name_tmp = GNUNET_strdup (attr_name);
-
- GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
-
- attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)
- + strlen (attr_name_tmp) + 1 + data_size);
- attr->type = type;
- attr->data_size = data_size;
- attr->flag = 0;
- write_ptr = (char *) &attr[1];
- GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
- attr->name = write_ptr;
- write_ptr += strlen (attr->name) + 1;
- GNUNET_memcpy (write_ptr, data, data_size);
- attr->data = write_ptr;
- GNUNET_free (attr_name_tmp);
- return attr;
-}
-
-/**
- * Create a new attestation reference.
- *
- * @param attr_name the referenced claim name
- * @param ref_value the claim name in the attestation
- * @return the new reference
- */
-struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
-GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name,
- const char *ref_value)
-{
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
- char *write_ptr;
- char *attr_name_tmp = GNUNET_strdup (attr_name);
- char *ref_value_tmp = GNUNET_strdup (ref_value);
-
- GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
- GNUNET_STRINGS_utf8_tolower (ref_value, ref_value_tmp);
-
- attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE)
- + strlen (attr_name_tmp) + strlen (ref_value_tmp) + 2);
-
- write_ptr = (char *) &attr[1];
- GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
- attr->name = write_ptr;
-
- write_ptr += strlen (attr_name) + 1;
- GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1);
- attr->reference_value = write_ptr;
-
- GNUNET_free (attr_name_tmp);
- GNUNET_free (ref_value_tmp);
- return attr;
-}
/**
* Add a new attribute to a claim list
* @param data_size claim payload size
*/
void
-GNUNET_RECLAIM_ATTRIBUTE_list_add (
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list,
+GNUNET_RECLAIM_attribute_list_add (
+ struct GNUNET_RECLAIM_AttributeList *al,
const char *attr_name,
+ const struct GNUNET_RECLAIM_Identifier *attestation,
uint32_t type,
const void *data,
size_t data_size)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
-
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- le->claim =
- GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
- GNUNET_CONTAINER_DLL_insert (claim_list->list_head,
- claim_list->list_tail,
- le);
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
+
+ ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
+ ale->attribute =
+ GNUNET_RECLAIM_attribute_new (attr_name, attestation,
+ type, data, data_size);
+ GNUNET_CONTAINER_DLL_insert (al->list_head,
+ al->list_tail,
+ ale);
}
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
+GNUNET_RECLAIM_attribute_list_serialize_get_size (
+ const struct GNUNET_RECLAIM_AttributeList *al)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
size_t len = 0;
- for (le = attrs->list_head; NULL != le; le = le->next)
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
{
- if (NULL != le->claim)
- {
- len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- len += GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
- }
- else if (NULL != le->attest )
- {
- len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- len += GNUNET_RECLAIM_ATTESTATION_serialize_get_size (le->attest);
- }
- else if (NULL != le->reference)
- {
- len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- len += GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (le->reference);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unserialized Claim List Entry Type for size not known.\n");
- break;
- }
- len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
+ GNUNET_assert (NULL != ale->attribute);
+ len += GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute);
+ len += sizeof(struct GNUNET_RECLAIM_AttributeListEntry);
}
return len;
}
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+GNUNET_RECLAIM_attribute_list_serialize (
+ const struct GNUNET_RECLAIM_AttributeList *al,
char *result)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
size_t len;
size_t total_len;
char *write_ptr;
write_ptr = result;
total_len = 0;
- for (le = attrs->list_head; NULL != le; le = le->next)
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *list_type;
- if (NULL != le->claim)
- {
- list_type = (struct
- GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) write_ptr;
- list_type->type = htons (1);
- total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr);
- total_len += len;
- write_ptr += len;
- }
- else if (NULL != le->attest )
- {
- list_type = (struct
- GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) write_ptr;
- list_type->type = htons (2);
- total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- len = GNUNET_RECLAIM_ATTESTATION_serialize (le->attest, write_ptr);
- total_len += len;
- write_ptr += len;
- }
- else if (NULL != le->reference)
- {
- list_type = (struct
- GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) write_ptr;
- list_type->type = htons (3);
- total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- len = GNUNET_RECLAIM_ATTESTATION_REF_serialize (le->reference, write_ptr);
- total_len += len;
- write_ptr += len;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unserialized Claim List Entry Type not known.\n");
- continue;
- }
+ GNUNET_assert (NULL != ale->attribute);
+ len = GNUNET_RECLAIM_attribute_serialize (ale->attribute, write_ptr);
+ total_len += len;
+ write_ptr += len;
}
return total_len;
}
* @param data_size the length of the serialized data
* @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
-GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size)
+struct GNUNET_RECLAIM_AttributeList *
+GNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeList *al;
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
size_t attr_len;
const char *read_ptr;
- if ((data_size < sizeof(struct Attribute) + sizeof(struct
- GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry))
- && (data_size < sizeof(struct
- Attestation)
- + sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry)) &&
- (data_size < sizeof(struct Attestation_Reference) + sizeof(struct
- GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry)) )
- return NULL;
-
- attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
+ al = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
+ if (data_size < sizeof(struct Attribute) + sizeof(struct
+ GNUNET_RECLAIM_AttributeListEntry))
+ return al;
read_ptr = data;
while (((data + data_size) - read_ptr) >= sizeof(struct Attribute))
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *list_type;
- list_type = (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) read_ptr;
- if (1 == ntohs (list_type->type))
- {
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- if (((data + data_size) - read_ptr) < sizeof(struct Attribute))
- break;
- le->attest = NULL;
- le->reference = NULL;
- le->claim =
- GNUNET_RECLAIM_ATTRIBUTE_deserialize (read_ptr,
- data_size - (read_ptr - data));
- GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
- attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
- read_ptr += attr_len;
- }
- else if (2 == ntohs (list_type->type))
- {
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- if (((data + data_size) - read_ptr) < sizeof(struct Attestation))
- break;
- le->claim = NULL;
- le->reference = NULL;
- le->attest =
- GNUNET_RECLAIM_ATTESTATION_deserialize (read_ptr,
- data_size - (read_ptr - data));
- GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
- attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (le->attest);
- read_ptr += attr_len;
- }
- else if (3 == ntohs (list_type->type))
- {
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
- if (((data + data_size) - read_ptr) < sizeof(struct
- Attestation_Reference))
- break;
- le->claim = NULL;
- le->attest = NULL;
- le->reference =
- GNUNET_RECLAIM_ATTESTATION_REF_deserialize (read_ptr,
- data_size - (read_ptr
- - data));
- GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
- attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
- le->reference);
- read_ptr += attr_len;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Serialized Claim List Entry Type not known.\n");
- break;
- }
+ ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
+ ale->attribute =
+ GNUNET_RECLAIM_attribute_deserialize (read_ptr,
+ data_size - (read_ptr - data));
+ GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale);
+ attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute);
+ read_ptr += attr_len;
}
- return attrs;
+ return al;
}
* @param attrs claim list to copy
* @return copied claim list
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
-GNUNET_RECLAIM_ATTRIBUTE_list_dup (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
+struct GNUNET_RECLAIM_AttributeList *
+GNUNET_RECLAIM_attribute_list_dup (
+ const struct GNUNET_RECLAIM_AttributeList *al)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result;
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
+ struct GNUNET_RECLAIM_AttributeListEntry *result_ale;
+ struct GNUNET_RECLAIM_AttributeList *result;
- result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
- if (NULL == attrs->list_head)
+ result = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Duplicating empty List\n");
- }
- for (le = attrs->list_head; NULL != le; le = le->next)
- {
- result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- result_le->claim = NULL;
- result_le->attest = NULL;
- result_le->reference = NULL;
- if (NULL != le->claim)
- {
- result_le->claim =
- GNUNET_RECLAIM_ATTRIBUTE_claim_new (le->claim->name,
- le->claim->type,
- le->claim->data,
- le->claim->data_size);
-
- result_le->claim->id = le->claim->id;
- result_le->claim->flag = le->claim->flag;
- }
- if ( NULL != le->attest)
- {
- result_le->attest = GNUNET_RECLAIM_ATTESTATION_claim_new (
- le->attest->name,
- le->attest->type,
- le->attest->data,
- le->attest->
- data_size);
- result_le->attest->id = le->attest->id;
- }
- if (NULL !=le->reference)
+ result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
+ GNUNET_assert (NULL != ale->attribute);
{
- result_le->reference = GNUNET_RECLAIM_ATTESTATION_reference_new (
- le->reference->name,
- le->reference->reference_value);
- result_le->reference->id = le->reference->id;
- result_le->reference->id_attest = le->reference->id_attest;
+ result_ale->attribute =
+ GNUNET_RECLAIM_attribute_new (ale->attribute->name,
+ &ale->attribute->attestation,
+ ale->attribute->type,
+ ale->attribute->data,
+ ale->attribute->data_size);
+
+ result_ale->attribute->id = ale->attribute->id;
+ result_ale->attribute->flag = ale->attribute->flag;
}
GNUNET_CONTAINER_DLL_insert (result->list_head,
result->list_tail,
- result_le);
+ result_ale);
}
return result;
}
* @param attrs list to destroy
*/
void
-GNUNET_RECLAIM_ATTRIBUTE_list_destroy (
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
+GNUNET_RECLAIM_attribute_list_destroy (
+ struct GNUNET_RECLAIM_AttributeList *al)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le;
+ struct GNUNET_RECLAIM_AttributeListEntry *ale;
+ struct GNUNET_RECLAIM_AttributeListEntry *tmp_ale;
- for (le = attrs->list_head; NULL != le; le = le->next)
+ for (ale = al->list_head; NULL != ale; ale = ale->next)
{
- if (NULL != le->claim)
- GNUNET_free (le->claim);
- if (NULL != le->attest)
- GNUNET_free (le->attest);
- if (NULL != le->reference)
- GNUNET_free (le->reference);
- tmp_le = le;
- le = le->next;
- GNUNET_free (tmp_le);
+ if (NULL != ale->attribute)
+ GNUNET_free (ale->attribute);
+ tmp_ale = ale;
+ ale = ale->next;
+ GNUNET_free (tmp_ale);
}
- GNUNET_free (attrs);
+ GNUNET_free (al);
}
-/**
- * Count attestations in claim list
- *
- * @param attrs list
- */
-int
-GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
-{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
- int i = 0;
- for (le = attrs->list_head; NULL != le; le = le->next)
- {
- if (NULL != le->attest)
- i++;
- }
- return i;
-}
+
/**
* Get required size for serialization buffer
*
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
+GNUNET_RECLAIM_attribute_serialize_get_size (
+ const struct GNUNET_RECLAIM_Attribute *attr)
{
return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
}
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_serialize (
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
+GNUNET_RECLAIM_attribute_serialize (
+ const struct GNUNET_RECLAIM_Attribute *attr,
char *result)
{
size_t data_len_ser;
*
* @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size)
+struct GNUNET_RECLAIM_Attribute *
+GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
+ struct GNUNET_RECLAIM_Attribute *attr;
struct Attribute *attr_ser;
size_t data_len;
size_t name_len;
"Buffer too small to deserialize\n");
return NULL;
}
- attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
+ attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
+ data_len + name_len + 1);
attr->type = ntohs (attr_ser->attribute_type);
attr->flag = ntohl (attr_ser->attribute_flag);
}
-/**
- * Get required size for serialization buffer
- *
- * @param attr the attestation to serialize
- * @return the required buffer size
- */
-size_t
-GNUNET_RECLAIM_ATTESTATION_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
-{
- return sizeof(struct Attestation) + strlen (attr->name) + attr->data_size;
-}
-
-/**
- * Serialize an attestation
- *
- * @param attr the attestation to serialize
- * @param result the serialized attestation
- * @return length of serialized data
- */
-size_t
-GNUNET_RECLAIM_ATTESTATION_serialize (
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
- char *result)
-{
- size_t data_len_ser;
- size_t name_len;
- struct Attestation *attr_ser;
- char *write_ptr;
-
- attr_ser = (struct Attestation *) result;
- attr_ser->attestation_type = htons (attr->type);
- attr_ser->attestation_flag = htonl (attr->flag);
- attr_ser->attestation_id = attr->id;
- name_len = strlen (attr->name);
- attr_ser->name_len = htons (name_len);
- write_ptr = (char *) &attr_ser[1];
- GNUNET_memcpy (write_ptr, attr->name, name_len);
- write_ptr += name_len;
- // TODO plugin-ize
- // data_len_ser = plugin->serialize_attribute_value (attr,
- // &attr_ser[1]);
- data_len_ser = attr->data_size;
- GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
- attr_ser->data_size = htons (data_len_ser);
-
- return sizeof(struct Attestation) + strlen (attr->name) + attr->data_size;
-}
-
-/**
- * Deserialize an attestation
- *
- * @param data the serialized attestation
- * @param data_size the length of the serialized data
- *
- * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
- */
-struct GNUNET_RECLAIM_ATTESTATION_Claim *
-GNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size)
-{
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
- struct Attestation *attr_ser;
- size_t data_len;
- size_t name_len;
- char *write_ptr;
-
- if (data_size < sizeof(struct Attestation))
- return NULL;
-
- attr_ser = (struct Attestation *) data;
- data_len = ntohs (attr_ser->data_size);
- name_len = ntohs (attr_ser->name_len);
- if (data_size < sizeof(struct Attestation) + data_len + name_len)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Buffer too small to deserialize\n");
- return NULL;
- }
- attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)
- + data_len + name_len + 1);
- attr->type = ntohs (attr_ser->attestation_type);
- attr->flag = ntohl (attr_ser->attestation_flag);
- attr->id = attr_ser->attestation_id;
- attr->data_size = data_len;
-
- write_ptr = (char *) &attr[1];
- GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
- write_ptr[name_len] = '\0';
- attr->name = write_ptr;
-
- write_ptr += name_len + 1;
- GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
- attr->data = write_ptr;
- return attr;
-}
-
-/**
- * Get required size for serialization buffer
- *
- * @param attr the reference to serialize
- * @return the required buffer size
- */
-size_t
-GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
-{
- return sizeof(struct Attestation_Reference) + strlen (attr->name) + strlen (
- attr->reference_value);
-}
-
-
-/**
- * Serialize a reference
- *
- * @param attr the reference to serialize
- * @param result the serialized reference
- * @return length of serialized data
- */
-size_t
-GNUNET_RECLAIM_ATTESTATION_REF_serialize (
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
- char *result)
-{
- size_t name_len;
- size_t refval_len;
- struct Attestation_Reference *attr_ser;
- char *write_ptr;
- attr_ser = (struct Attestation_Reference *) result;
- attr_ser->reference_id = attr->id;
- attr_ser->attestation_id = attr->id_attest;
- name_len = strlen (attr->name);
- refval_len = strlen (attr->reference_value);
- attr_ser->name_len = htons (name_len);
- attr_ser->ref_value_len = htons (refval_len);
- write_ptr = (char *) &attr_ser[1];
- GNUNET_memcpy (write_ptr, attr->name, name_len);
- write_ptr += name_len;
- GNUNET_memcpy (write_ptr, attr->reference_value, refval_len);
-
- return sizeof(struct Attestation_Reference) + strlen (attr->name) + strlen (
- attr->reference_value);
-}
-
-
-/**
- * Deserialize a reference
- *
- * @param data the serialized reference
- * @param data_size the length of the serialized data
- *
- * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
- */
-struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *
-GNUNET_RECLAIM_ATTESTATION_REF_deserialize (const char *data, size_t data_size)
-{
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
- struct Attestation_Reference *attr_ser;
- size_t name_len;
- size_t refval_len;
- char *write_ptr;
-
- if (data_size < sizeof(struct Attestation_Reference))
- return NULL;
- attr_ser = (struct Attestation_Reference *) data;
- name_len = ntohs (attr_ser->name_len);
- refval_len = ntohs (attr_ser->ref_value_len);
- if (data_size < sizeof(struct Attestation_Reference) + refval_len + name_len)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Buffer too small to deserialize\n");
- return NULL;
- }
- attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE)
- + refval_len + name_len + 2);
-
- attr->id = attr_ser->reference_id;
- attr->id_attest = attr_ser->attestation_id;
-
- write_ptr = (char *) &attr[1];
- GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
- write_ptr[name_len] = '\0';
- attr->name = write_ptr;
-
- write_ptr += name_len + 1;
- GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, refval_len);
- write_ptr[refval_len] = '\0';
- attr->reference_value = write_ptr;
- return attr;
-}
/* end of reclaim_attribute.c */
*/
struct GNUNET_RECLAIM_Identifier attribute_id;
+ /**
+ * Attestation ID
+ */
+ struct GNUNET_RECLAIM_Identifier attestation_id;
+
/**
* Name length
*/
// followed by data_size Attestation value data
};
-/**
- * Serialized attestation reference
- */
-struct Attestation_Reference
-{
- /**
- * Reference ID
- */
- struct GNUNET_RECLAIM_Identifier reference_id;
-
- /**
- * The ID of the referenced attestation
- */
- struct GNUNET_RECLAIM_Identifier attestation_id;
-
- /**
- * Claim Name length
- */
- uint32_t name_len;
-
- /**
- * Length of the referenced value
- */
- uint32_t ref_value_len;
-
-
- // followed by the name and referenced value
-};
-
#endif
/**
* Attribute list
*/
-static struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list;
+static struct GNUNET_RECLAIM_AttributeList *attr_list;
/**
* Attribute expiration interval
/**
* Claim to store
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
+struct GNUNET_RECLAIM_Attribute *claim;
/**
* Claim to delete
/**
* Claim object to delete
*/
-static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete;
+static struct GNUNET_RECLAIM_Attribute *attr_to_delete;
static void
do_cleanup (void *cls)
static void
process_attrs (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
char *value_str;
char *id;
ret = 1;
return;
}
- value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
+ value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
attr->data,
attr->data_size);
- attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
+ attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
fprintf (stdout,
- "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
+ "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
attr->name,
value_str,
attr_type,
attr->flag,
- id);
+ id,
+ (NULL == attest) ? "" : "ATTESTED");
GNUNET_free (id);
}
if (NULL == type_str)
type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING;
else
- type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
+ type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
GNUNET_assert (GNUNET_SYSERR !=
- GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
+ GNUNET_RECLAIM_attribute_string_to_value (type,
attr_value,
(void **) &data,
&data_size));
else
{
claim =
- GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
+ GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
}
reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
pkey,
static void
iter_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *le;
char *attrs_tmp;
char *attr_str;
char *label;
{
if (0 == strcasecmp (attr_name, attr->name))
{
- claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
- attr->type,
- attr->data,
- attr->data_size);
+ claim = GNUNET_RECLAIM_attribute_new (attr->name,
+ &attr->attestation,
+ attr->type,
+ attr->data,
+ attr->data_size);
}
}
else if (issue_attrs)
attr_str = strtok (NULL, ",");
continue;
}
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
- attr->type,
- attr->data,
- attr->data_size);
- le->claim->flag = attr->flag;
- le->claim->id = attr->id;
+ le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
+ le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
+ &attr->attestation,
+ attr->type,
+ attr->data,
+ attr->data_size);
+ le->attribute->flag = attr->flag;
+ le->attribute->id = attr->id;
GNUNET_CONTAINER_DLL_insert (attr_list->list_head,
attr_list->list_tail,
le);
label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
if (0 == strcasecmp (attr_delete, label))
{
- attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
- attr->type,
- attr->data,
- attr->data_size);
+ attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name,
+ &attr->attestation,
+ attr->type,
+ attr->data,
+ attr->data_size);
attr_to_delete->id = attr->id;
}
GNUNET_free (label);
}
else if (list)
{
- attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
+ attr_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
attr->data,
attr->data_size);
- attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
+ attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
fprintf (stdout,
"Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
&ticket,
sizeof(struct GNUNET_RECLAIM_Ticket));
- attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
+ attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
claim = NULL;
attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
pkey,
/**
* The attribute to delete
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
+ struct GNUNET_RECLAIM_Attribute *claim;
/**
* The attestation to delete
*/
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
+ struct GNUNET_RECLAIM_Attestation *attest;
- /**
- * The reference to delete
- */
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
/**
* Tickets to update
*/
/**
* The attribute to store
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
+ struct GNUNET_RECLAIM_Attribute *claim;
/**
* The attestation to store
*/
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
-
- /**
- * The reference to store
- */
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
+ struct GNUNET_RECLAIM_Attestation *attest;
/**
* The attribute expiration interval
GNUNET_free (adh->claim);
if (NULL != adh->attest)
GNUNET_free (adh->attest);
- if (NULL != adh->reference)
- GNUNET_free (adh->reference);
while (NULL != (le = adh->tickets_to_update_head))
{
GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
GNUNET_free (ash->claim);
if (NULL != ash->attest)
GNUNET_free (ash->attest);
- if (NULL != ash->reference)
- GNUNET_free (ash->reference);
GNUNET_free (ash);
}
{
struct TicketIssueOperation *tio;
struct IdpClient *idp = cls;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
+ struct GNUNET_RECLAIM_AttributeList *attrs;
size_t attrs_len;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
tio = GNUNET_new (struct TicketIssueOperation);
attrs_len = ntohs (im->attr_len);
- attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1],
+ attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1],
attrs_len);
tio->r_id = ntohl (im->id);
tio->client = idp;
&issue_ticket_result_cb,
tio);
GNUNET_SERVICE_client_continue (idp->client);
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
+ GNUNET_RECLAIM_attribute_list_destroy (attrs);
}
static void
consume_result_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ const struct GNUNET_RECLAIM_AttributeList *attrs,
int32_t success,
const char *emsg)
{
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
}
- attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
+ attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending CONSUME_TICKET_RESULT message\n");
env = GNUNET_MQ_msg_extra (crm,
crm->identity = *identity;
crm->result = htonl (success);
data_tmp = (char *) &crm[1];
- GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp);
+ GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
GNUNET_MQ_send (cop->client->mq, env);
GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
cop->client->consume_op_tail,
size_t buf_size;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
- buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim);
+ buf_size = GNUNET_RECLAIM_attribute_serialize_get_size (ash->claim);
buf = GNUNET_malloc (buf_size);
// Give the ash a new id if unset
if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id))
GNUNET_RECLAIM_id_generate (&ash->claim->id);
- GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf);
+ GNUNET_RECLAIM_attribute_serialize (ash->claim, buf);
label
= GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id,
- sizeof (ash->reference->id));
+ sizeof (ash->claim->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
rd[0].data_size = buf_size;
rd[0].data = buf;
- rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR;
+ rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE;
rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
rd[0].expiration_time = ash->exp.rel_value_us;
ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
data_len = ntohs (sam->attr_len);
ash = GNUNET_new (struct AttributeStoreHandle);
- ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1],
+ ash->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1],
data_len);
ash->r_id = ntohl (sam->id);
}
-/**
- * Send a reference error response
- *
- * @param ash our attribute store handle
- * @param success the success status
- */
-static void
-send_ref_error (struct AttributeStoreHandle *ash)
-{
- struct GNUNET_MQ_Envelope *env;
- struct SuccessResultMessage *acr_msg;
-
- ash->ns_qe = NULL;
- GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head,
- ash->client->store_op_tail,
- ash);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
- env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
- acr_msg->id = htonl (ash->r_id);
- acr_msg->op_result = htonl (GNUNET_SYSERR);
- GNUNET_MQ_send (ash->client->mq, env);
- cleanup_as_handle (ash);
-}
-
-
/**
* Error looking up potential attestation. Abort.
*
/**
-* Check for existing record before storing reference
+* Check for existing record before storing attestation
*
* @param cls our attribute store handle
* @param zone zone we are iterating
struct AttributeStoreHandle *ash = cls;
char *buf;
size_t buf_size;
- buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest);
+ buf_size = GNUNET_RECLAIM_attestation_serialize_get_size (ash->attest);
buf = GNUNET_malloc (buf_size);
- GNUNET_RECLAIM_ATTESTATION_serialize (ash->attest, buf);
- if (0 == rd_count)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Storing new Attestation\n");
- struct GNUNET_GNSRECORD_Data rd_new[1];
- rd_new[0].data_size = buf_size;
- rd_new[0].data = buf;
- rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR;
- rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
- rd_new[0].expiration_time = ash->exp.rel_value_us;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
- ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
- &ash->identity,
- label,
- 1,
- rd_new,
- &attest_store_cont,
- ash);
- GNUNET_free (buf);
- return;
- }
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Existing Attestation location is not an Attestation\n");
- send_ref_error (ash);
- return;
- }
- struct GNUNET_GNSRECORD_Data rd_new[rd_count];
- for (int i = 0; i<rd_count; i++)
- {
- rd_new[i] = rd[i];
- }
+ GNUNET_RECLAIM_attestation_serialize (ash->attest, buf);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Storing new Attestation\n");
+ struct GNUNET_GNSRECORD_Data rd_new[1];
rd_new[0].data_size = buf_size;
rd_new[0].data = buf;
- rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR;
+ rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION;
rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
rd_new[0].expiration_time = ash->exp.rel_value_us;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
&ash->identity,
label,
- rd_count,
+ 1,
rd_new,
&attest_store_cont,
ash);
GNUNET_free (buf);
+ return;
}
data_len = ntohs (sam->attr_len);
ash = GNUNET_new (struct AttributeStoreHandle);
- ash->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &sam[1],
+ ash->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &sam[1],
data_len);
ash->r_id = ntohl (sam->id);
}
-/**
- * Error looking up potential reference value. Abort.
- *
- * @param cls our attribute store handle
- */
-static void
-ref_error (void *cls)
-{
- struct AttributeStoreHandle *ash = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to find Attestation entry for Attestation reference\n");
- cleanup_as_handle (ash);
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return;
-}
-
-
-/**
- * Error looking up potential reference value. Abort.
- *
- * @param cls our attribute delete handle
- */
-static void
-ref_del_error (void *cls)
-{
- struct AttributeDeleteHandle *adh = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to find Attestation entry for Attestation reference\n");
- cleanup_adh (adh);
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return;
-}
-
-
-/**
-* Reference store result handler
-*
-* @param cls our attribute store handle
-* @param success GNUNET_OK if successful
-* @param emsg error message (NULL if success=GNUNET_OK)
-*/
-static void
-reference_store_cont (void *cls, int32_t success, const char *emsg)
-{
- struct AttributeStoreHandle *ash = cls;
- struct GNUNET_MQ_Envelope *env;
- struct SuccessResultMessage *acr_msg;
-
- ash->ns_qe = NULL;
- GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head,
- ash->client->store_op_tail,
- ash);
-
- if (GNUNET_SYSERR == success)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to store reference %s\n",
- emsg);
- cleanup_as_handle (ash);
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
- env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
- acr_msg->id = htonl (ash->r_id);
- acr_msg->op_result = htonl (GNUNET_OK);
- GNUNET_MQ_send (ash->client->mq, env);
- cleanup_as_handle (ash);
-}
-
-
-/**
-* Check for existing record before storing reference
-*
-* @param cls our attribute store handle
-* @param zone zone we are iterating
-* @param label label of the records
-* @param rd_count record count
-* @param rd records
-*/
-static void
-ref_add_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
- const char *label,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
-{
- struct AttributeStoreHandle *ash = cls;
- char *buf;
- size_t buf_size;
- buf_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (ash->reference);
- buf = GNUNET_malloc (buf_size);
- GNUNET_RECLAIM_ATTESTATION_REF_serialize (ash->reference, buf);
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
- char *data_tmp;
- if (0 == rd_count)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to find Attestation entry for Attestation reference\n");
- send_ref_error (ash);
- return;
- }
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Intended Reference storage location is not an attestation\n");
- send_ref_error (ash);
- return;
- }
- struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1];
- int i;
- for (i = 0; i<rd_count; i++)
- {
- data_tmp = GNUNET_malloc (rd[i].data_size);
- GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
- ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, htons (
- rd[i].data_size));
- rd_new[i] = rd[i];
- if ((strcmp (ash->reference->name,ref->name) == 0) &&
- (strcmp (ash->reference->reference_value,ref->reference_value)==0) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Reference already stored\n");
- reference_store_cont (ash,GNUNET_OK, NULL);
- return;
- }
- }
- rd_new[rd_count].data_size = buf_size;
- rd_new[rd_count].data = buf;
- rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE;
- rd_new[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
- rd_new[rd_count].expiration_time = ash->exp.rel_value_us;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
- ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
- &ash->identity,
- label,
- rd_count + 1,
- rd_new,
- &reference_store_cont,
- ash);
- GNUNET_free (buf);
-}
-
-
-/**
- * Add a new reference
- *
- * @param cls the AttributeStoreHandle
- */
-static void
-reference_store_task (void *cls)
-{
- struct AttributeStoreHandle *ash = cls;
- char *label;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing reference\n");
-
- // Give the ash a new id if unset
- if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->reference->id))
- {
- if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->reference->id_attest))
- {
- GNUNET_RECLAIM_id_generate (&ash->reference->id);
- }
- else
- {
- ash->reference->id = ash->reference->id_attest;
- }
- }
-
- label = GNUNET_STRINGS_data_to_string_alloc (&ash->reference->id,
- sizeof (ash->reference->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Looking up existing data under label %s\n", label);
-// Test for the content of the existing ID
-
- ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
- &ash->identity,
- label,
- &ref_error,
- ash,
- &ref_add_cb,
- ash);
- GNUNET_free (label);
-}
-
-
-/**
- * Check an attestation reference store message
- *
- * @param cls unused
- * @param sam the message to check
- */
-static int
-check_reference_store_message (void *cls,
- const struct
- AttributeStoreMessage *sam)
-{
- uint16_t size;
-
- size = ntohs (sam->header.size);
- if (size <= sizeof(struct AttributeStoreMessage))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Handle an attestation reference store message
- *
- * @param cls our client
- * @param sam the message to handle
- */
-static void
-handle_reference_store_message (void *cls,
- const struct AttributeStoreMessage *sam)
-{
- struct AttributeStoreHandle *ash;
- struct IdpClient *idp = cls;
- size_t data_len;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_STORE message\n");
-
- data_len = ntohs (sam->attr_len);
- ash = GNUNET_new (struct AttributeStoreHandle);
- ash->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &sam[1],
- data_len);
- ash->r_id = ntohl (sam->id);
- ash->identity = sam->identity;
- ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
- GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey);
-
-
- GNUNET_SERVICE_client_continue (idp->client);
- ash->client = idp;
- GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
- GNUNET_SCHEDULER_add_now (&reference_store_task, ash);
-}
-
-
/**
* Send a deletion success response
*
int has_changed = GNUNET_NO;
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
continue;
if (adh->claim != NULL)
if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
&adh->attest->id))
continue;
- if (adh->reference != NULL)
- if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data,
- &adh->reference->id))
- continue;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Attribute or Attestation/Reference to delete found (%s)\n",
+ "Attribute or Attestation to delete found (%s)\n",
adh->label);
has_changed = GNUNET_YES;
break;
for (int i = 0; i < le->rd_count; i++)
{
if (adh->claim != NULL)
- if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
+ if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
&& (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
&adh->claim->id)))
continue;
if (adh->attest != NULL)
- if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
+ if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
&& (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
&adh->attest->id)))
continue;
- if (adh->reference != NULL)
- if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
- && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
- &adh->reference->id)))
- continue;
rd_new[j] = rd[i];
j++;
}
data_len = ntohs (dam->attr_len);
adh = GNUNET_new (struct AttributeDeleteHandle);
- adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1],
+ adh->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1],
data_len);
- adh->reference = NULL;
adh->attest = NULL;
adh->r_id = ntohl (dam->id);
data_len = ntohs (dam->attr_len);
adh = GNUNET_new (struct AttributeDeleteHandle);
- adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1],
+ adh->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &dam[1],
data_len);
- adh->reference = NULL;
adh->claim = NULL;
adh->r_id = ntohl (dam->id);
}
-/**
-* Reference deleted callback
-*
-* @param cls our handle
-* @param success success status
-* @param emsg error message (NULL if success=GNUNET_OK)
-*/
-static void
-reference_delete_cont (void *cls, int32_t success, const char *emsg)
-{
- struct AttributeDeleteHandle *adh = cls;
-
- adh->ns_qe = NULL;
- if (GNUNET_SYSERR == success)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error deleting reference %s\n",
- adh->label);
- send_delete_response (adh, GNUNET_SYSERR);
- cleanup_adh (adh);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
- // GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
- send_delete_response (adh, GNUNET_OK);
- cleanup_adh (adh);
- return;
-}
-
-
-static void
-ref_del_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
- const char *label,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
-{
-
- struct AttributeDeleteHandle *adh = cls;
- char *data_tmp;
- struct GNUNET_GNSRECORD_Data rd_new[rd_count - 1];
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
- size_t attr_len;
-
- if (0 == rd_count)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to find Attestation entry for Attestation reference\n");
- cleanup_adh (adh);
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return;
- }
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Intended Reference location is not an attestation\n");
- cleanup_adh (adh);
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return;
- }
- rd_new[0] = rd[0];
- int i;
- int j = 1;
- for (i = 1; i<rd_count; i++)
- {
- data_tmp = GNUNET_malloc (rd[i].data_size);
- GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
- attr_len = htons (rd[i].data_size);
- ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len);
- if (NULL == ref)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to parse attestation reference from %s\n",
- data_tmp);
- rd_new[j] = rd[i];
- j += 1;
- continue;
- }
- if ((strcmp (adh->reference->name,ref->name) == 0) &&
- (strcmp (adh->reference->reference_value,ref->reference_value)==0) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found reference to delete.\n");
- }
- else
- {
- rd_new[j] = rd[i];
- j += 1;
- }
- GNUNET_free (data_tmp);
- }
- adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
- &adh->identity,
- label,
- j,
- rd_new,
- &reference_delete_cont,
- adh);
-}
-
-
-/**
- * Check an attestation reference delete message
- *
- * @param cls unused
- * @param sam the message to check
- */
-static int
-check_reference_delete_message (void *cls,
- const struct AttributeDeleteMessage *dam)
-{
- uint16_t size;
-
- size = ntohs (dam->header.size);
- if (size <= sizeof(struct AttributeDeleteMessage))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Handle reference deletion
- *
- * @param cls our client
- * @param dam deletion message
- */
-static void
-handle_reference_delete_message (void *cls,
- const struct AttributeDeleteMessage *dam)
-{
- struct AttributeDeleteHandle *adh;
- struct IdpClient *idp = cls;
- size_t data_len;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_DELETE message\n");
- data_len = ntohs (dam->attr_len);
- adh = GNUNET_new (struct AttributeDeleteHandle);
- adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1],
- data_len);
- adh->attest = NULL;
- adh->claim = NULL;
-
- adh->r_id = ntohl (dam->id);
- adh->identity = dam->identity;
- adh->label
- = GNUNET_STRINGS_data_to_string_alloc (&adh->reference->id,
- sizeof(adh->reference->id));
- GNUNET_SERVICE_client_continue (idp->client);
- adh->client = idp;
- GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
- adh->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
- &adh->identity,
- adh->label,
- &ref_del_error,
- adh,
- &ref_del_cb,
- adh);
-}
-
-
/*************************************************
* Attrubute iteration
*************************************************/
/**
- * Got record. Return if it is an attribute or attestation/reference.
+ * Got record. Return if it is an attribute or attestation.
*
* @param cls our attribute iterator
* @param zone zone we are iterating
}
if (rd_count > 1)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[0].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[0].record_type)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found Ticket. Ignoring.\n");
GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
return;
}
- else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
+ else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[0].record_type)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Non-Attestation record with multiple entries found: %u\n",
for (int i = 0; i<rd_count; i++)
{
- if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd[i].record_type) &&
- (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) &&
- (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE != rd[i].record_type))
+ if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type) &&
+ (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[i].record_type))
{
GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
return;
}
-
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type)
+ // FIXME Send attribute TOGETHER with respective attestation if applicable
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
{
struct AttributeResultMessage *arm;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
}
else
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
{
struct AttributeResultMessage *arm;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
GNUNET_MQ_send (ai->client->mq, env);
}
- else
- {
- struct ReferenceResultMessage *rrm;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
- label);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending REFERENCE_RESULT message\n");
- env = GNUNET_MQ_msg_extra (rrm,
- rd[i].data_size + rd[0].data_size,
- GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT);
- rrm->id = htonl (ai->request_id);
- rrm->attest_len = htons (rd[0].data_size);
- rrm->ref_len = htons (rd[i].data_size);
- GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity);
- data_tmp = (char *) &rrm[1];
- GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size);
- data_tmp += rd[0].data_size;
- GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
- GNUNET_MQ_send (ai->client->mq, env);
- }
}
}
}
GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE,
struct AttributeDeleteMessage,
NULL),
- GNUNET_MQ_hd_var_size (reference_store_message,
- GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE,
- struct AttributeStoreMessage,
- NULL),
- GNUNET_MQ_hd_var_size (reference_delete_message,
- GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE,
- struct AttributeDeleteMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (
- iteration_start,
- GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
- struct AttributeIterationStartMessage,
- NULL),
+ GNUNET_MQ_hd_fixed_size (iteration_start,
+ GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
+ struct AttributeIterationStartMessage,
+ NULL),
GNUNET_MQ_hd_fixed_size (iteration_next,
GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT,
struct AttributeIterationNextMessage,
/**
* Attributes
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
+ struct GNUNET_RECLAIM_AttributeList *attrs;
/**
* Tickets
/**
* Attributes
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
+ struct GNUNET_RECLAIM_AttributeList *attrs;
+
+ /**
+ * Attestations
+ */
+ struct GNUNET_RECLAIM_AttestationList *attests;
/**
* Lookup time
/**
* Attributes to issue
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
+ struct GNUNET_RECLAIM_AttributeList *attrs;
/**
* Issuer Key
}
for (int i = 0; i < le->rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
continue;
for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
{
/** Let everything point to the old record **/
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
continue;
for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
{
// new_rd = *rd;
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
{
/** find a new place for this attribute **/
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
- claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data,
+ struct GNUNET_RECLAIM_Attribute *claim;
+ claim = GNUNET_RECLAIM_attribute_deserialize (rd[i].data,
rd[i].data_size);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Attribute to update: Name=%s\n",
claim->name);
claim->id = rvk->move_attr->new_id;
- new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim);
+ new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize_get_size (claim);
attr_data = GNUNET_malloc (rd[i].data_size);
- new_rd[i].data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim,
+ new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize (claim,
attr_data);
new_rd[i].data = attr_data;
new_rd[i].record_type = rd[i].record_type;
new_rd[i].flags = rd[i].flags;
new_rd[i].expiration_time = rd[i].expiration_time;
- new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
- sizeof (rvk->move_attr->
- new_id));
+ new_label =
+ GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
+ sizeof (rvk->move_attr->new_id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
GNUNET_free (claim);
}
- else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type)
+ else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
{
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
- attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data,
+ struct GNUNET_RECLAIM_Attestation *attest;
+ attest = GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
rd[i].data_size);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Attestation to update: Name=%s\n",
attest->name);
attest->id = rvk->move_attr->new_id;
- new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (
- attest);
+ new_rd[i].data_size =
+ GNUNET_RECLAIM_attestation_serialize_get_size (attest);
attr_data = GNUNET_malloc (rd[i].data_size);
- new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_serialize (attest,
+ new_rd[i].data_size = GNUNET_RECLAIM_attestation_serialize (attest,
attr_data);
new_rd[i].data = attr_data;
new_rd[i].record_type = rd[i].record_type;
new_rd[i].flags = rd[i].flags;
new_rd[i].expiration_time = rd[i].expiration_time;
- new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
- sizeof (rvk->move_attr->
- new_id));
+ new_label =
+ GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
+ sizeof (rvk->move_attr->new_id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n",
new_label);
GNUNET_free (attest);
}
- else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
- {
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference;
- reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
- rd[i].data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Reference to update: Name=%s\n",
- reference->name);
- reference->id = rvk->move_attr->new_id;
- reference->id_attest = rvk->move_attr->new_id;
- new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (
- reference);
- attr_data = GNUNET_malloc (rd[i].data_size);
- new_rd[i].data_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize (reference,
- attr_data);
- new_rd[i].data = attr_data;
- new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
- sizeof (rvk->move_attr->
- new_id));
- new_rd[i].record_type = rd[i].record_type;
- new_rd[i].flags = rd[i].flags;
- new_rd[i].expiration_time = rd[i].expiration_time;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference %s\n", new_label);
- GNUNET_free (reference);
- }
}
rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
&rvk->identity,
*/
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
continue;
le = GNUNET_new (struct RevokedAttributeEntry);
le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
}
if (NULL != cth->attrs)
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs);
+ GNUNET_RECLAIM_attribute_list_destroy (cth->attrs);
+ if (NULL != cth->attests)
+ GNUNET_RECLAIM_attestation_list_destroy (cth->attests);
GNUNET_free (cth);
}
{
struct ParallelLookup *parallel_lookup = cls;
struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le;
+ struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Parallel lookup finished (count=%u)\n",
// REMARK: It is possible now to find rd_count > 1
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
{
- attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- attr_le->claim =
- GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd[i].data, rd[i].data_size);
+ attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
+ attr_le->attribute =
+ GNUNET_RECLAIM_attribute_deserialize (rd[i].data, rd[i].data_size);
GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
cth->attrs->list_tail,
attr_le);
- attr_le->reference = NULL;
- attr_le->attest = NULL;
}
- else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type)
+ else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
{
- /**Ignore all plain attestations
- *attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- *attr_le->attest =
- * GNUNET_RECLAIM_ATTESTATION_deserialize (rd[i].data, rd[i].data_size);
- *GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
- * cth->attrs->list_tail,
- * attr_le);
- */
- continue;
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
+ ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
+ ale->attestation =
+ GNUNET_RECLAIM_attestation_deserialize (rd[i].data,
+ rd[i].data_size);
+ GNUNET_CONTAINER_DLL_insert (cth->attests->list_head,
+ cth->attests->list_tail,
+ ale);
}
- else if (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE == rd[i].record_type)
+ else
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le2;
- attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- attr_le2 = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[0].record_type)
- {
- attr_le->attest = GNUNET_RECLAIM_ATTESTATION_deserialize (rd[0].data,
- rd[0].
- data_size);
- attr_le2->reference =
- GNUNET_RECLAIM_ATTESTATION_REF_deserialize (rd[i].data,
- rd[i].data_size);
- attr_le->claim = NULL;
- attr_le->reference = NULL;
- attr_le2->claim = NULL;
- attr_le2->attest = NULL;
- GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
- cth->attrs->list_tail,
- attr_le);
- GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
- cth->attrs->list_tail,
- attr_le2);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Parallel Lookup of Reference without Attestation");
- continue;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Parallel Lookup of Reference without Attestation");
+ continue;
+ }
- }
}
if (NULL != cth->parallel_lookups_head)
return; // Wait for more
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
continue;
lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
cth->identity = *id;
GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
- cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
+ cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
cth->ticket = *ticket;
cth->cb = cb;
cth->cb_cls = cb_cls;
GNUNET_GNS_lookup (gns,
label,
&cth->ticket.identity,
- GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF,
+ GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF,
GNUNET_GNS_LO_DEFAULT,
&lookup_authz_cb,
cth);
static void
issue_ticket (struct TicketIssueHandle *ih)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *le;
struct GNUNET_GNSRECORD_Data *attrs_record;
char *label;
size_t list_len = 1;
int i;
- char *attest_string;
for (le = ih->attrs->list_head; NULL != le; le = le->next)
+ {
list_len++;
+ if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
+ list_len++;
+ }
attrs_record =
GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
i = 0;
for (le = ih->attrs->list_head; NULL != le; le = le->next)
{
- if (NULL != le->claim)
- {
- attrs_record[i].data = &le->claim->id;
- attrs_record[i].data_size = sizeof(le->claim->id);
- }
- else if (NULL != le->attest)
- {
- // REMARK: Since we only store IDs, the references are irrelevant
- int j = 0;
- GNUNET_asprintf (&attest_string,"%d",le->attest->id);
- while (j<i)
- {
- if (0 == strcmp (attest_string,GNUNET_STRINGS_data_to_string_alloc (
- attrs_record[j].data, attrs_record[j].data_size)))
- break;
- j++;
- }
- if (j < i)
- {
- list_len--;
- continue;
- }
- attrs_record[i].data = &le->attest->id;
- attrs_record[i].data_size = sizeof(le->attest->id);
- }
- else if (NULL != le->reference)
- {
- list_len--;
- continue;
- /*
- int j = 0;
- GNUNET_asprintf (&attest_string,"%d",le->attest->id);
- while (j<i)
- {
- if (strcmp(attest_string, GNUNET_STRINGS_data_to_string_alloc (
- attrs_record[j].data, attrs_record[j].data_size)))
- break;
- j++;
- }
- if (j < i)
- continue;
- attrs_record[i].data = &le->reference->id;
- attrs_record[i].data_size = sizeof(le->reference->id);
- */
- }
- /**
- * FIXME: Should this be the attribute expiration time or ticket
- * refresh interval? Probably min(attrs.expiration)
- */
+ attrs_record[i].data = &le->attribute->id;
+ attrs_record[i].data_size = sizeof(le->attribute->id);
attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
- attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF;
+ attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
+ if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
+ {
+ i++;
+ attrs_record[i].data = &le->attribute->attestation;
+ attrs_record[i].data_size = sizeof(le->attribute->attestation);
+ attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
+ attrs_record[i].record_type =
+ GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
+ attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
+ }
i++;
}
attrs_record[i].data = &ih->ticket;
struct GNUNET_RECLAIM_Ticket *ticket = NULL;
// figure out the number of requested attributes
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *le;
unsigned int attr_cnt = 0;
+ unsigned int attest_cnt = 0;
for (le = tih->attrs->list_head; NULL != le; le = le->next)
+ {
attr_cnt++;
+ if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
+ attest_cnt++;
+ }
// ticket search
unsigned int found_attrs_cnt = 0;
+ unsigned int found_attests_cnt = 0;
for (int i = 0; i < rd_count; i++)
{
}
// cmp requested attributes with ticket attributes
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
+ if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
+ (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
continue;
for (le = tih->attrs->list_head; NULL != le; le = le->next)
{
- // cmp attr_ref id with requested attr id
- if (NULL !=le->claim)
- {
- if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(le->claim->id)))
- found_attrs_cnt++;
- }
- else if (NULL !=le->attest)
- {
- if (0 == memcmp (rd[i].data,
- &le->attest->id,
- sizeof(le->attest->id)))
- found_attrs_cnt++;
- }
- else if (NULL != le->reference)
- {
- if (0 == memcmp (rd[i].data,
- &le->reference->id,
- sizeof(le->reference->id)))
- found_attrs_cnt++;
- }
-
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
+ &le->attribute->id))
+ found_attrs_cnt++;
+ }
+ for (le = tih->attrs->list_head; NULL != le; le = le->next)
+ {
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data,
+ &le->attribute->attestation))
+ found_attests_cnt++;
}
}
* If we found a matching ticket, return that to the caller and
* we are done.
*/
- if ((attr_cnt == found_attrs_cnt) && (NULL != ticket))
+ if ((attr_cnt == found_attrs_cnt) &&
+ (attest_cnt == found_attests_cnt) &&
+ (NULL != ticket))
{
GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
*/
void
RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ const struct GNUNET_RECLAIM_AttributeList *attrs,
const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
RECLAIM_TICKETS_TicketResult cb,
void *cb_cls)
tih = GNUNET_new (struct TicketIssueHandle);
tih->cb = cb;
tih->cb_cls = cb_cls;
- tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs);
+ tih->attrs = GNUNET_RECLAIM_attribute_list_dup (attrs);
tih->identity = *identity;
tih->ticket.audience = *audience;
typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l,
+ const struct GNUNET_RECLAIM_AttributeList *l,
int32_t success,
const char *emsg);
*/
void
RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ const struct GNUNET_RECLAIM_AttributeList *attrs,
const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
RECLAIM_TICKETS_TicketResult cb,
void *cb_cls);
static int
parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
+ struct GNUNET_RECLAIM_Attribute *attr;
const char *name_str = NULL;
const char *val_str = NULL;
const char *type_str = NULL;
const char *id_str = NULL;
+ const char *attest_str = NULL;
const char *flag_str = NULL;
char *data;
int unpack_state;
}
// interpret single attribute
unpack_state = json_unpack (root,
- "{s:s, s?s, s:s, s:s, s?s!}",
+ "{s:s, s?s, s?s, s:s, s:s, s?s!}",
"name",
&name_str,
"id",
&id_str,
+ "attestation",
+ &attest_str,
"type",
&type_str,
"value",
"Error json object has a wrong format!\n");
return GNUNET_SYSERR;
}
- type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
+ type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
if (GNUNET_SYSERR ==
- (GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
+ (GNUNET_RECLAIM_attribute_string_to_value (type,
val_str,
(void **) &data,
&data_size)))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n");
return GNUNET_SYSERR;
}
- attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size);
+ attr = GNUNET_RECLAIM_attribute_new (name_str, NULL,
+ type, data, data_size);
+ if ((NULL != attest_str) && (0 != strlen (attest_str)))
+ {
+ GNUNET_STRINGS_string_to_data (attest_str,
+ strlen (attest_str),
+ &attr->attestation,
+ sizeof(attr->attestation));
+ }
if ((NULL == id_str) || (0 == strlen (id_str)))
memset (&attr->id, 0, sizeof (attr->id));
else
&attr->id,
sizeof(attr->id));
- *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr = attr;
+ *(struct GNUNET_RECLAIM_Attribute **) spec->ptr = attr;
return GNUNET_OK;
}
static void
clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr;
+ struct GNUNET_RECLAIM_Attribute **attr;
- attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr;
+ attr = (struct GNUNET_RECLAIM_Attribute **) spec->ptr;
if (NULL != *attr)
{
GNUNET_free (*attr);
/**
* JSON Specification for Reclaim claims.
*
- * @param ticket struct of GNUNET_RECLAIM_ATTRIBUTE_Claim to fill
+ * @param ticket struct of GNUNET_RECLAIM_Attribute to fill
* @return JSON Specification
*/
struct GNUNET_JSON_Specification
-GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr)
+GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr)
{
struct GNUNET_JSON_Specification ret = { .parser = &parse_attr,
.cleaner = &clean_attr,
static int
parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
{
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
+ struct GNUNET_RECLAIM_Attestation *attr;
const char *name_str = NULL;
const char *val_str = NULL;
const char *type_str = NULL;
"Error json object has a wrong format!\n");
return GNUNET_SYSERR;
}
- type = GNUNET_RECLAIM_ATTESTATION_typename_to_number (type_str);
+ type = GNUNET_RECLAIM_attestation_typename_to_number (type_str);
if (GNUNET_SYSERR ==
- (GNUNET_RECLAIM_ATTESTATION_string_to_value (type,
+ (GNUNET_RECLAIM_attestation_string_to_value (type,
val_str,
(void **) &data,
&data_size)))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attestation value invalid!\n");
return GNUNET_SYSERR;
}
- attr = GNUNET_RECLAIM_ATTESTATION_claim_new (name_str, type, data, data_size);
+ attr = GNUNET_RECLAIM_attestation_new (name_str, type, data, data_size);
if ((NULL == id_str) || (0 == strlen (id_str)))
memset (&attr->id, 0, sizeof (attr->id));
else
&attr->id,
sizeof(attr->id));
- *(struct GNUNET_RECLAIM_ATTESTATION_Claim **) spec->ptr = attr;
+ *(struct GNUNET_RECLAIM_Attestation **) spec->ptr = attr;
return GNUNET_OK;
}
static void
clean_attest (void *cls, struct GNUNET_JSON_Specification *spec)
{
- struct GNUNET_RECLAIM_ATTESTATION_Claim **attr;
+ struct GNUNET_RECLAIM_Attestation **attr;
- attr = (struct GNUNET_RECLAIM_ATTESTATION_Claim **) spec->ptr;
+ attr = (struct GNUNET_RECLAIM_Attestation **) spec->ptr;
if (NULL != *attr)
{
GNUNET_free (*attr);
*/
struct GNUNET_JSON_Specification
GNUNET_RECLAIM_JSON_spec_claim_attest (struct
- GNUNET_RECLAIM_ATTESTATION_Claim **attr)
+ GNUNET_RECLAIM_Attestation **attr)
{
struct GNUNET_JSON_Specification ret = { .parser = &parse_attest,
.cleaner = &clean_attest,
return ret;
}
-/**
- * Parse given JSON object to an attestation claim
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static int
-parse_attest_ref (void *cls, json_t *root, struct
- GNUNET_JSON_Specification *spec)
-{
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
- const char *name_str = NULL;
- const char *ref_val_str = NULL;
- const char *ref_id_str = NULL;
- const char *id_str = NULL;
- int unpack_state;
-
- GNUNET_assert (NULL != root);
-
- if (! json_is_object (root))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error json is not array nor object!\n");
- return GNUNET_SYSERR;
- }
- // interpret single reference
- unpack_state = json_unpack (root,
- "{s:s, s?s, s:s, s:s!}",
- "name",
- &name_str,
- "id",
- &id_str,
- "ref_id",
- &ref_id_str,
- "ref_value",
- &ref_val_str);
- if ((0 != unpack_state) || (NULL == name_str) || (NULL == ref_val_str) ||
- (NULL == ref_id_str))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error json object has a wrong format!\n");
- return GNUNET_SYSERR;
- }
-
- attr = GNUNET_RECLAIM_ATTESTATION_reference_new (name_str, ref_val_str);
- memset (&attr->id, 0, sizeof (attr->id));
-
- if ((NULL == ref_id_str) || (0 == strlen (ref_id_str)))
- memset (&attr->id_attest, 0, sizeof (attr->id_attest));
- else
- GNUNET_STRINGS_string_to_data (ref_id_str,
- strlen (ref_id_str),
- &attr->id_attest,
- sizeof(attr->id_attest));
-
- *(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **) spec->ptr = attr;
- return GNUNET_OK;
-}
-
-/**
- * Cleanup data left from parsing RSA public key.
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_attest_ref (void *cls, struct GNUNET_JSON_Specification *spec)
-{
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **attr;
-
- attr = (struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **) spec->ptr;
- if (NULL != *attr)
- {
- GNUNET_free (*attr);
- *attr = NULL;
- }
-}
-
-/**
- * JSON Specification for Reclaim attestation references.
- *
- * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_REFERENCE to fill
- * @return JSON Specification
- */
-struct GNUNET_JSON_Specification
-GNUNET_RECLAIM_JSON_spec_claim_attest_ref (struct
- GNUNET_RECLAIM_ATTESTATION_REFERENCE
- **attr)
-{
- struct GNUNET_JSON_Specification ret = { .parser = &parse_attest_ref,
- .cleaner = &clean_attest_ref,
- .cls = NULL,
- .field = NULL,
- .ptr = attr,
- .ptr_size = 0,
- .size_ptr = NULL };
-
- *attr = NULL;
- return ret;
-}
* @return JSON Specification
*/
struct GNUNET_JSON_Specification
-GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr);
+GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr);
/**
* JSON Specification for Reclaim tickets.
/**
* JSON Specification for Reclaim attestation claims.
*
- * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_Claim to fill
+ * @param ticket struct of GNUNET_RECLAIM_Attestation to fill
* @return JSON Specification
*/
struct GNUNET_JSON_Specification
GNUNET_RECLAIM_JSON_spec_claim_attest (struct
- GNUNET_RECLAIM_ATTESTATION_Claim **attr);
+ GNUNET_RECLAIM_Attestation **attr);
- /**
- * JSON Specification for Reclaim attestation references.
- *
- * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_REFERENCE to fill
- * @return JSON Specification
- */
- struct GNUNET_JSON_Specification
- GNUNET_RECLAIM_JSON_spec_claim_attest_ref(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **attr);
* The length of the attributes list
*/
uint32_t attr_list_len GNUNET_PACKED;
+
+ /**
+ * The length of the attestation list
+ */
+ uint32_t attest_list_len GNUNET_PACKED;
};
GNUNET_NETWORK_STRUCT_END
char *
OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ struct GNUNET_RECLAIM_AttributeList *attrs,
+ struct GNUNET_RECLAIM_AttestationList *attests,
const struct GNUNET_TIME_Relative *expiration_time,
const char *nonce,
const char *secret_key)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *le;
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
struct GNUNET_HashCode signature;
struct GNUNET_TIME_Absolute exp_time;
struct GNUNET_TIME_Absolute time_now;
json_t *aggr_names;
json_t *aggr_sources;
json_t *aggr_sources_jwt;
- struct GNUNET_RECLAIM_Identifier attest_arr[GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (attrs)];
+ int num_attestations = 0;
+ for (le = attrs->list_head; NULL != le; le = le->next)
+ {
+ if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
+ num_attestations++;
+ }
// iat REQUIRED time now
time_now = GNUNET_TIME_absolute_get ();
// nonce
if (NULL != nonce)
json_object_set_new (body, "nonce", json_string (nonce));
- int i = 0;
attest_val_str = NULL;
aggr_names_str = NULL;
aggr_sources_str = NULL;
aggr_sources_jwt_str = NULL;
source_name = NULL;
+ int i = 0;
+ for (ale = attests->list_head; NULL != ale; ale = ale->next)
+ {
+ // New Attestation
+ GNUNET_asprintf (&source_name,
+ "src%d",
+ i);
+ aggr_sources_jwt = json_object ();
+ attest_val_str =
+ GNUNET_RECLAIM_attestation_value_to_string (ale->attestation->type,
+ ale->attestation->data,
+ ale->attestation->data_size);
+ json_object_set_new (aggr_sources_jwt, "JWT",
+ json_string (attest_val_str) );
+ aggr_sources_jwt_str = json_dumps (aggr_sources_jwt, JSON_INDENT (0)
+ | JSON_COMPACT);
+ json_object_set_new (aggr_sources, source_name,json_string (
+ aggr_sources_jwt_str));
+ i++;
+ }
+
for (le = attrs->list_head; NULL != le; le = le->next)
{
- if (le->claim != NULL)
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
{
attr_val_str =
- GNUNET_RECLAIM_ATTRIBUTE_value_to_string (le->claim->type,
- le->claim->data,
- le->claim->data_size);
- json_object_set_new (body, le->claim->name, json_string (attr_val_str));
+ GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type,
+ le->attribute->data,
+ le->attribute->data_size);
+ json_object_set_new (body, le->attribute->name,
+ json_string (attr_val_str));
GNUNET_free (attr_val_str);
}
- else if (NULL != le->reference)
+ else
{
// Check if attest is there
int j = 0;
- while (j<i)
+ for (ale = attests->list_head; NULL != ale; ale = ale->next)
{
- if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j],
- &le->reference->id_attest))
+ if (GNUNET_YES ==
+ GNUNET_RECLAIM_id_is_equal (&ale->attestation->id,
+ &le->attribute->attestation))
break;
j++;
}
- if (j==i)
- {
- // Attest not yet existent. Append to the end of the list
- GNUNET_CONTAINER_DLL_remove (attrs->list_head, attrs->list_tail, le);
- GNUNET_CONTAINER_DLL_insert_tail (attrs->list_head, attrs->list_tail,
- le);
- continue;
- }
- else
- {
- // Attestation is existing, hence take the respective source str
- GNUNET_asprintf (&source_name,
- "src%d",
- j);
- json_object_set_new (aggr_names, le->reference->name, json_string (
- source_name));
- }
-
- }
- else if (NULL != le->attest)
- {
- // We assume that at max 99 different attestations
- int j = 0;
- while (j<i)
- {
- if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attest_arr[j],
- &le->attest->id))
- break;
- j++;
- }
- if (j==i)
- {
- // New Attestation
- attest_arr[i] = le->attest->id;
- GNUNET_asprintf (&source_name,
- "src%d",
- i);
- aggr_sources_jwt = json_object ();
- attest_val_str = GNUNET_RECLAIM_ATTESTATION_value_to_string (
- le->attest->type, le->attest->data, le->attest->data_size);
- json_object_set_new (aggr_sources_jwt, "JWT",json_string (
- attest_val_str) );
- aggr_sources_jwt_str = json_dumps (aggr_sources_jwt, JSON_INDENT (0)
- | JSON_COMPACT);
- json_object_set_new (aggr_sources, source_name,json_string (
- aggr_sources_jwt_str));
- i++;
- }
- else
- {
- // Attestation already existent. Ignore
- continue;
- }
-
+ GNUNET_assert (NULL != ale);
+ // Attestation is existing, hence take the respective source str
+ GNUNET_asprintf (&source_name,
+ "src%d",
+ j);
+ json_object_set_new (aggr_names, le->attribute->data,
+ json_string (source_name));
}
}
+
if (NULL != attest_val_str)
GNUNET_free (attest_val_str);
if (NULL != source_name)
GNUNET_free (source_name);
- if (0!=i)
+ if (0 != i)
{
aggr_names_str = json_dumps (aggr_names, JSON_INDENT (0) | JSON_COMPACT);
aggr_sources_str = json_dumps (aggr_sources, JSON_INDENT (0)
char *
OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
const struct GNUNET_RECLAIM_Ticket *ticket,
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ struct GNUNET_RECLAIM_AttributeList *attrs,
+ struct GNUNET_RECLAIM_AttestationList *attests,
const char *nonce_str,
const char *code_challenge)
{
size_t payload_len;
size_t code_payload_len;
size_t attr_list_len = 0;
+ size_t attests_list_len = 0;
size_t code_challenge_len = 0;
uint32_t nonce;
uint32_t nonce_tmp;
if (NULL != attrs)
{
// Get length
- attr_list_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
+ attr_list_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
params.attr_list_len = htonl (attr_list_len);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Length of serialized attributes: %lu\n",
// Get serialized attributes
payload_len += attr_list_len;
}
+ if (NULL != attests)
+ {
+ // Get length
+ attests_list_len =
+ GNUNET_RECLAIM_attestation_list_serialize_get_size (attests);
+ params.attest_list_len = htonl (attests_list_len);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Length of serialized attestations: %lu\n",
+ attests_list_len);
+ // Get serialized attributes
+ payload_len += attests_list_len;
+ }
+
// Get plaintext length
payload = GNUNET_malloc (payload_len);
memcpy (payload, ¶ms, sizeof(params));
tmp += code_challenge_len;
}
if (0 < attr_list_len)
- GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, tmp);
+ GNUNET_RECLAIM_attribute_list_serialize (attrs, tmp);
+ if (0 < attests_list_len)
+ GNUNET_RECLAIM_attestation_list_serialize (attests, tmp);
+
/** END **/
/** ENCRYPT **/
const char *code,
const char *code_verifier,
struct GNUNET_RECLAIM_Ticket *ticket,
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs,
+ struct GNUNET_RECLAIM_AttributeList **attrs,
+ struct GNUNET_RECLAIM_AttestationList **attests,
char **nonce_str)
{
char *code_payload;
// Attributes
attrs_ser = ((char *) ¶ms[1]) + code_challenge_len;
attrs_ser_len = ntohl (params->attr_list_len);
- *attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (attrs_ser, attrs_ser_len);
+ *attrs = GNUNET_RECLAIM_attribute_list_deserialize (attrs_ser, attrs_ser_len);
*nonce_str = NULL;
if (nonce != 0)
char*
OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ struct GNUNET_RECLAIM_AttributeList *attrs,
+ struct GNUNET_RECLAIM_AttestationList *attests,
const struct GNUNET_TIME_Relative *expiration_time,
const char *nonce,
const char *secret_key);
char*
OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
const struct GNUNET_RECLAIM_Ticket *ticket,
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ struct GNUNET_RECLAIM_AttributeList *attrs,
+ struct GNUNET_RECLAIM_AttestationList *attests,
const char *nonce,
const char *code_challenge);
const char *code,
const char *code_verifier,
struct GNUNET_RECLAIM_Ticket *ticket,
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs,
+ struct GNUNET_RECLAIM_AttributeList **attrs,
+ struct GNUNET_RECLAIM_AttestationList **attests,
char **nonce);
/**
{
switch (type)
{
- case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
- return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
-
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
return GNUNET_strndup (data, data_size);
-
- case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF:
return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
default:
return GNUNET_SYSERR;
switch (type)
{
- case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
- return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
-
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
*data = GNUNET_strdup (s);
*data_size = strlen (s);
return GNUNET_OK;
-
- case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF:
return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
default:
const char *name;
uint32_t number;
} name_map[] = {
- { "RECLAIM_ATTR", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR },
- { "RECLAIM_ATTR_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF },
- { "RECLAIM_ATTEST", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR },
+ { "RECLAIM_ATTRIBUTE", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE },
+ { "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF },
+ { "RECLAIM_ATTESTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION },
+ { "RECLAIM_ATTESTATION_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF },
{ "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER },
{ "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT },
{ "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT },
{ "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET },
- { "RECLAIM_REFERENCE", GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE },
{ NULL, UINT32_MAX }
};
/**
* Attribute claim list
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list;
+ struct GNUNET_RECLAIM_AttributeList *attr_list;
+
+ /**
+ * Attestation list
+ */
+ struct GNUNET_RECLAIM_AttestationList *attests_list;
+
/**
* IDENTITY Operation
static void
cleanup_handle (struct RequestHandle *handle)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
+ struct GNUNET_RECLAIM_AttributeListEntry *claim_entry;
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
json_decref (handle->oidc->response);
GNUNET_free (handle->oidc);
}
- if (NULL != handle->attr_list)
- {
- for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;)
- {
- claim_tmp = claim_entry;
- claim_entry = claim_entry->next;
- if (NULL != claim_tmp->claim)
- GNUNET_free (claim_tmp->claim);
- if (NULL != claim_tmp->attest)
- GNUNET_free (claim_tmp->attest);
- if (NULL != claim_tmp->reference)
- GNUNET_free (claim_tmp->reference);
- GNUNET_free (claim_tmp);
- }
- GNUNET_free (handle->attr_list);
- }
+ GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list);
+ GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list);
+
for (ego_entry = handle->ego_head; NULL != ego_entry;)
{
ego_tmp = ego_entry;
code_string = OIDC_build_authz_code (&handle->priv_key,
&handle->ticket,
handle->attr_list,
+ handle->attests_list,
handle->oidc->nonce,
handle->oidc->code_challenge);
if ((NULL != handle->redirect_prefix) && (NULL != handle->redirect_suffix) &&
/**
- * Collects all attributes/references for an ego if in scope parameter
+ * Collects all attributes for an ego if in scope parameter
*/
static void
oidc_attr_collect (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
struct RequestHandle *handle = cls;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_RECLAIM_AttributeListEntry *le;
char *scope_variables;
char *scope_variable;
char delimiter[] = " ";
- if ((NULL == attr) && (NULL == reference))
+ scope_variables = GNUNET_strdup (handle->oidc->scope);
+ scope_variable = strtok (scope_variables, delimiter);
+ while (NULL != scope_variable)
{
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
- return;
+ if (0 == strcmp (attr->name, scope_variable))
+ break;
+ scope_variable = strtok (NULL, delimiter);
}
- if (NULL != reference)
+ if (NULL == scope_variable)
{
- if ((NULL == reference->name) || (NULL == reference->reference_value))
- {
- return;
- }
- scope_variables = GNUNET_strdup (handle->oidc->scope);
- scope_variable = strtok (scope_variables, delimiter);
- while (NULL != scope_variable)
- {
- if (0 == strcmp (reference->name, scope_variable))
- break;
- scope_variable = strtok (NULL, delimiter);
- }
- if (NULL == scope_variable)
- {
- GNUNET_free (scope_variables);
- return;
- }
+ GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
GNUNET_free (scope_variables);
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le2;
- le2 = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- le->claim = NULL;
- le->reference = NULL;
- le->attest = GNUNET_RECLAIM_ATTESTATION_claim_new (attest->name,
+ // We can ignore this
+ return;
+ }
+ GNUNET_free (scope_variables);
+ le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
+ le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
+ &attr->attestation,
+ attr->type,
+ attr->data,
+ attr->data_size);
+ le->attribute->id = attr->id;
+ le->attribute->flag = attr->flag;
+ le->attribute->attestation = attr->attestation;
+ GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
+ handle->attr_list->list_tail,
+ le);
+ if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
+ {
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
+ ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
+ ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name,
attest->type,
attest->data,
attest->data_size);
- le->attest->id = attest->id;
- le2->attest = NULL;
- le2->claim = NULL;
- le2->reference = GNUNET_RECLAIM_ATTESTATION_reference_new (reference->name,
- reference->
- reference_value);
- le2->reference->id = reference->id;
- le2->reference->id_attest = reference->id_attest;
- GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
- handle->attr_list->list_tail,
- le);
- GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
- handle->attr_list->list_tail,
- le2);
- }
- else if (NULL != attr)
- {
- if ((NULL == attr->name) || (NULL == attr->data))
- {
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
- return;
- }
- scope_variables = GNUNET_strdup (handle->oidc->scope);
- scope_variable = strtok (scope_variables, delimiter);
- while (NULL != scope_variable)
- {
- if (0 == strcmp (attr->name, scope_variable))
- break;
- scope_variable = strtok (NULL, delimiter);
- }
- if (NULL == scope_variable)
- {
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
- GNUNET_free (scope_variables);
- return;
- }
- GNUNET_free (scope_variables);
- le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- le->reference = NULL;
- le->attest = NULL;
- le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
- attr->type,
- attr->data,
- attr->data_size);
- le->claim->id = attr->id;
- le->claim->flag = attr->flag;
-
- GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
- handle->attr_list->list_tail,
- le);
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
+ GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head,
+ handle->attests_list->list_tail,
+ ale);
}
+ GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
}
*GNUNET_IDENTITY_ego_get_private_key (handle->ego_entry->ego);
handle->idp = GNUNET_RECLAIM_connect (cfg);
handle->attr_list =
- GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
+ GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
handle->attr_it =
GNUNET_RECLAIM_get_attributes_start (handle->idp,
&handle->priv_key,
struct RequestHandle *handle = cls;
const struct EgoEntry *ego_entry;
struct GNUNET_TIME_Relative expiration_time;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *cl;
+ struct GNUNET_RECLAIM_AttributeList *cl;
+ struct GNUNET_RECLAIM_AttestationList *al;
struct GNUNET_RECLAIM_Ticket ticket;
struct GNUNET_CRYPTO_EcdsaPublicKey cid;
const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
// decode code
if (GNUNET_OK != OIDC_parse_authz_code (privkey, code, code_verifier, &ticket,
- &cl, &nonce))
+ &cl, &al, &nonce))
{
handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_REQUEST);
handle->edesc = GNUNET_strdup ("invalid code");
id_token = OIDC_id_token_new (&ticket.audience,
&ticket.identity,
cl,
+ al,
&expiration_time,
(NULL != nonce) ? nonce : NULL,
jwt_secret);
MHD_add_response_header (resp, "Pragma", "no-cache");
MHD_add_response_header (resp, "Content-Type", "application/json");
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cl);
+ GNUNET_RECLAIM_attribute_list_destroy (cl);
+ GNUNET_RECLAIM_attestation_list_destroy (al);
GNUNET_free (access_token);
GNUNET_free (json_response);
GNUNET_free (id_token);
/**
- * Collects claims and stores them in handle
- */
+ * Collects claims and stores them in handle
+ */
static void
consume_ticket (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
struct RequestHandle *handle = cls;
if (NULL == identity)
GNUNET_SCHEDULER_add_now (&return_userinfo_response, handle);
return;
}
- if (NULL != attr)
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
{
char *tmp_value;
json_t *value;
- tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
+ tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
attr->data,
attr->data_size);
value = json_string (tmp_value);
json_object_set_new (handle->oidc->response, attr->name, value);
GNUNET_free (tmp_value);
+ return;
}
- else if ((NULL != attest) && (NULL != reference))
- {
- json_t *claim_sources;
- json_t *claim_sources_jwt;
- json_t *claim_names;
- char *attest_val_str;
- claim_sources=json_object_get(handle->oidc->response,"_claim_sources");
- claim_names=json_object_get(handle->oidc->response,"_claim_names");
- attest_val_str = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type,
- attest->data,
- attest->
- data_size);
- if ((NULL == claim_sources) && (NULL == claim_names) )
- {
- claim_sources = json_object ();
- claim_names = json_object ();
- }
- char *source_name;
- int i = 0;
- GNUNET_asprintf (&source_name,"src%d",i);
- while (NULL != (claim_sources_jwt = json_object_get (claim_sources,
- source_name)))
+ json_t *claim_sources;
+ json_t *claim_sources_jwt;
+ json_t *claim_names;
+ char *attest_val_str;
+ claim_sources = json_object_get (handle->oidc->response,"_claim_sources");
+ claim_names = json_object_get (handle->oidc->response,"_claim_names");
+ attest_val_str =
+ GNUNET_RECLAIM_attestation_value_to_string (attest->type,
+ attest->data,
+ attest->data_size);
+ if ((NULL == claim_sources) && (NULL == claim_names) )
+ {
+ claim_sources = json_object ();
+ claim_names = json_object ();
+ }
+ char *source_name;
+ int i = 0;
+ GNUNET_asprintf (&source_name, "src%d", i);
+ while (NULL != (claim_sources_jwt = json_object_get (claim_sources,
+ source_name)))
+ {
+ if (0 == strcmp (json_string_value (json_object_get (claim_sources_jwt,
+ "JWT")),
+ attest_val_str))
{
- if (0 == strcmp (json_string_value (json_object_get (claim_sources_jwt,
- "JWT")),
- attest_val_str))
- {
- // Adapt only the claim names
- json_object_set_new (claim_names, reference->name, json_string (
- source_name));
- json_object_set (handle->oidc->response, "_claim_names",claim_names);
- handle->oidc->response = json_deep_copy(handle->oidc->response);
- break;
- }
- i++;
- GNUNET_asprintf (&source_name,"src%d",i);
- }
-
- // Create new one
- if (NULL == claim_sources_jwt)
- {
- claim_sources_jwt = json_object ();
- // Set the JWT for names
- json_object_set_new (claim_names, reference->name, json_string (
- source_name));
- // Set the JWT for the inner source
- json_object_set_new (claim_sources_jwt, "JWT", json_string (
- attest_val_str));
- // Set the JWT for the source
- json_object_set_new (claim_sources, source_name,claim_sources_jwt);
- // Set as claims
- json_object_set (handle->oidc->response, "_claim_names", claim_names);
- json_object_set (handle->oidc->response, "_claim_sources",claim_sources);
- handle->oidc->response = json_deep_copy(handle->oidc->response);
+ // Adapt only the claim names
+ json_object_set_new (claim_names, attr->data,
+ json_string (source_name));
+ json_object_set (handle->oidc->response,
+ "_claim_names", claim_names);
+ break;
}
-
- json_decref (claim_sources);
- json_decref (claim_names);
- json_decref (claim_sources_jwt);
- GNUNET_free (attest_val_str);
- }
- else
- {
- // REMARK: We should not find any claim, one of attest/ref is NULL
- }
+ i++;
+ GNUNET_free (source_name);
+ GNUNET_asprintf (&source_name, "src%d", i);
+ }
+
+ // Create new one
+ if (NULL == claim_sources_jwt)
+ {
+ claim_sources_jwt = json_object ();
+ // Set the JWT for names
+ json_object_set_new (claim_names, attr->data,
+ json_string (source_name));
+ // Set the JWT for the inner source
+ json_object_set_new (claim_sources_jwt, "JWT",
+ json_string (attest_val_str));
+ // Set the JWT for the source
+ json_object_set_new (claim_sources, source_name, claim_sources_jwt);
+ // Set as claims
+ json_object_set (handle->oidc->response, "_claim_names", claim_names);
+ json_object_set (handle->oidc->response, "_claim_sources",claim_sources);
+ }
+
+ json_decref (claim_sources);
+ json_decref (claim_names);
+ json_decref (claim_sources_jwt);
+ GNUNET_free (attest_val_str);
}
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES "/reclaim/attributes"
/**
- * Attestation namespace
- */
-#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE "/reclaim/attestation"
+ * Attestation namespace
+ */
+#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION "/reclaim/attestation"
/**
* Ticket namespace
/**
* Attribute claim list
*/
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list;
+ struct GNUNET_RECLAIM_AttributeList *attr_list;
/**
* IDENTITY Operation
*/
struct GNUNET_RECLAIM_AttributeIterator *attr_it;
+ /**
+ * Attribute iterator
+ */
+ struct GNUNET_RECLAIM_AttestationIterator *attest_it;
+
+
/**
* Ticket iterator
*/
static void
cleanup_handle (struct RequestHandle *handle)
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
GNUNET_IDENTITY_disconnect (handle->identity_handle);
if (NULL != handle->attr_it)
GNUNET_RECLAIM_get_attributes_stop (handle->attr_it);
+ if (NULL != handle->attest_it)
+ GNUNET_RECLAIM_get_attestations_stop (handle->attest_it);
if (NULL != handle->ticket_it)
GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it);
if (NULL != handle->idp)
GNUNET_free (handle->url);
if (NULL != handle->emsg)
GNUNET_free (handle->emsg);
- if (NULL != handle->attr_list)
- {
- for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;)
- {
- claim_tmp = claim_entry;
- claim_entry = claim_entry->next;
- GNUNET_free (claim_tmp->claim);
- GNUNET_free (claim_tmp->attest);
- GNUNET_free (claim_tmp->reference);
- GNUNET_free (claim_tmp);
- }
- GNUNET_free (handle->attr_list);
- }
+ GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list);
for (ego_entry = handle->ego_head; NULL != ego_entry;)
{
ego_tmp = ego_entry;
GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
}
+
static void
delete_finished_cb (void *cls, int32_t success, const char *emsg)
{
GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
}
+
/**
* Return attributes for identity
*
}
-static void
-add_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle,
- const char *url,
- void *cls)
-{
- struct RequestHandle *handle = cls;
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
- const char *identity;
- struct EgoEntry *ego_entry;
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attribute;
- struct GNUNET_TIME_Relative exp;
- char term_data[handle->rest_handle->data_size + 1];
- json_t *data_json;
- json_error_t err;
- struct GNUNET_JSON_Specification attrspec[] =
- { GNUNET_RECLAIM_JSON_spec_claim_attest_ref (&attribute),
- GNUNET_JSON_spec_end () };
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding an attestation reference for %s.\n",
- handle->url);
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen (
- "reference/") + 1 >= strlen (
- handle->url))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- identity = handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/")
- + 1;
- for (ego_entry = handle->ego_head; NULL != ego_entry;
- ego_entry = ego_entry->next)
- if (0 == strcmp (identity, ego_entry->identifier))
- break;
- if (NULL == ego_entry)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
- return;
- }
- identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
- if (0 >= handle->rest_handle->data_size)
- {
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-
- term_data[handle->rest_handle->data_size] = '\0';
- GNUNET_memcpy (term_data,
- handle->rest_handle->data,
- handle->rest_handle->data_size);
- data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
- json_decref (data_json);
- if (NULL == attribute)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to parse attestation reference from %s\n",
- term_data);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- /**
- * New ID for attribute
- */
- if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
- attribute->id = attribute->id_attest;
- handle->idp = GNUNET_RECLAIM_connect (cfg);
- exp = GNUNET_TIME_UNIT_HOURS;
- handle->idp_op = GNUNET_RECLAIM_attestation_reference_store (handle->idp,
- identity_priv,
- attribute,
- &exp,
- &finished_cont,
- handle);
- GNUNET_JSON_parse_free (attrspec);
-}
-
static void
parse_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
const char *url,
}
if (0 == strcmp (type_str, "JWT"))
{
- // The value is a JWT
- char *decoded_jwt;
- char delim[] = ".";
- char *jwt_body = strtok (val_str, delim);
- jwt_body = strtok (NULL, delim);
- GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
- (void **) &decoded_jwt);
- resp = GNUNET_REST_create_response (decoded_jwt);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- GNUNET_free (decoded_jwt);
+ // The value is a JWT
+ char *decoded_jwt;
+ char delim[] = ".";
+ char *jwt_body = strtok (val_str, delim);
+ jwt_body = strtok (NULL, delim);
+ GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
+ (void **) &decoded_jwt);
+ resp = GNUNET_REST_create_response (decoded_jwt);
+ handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
+ GNUNET_free (decoded_jwt);
}
else
{
json_decref (data_json);
}
+
static void
add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
const char *url,
void *cls)
{
struct RequestHandle *handle = cls;
- /* Check for substring "reference" */
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
+ /* Check for substring "parse"
+ * FIXME UGLY! */
+ if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) < strlen (
handle->url))
{
- if ( strncmp ("reference/", (handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
- + 1), strlen (
- "reference/")) == 0)
+ if (strncmp ("parse", (handle->url + strlen (
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION)
+ + 1), strlen (
+ "parse")) == 0)
{
- add_attestation_ref_cont (con_handle,url,cls);
+ parse_attestation_cont (con_handle,url,cls);
return;
}
}
- /* Check for substring "parse" */
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
- handle->url))
- {
- if ( strncmp ("parse", (handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
- + 1), strlen (
- "parse")) == 0)
- {
- parse_attestation_cont (con_handle,url,cls);
- return;
- }
- }
const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
const char *identity;
struct EgoEntry *ego_entry;
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attribute;
+ struct GNUNET_RECLAIM_Attestation *attribute;
struct GNUNET_TIME_Relative exp;
char term_data[handle->rest_handle->data_size + 1];
json_t *data_json;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding an attestation for %s.\n",
handle->url);
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
+ if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
handle->url))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
return;
}
identity = handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1;
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1;
for (ego_entry = handle->ego_head; NULL != ego_entry;
ego_entry = ego_entry->next)
GNUNET_JSON_parse_free (attrspec);
}
-/**
- * Collect all references for an ego
- *
- */
-static void
-ref_collect (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
-{
- struct RequestHandle *handle = cls;
- json_t *attr_obj;
- char *id_str;
- char *id_attest_str;
-
- if (NULL == reference)
- {
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
- return;
- }
-
- if ((NULL == reference->name) || (NULL == reference->reference_value))
- {
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference: %s\n",
- reference->name);
- attr_obj = json_object ();
- json_object_set_new (attr_obj, "name", json_string (reference->name));
- json_object_set_new (attr_obj, "ref_value", json_string (
- reference->reference_value));
- id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id,
- sizeof(reference->id));
- id_attest_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id_attest,
- sizeof(reference->id_attest));
- json_object_set_new (attr_obj, "id", json_string (id_str));
- json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str));
- json_array_append (handle->resp_object, attr_obj);
- json_decref (attr_obj);
-}
-
-/**
- * Lists references for identity request
- *
- * @param con_handle the connection handle
- * @param url the url
- * @param cls the RequestHandle
- */
-static void
-list_reference_cont (struct GNUNET_REST_RequestHandle *con_handle,
- const char *url,
- void *cls)
-{
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
- struct RequestHandle *handle = cls;
- struct EgoEntry *ego_entry;
- char *identity;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Getting references for %s.\n",
- handle->url);
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen (
- "reference/") + 1 >= strlen (
- handle->url))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- identity = handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/")
- + 1;
- for (ego_entry = handle->ego_head; NULL != ego_entry;
- ego_entry = ego_entry->next)
- if (0 == strcmp (identity, ego_entry->identifier))
- break;
- handle->resp_object = json_array ();
-
- if (NULL == ego_entry)
- {
- // Done
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
- GNUNET_SCHEDULER_add_now (&return_response, handle);
- return;
- }
- priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
- handle->idp = GNUNET_RECLAIM_connect (cfg);
- handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp,
- priv_key,
- &collect_error_cb,
- handle,
- &ref_collect,
- handle,
- &collect_finished_cb,
- handle);
-}
/**
* Collect all attestations for an ego
static void
attest_collect (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
struct RequestHandle *handle = cls;
json_t *attr_obj;
char *id_str;
- if (NULL != reference)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Attestation Collection with Reference\n");
- return;
- }
if (NULL == attest)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n",
attest->name);
- tmp_value = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type,
+ tmp_value = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
attest->data,
attest->data_size);
attr_obj = json_object ();
json_object_set_new (attr_obj, "value", json_string (tmp_value));
json_object_set_new (attr_obj, "name", json_string (attest->name));
- type = GNUNET_RECLAIM_ATTESTATION_number_to_typename (attest->type);
+ type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
json_object_set_new (attr_obj, "type", json_string (type));
- id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id));
+ id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id,
+ sizeof(attest->id));
json_object_set_new (attr_obj, "id", json_string (id_str));
json_array_append (handle->resp_object, attr_obj);
json_decref (attr_obj);
void *cls)
{
struct RequestHandle *handle = cls;
- /* Check for substring "reference" */
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
- handle->url))
- {
- if ( strncmp ("reference/", (handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
- + 1), strlen (
- "reference/")) == 0)
- {
- list_reference_cont (con_handle,url,cls);
- return;
- }
- }
const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
struct EgoEntry *ego_entry;
char *identity;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Getting attestations for %s.\n",
handle->url);
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
+ if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
handle->url))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
return;
}
identity = handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1;
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1;
for (ego_entry = handle->ego_head; NULL != ego_entry;
ego_entry = ego_entry->next)
}
priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
handle->idp = GNUNET_RECLAIM_connect (cfg);
- handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp,
- priv_key,
- &collect_error_cb,
- handle,
- &attest_collect,
- handle,
- &collect_finished_cb,
- handle);
-}
-
-/**
- * Deletes reference from an identity
- *
- * @param con_handle the connection handle
- * @param url the url
- * @param cls the RequestHandle
- */
-static void
-delete_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle,
- const char *url,
- void *cls)
-{
- struct RequestHandle *handle = cls;
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
- struct EgoEntry *ego_entry;
- char *identity;
- char *identity_id_str;
- char *id;
- char term_data[handle->rest_handle->data_size + 1];
- json_t *data_json;
- json_error_t err;
-
- struct GNUNET_JSON_Specification attrspec[] =
- { GNUNET_RECLAIM_JSON_spec_claim_attest_ref (&attr),
- GNUNET_JSON_spec_end () };
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deleting attestation reference.\n");
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen (
- "reference/") + 1 >= strlen (
- handle->url))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- identity_id_str = strdup (handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
- + strlen ("reference/")
- + 1);
- identity = strtok (identity_id_str, "/");
- id = strtok (NULL, "/");
-
- if ((NULL == identity) || (NULL == id))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- for (ego_entry = handle->ego_head; NULL != ego_entry;
- ego_entry = ego_entry->next)
- if (0 == strcmp (identity, ego_entry->identifier))
- break;
- handle->resp_object = json_array ();
- if (NULL == ego_entry)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
- GNUNET_SCHEDULER_add_now (&return_response, handle);
- return;
- }
- priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
- if (0 >= handle->rest_handle->data_size)
- {
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-
- term_data[handle->rest_handle->data_size] = '\0';
- GNUNET_memcpy (term_data,
- handle->rest_handle->data,
- handle->rest_handle->data_size);
- data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
- json_decref (data_json);
- if (NULL == attr)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to parse attestation reference from %s\n",
- term_data);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(attr->id));
-
- handle->idp = GNUNET_RECLAIM_connect (cfg);
- handle->idp_op = GNUNET_RECLAIM_attestation_reference_delete (handle->idp,
- priv_key,
- attr,
- &
- delete_finished_cb,
- handle);
- GNUNET_JSON_parse_free (attrspec);
+ handle->attest_it = GNUNET_RECLAIM_get_attestations_start (handle->idp,
+ priv_key,
+ &collect_error_cb,
+ handle,
+ &attest_collect,
+ handle,
+ &collect_finished_cb,
+ handle);
}
void *cls)
{
struct RequestHandle *handle = cls;
- /* Check for substring "reference" */
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
- handle->url))
- {
- if ( strncmp ("reference", (handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE)
- + 1), strlen (
- "reference")) == 0)
- {
- delete_attestation_ref_cont (con_handle,url,cls);
- return;
- }
- }
const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
- struct GNUNET_RECLAIM_ATTESTATION_Claim attr;
+ struct GNUNET_RECLAIM_Attestation attr;
struct EgoEntry *ego_entry;
char *identity_id_str;
char *identity;
char *id;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
- if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
+ if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
handle->url))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
}
identity_id_str =
strdup (handle->url + strlen (
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1);
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION) + 1);
identity = strtok (identity_id_str, "/");
id = strtok (NULL, "/");
if ((NULL == identity) || (NULL == id))
}
priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
handle->idp = GNUNET_RECLAIM_connect (cfg);
- memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim));
+ memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attestation));
GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
attr.name = "";
handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp,
GNUNET_free (identity_id_str);
}
+
/**
* List tickets for identity request
*
const char *identity;
struct RequestHandle *handle = cls;
struct EgoEntry *ego_entry;
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attribute;
+ struct GNUNET_RECLAIM_Attribute *attribute;
struct GNUNET_TIME_Relative exp;
char term_data[handle->rest_handle->data_size + 1];
json_t *data_json;
GNUNET_JSON_parse_free (attrspec);
}
+
/**
* Parse a JWT and return the respective claim value as Attribute
*
* @param attest the jwt attestation
* @param claim the name of the claim in the JWT
*
- * @return a GNUNET_RECLAIM_ATTRIBUTE_Claim, containing the new value
+ * @return a GNUNET_RECLAIM_Attribute, containing the new value
*/
-struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+struct GNUNET_RECLAIM_Attribute *
+parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest,
const char *claim)
{
char *jwt_string;
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
+ struct GNUNET_RECLAIM_Attribute *attr;
char delim[] = ".";
const char *type_str = NULL;
const char *val_str = NULL;
json_t *json_val;
json_error_t *json_err = NULL;
- jwt_string = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type,
+ jwt_string = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
attest->data,
attest->data_size);
char *jwt_body = strtok (jwt_string, delim);
}
}
type_str = "String";
- type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
- if (GNUNET_SYSERR ==(GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,val_str,
+ type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
+ if (GNUNET_SYSERR == GNUNET_RECLAIM_attribute_string_to_value (type,val_str,
(void **) &data,
- &data_size)))
+ &data_size))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Attribute value from JWT Parser invalid!\n");
- GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
+ GNUNET_RECLAIM_attribute_string_to_value (type,
"Error: Referenced Claim Name not Found",
(void **) &data,
&data_size);
- attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size);
+ attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id,
+ type, data, data_size);
attr->id = attest->id;
attr->flag = 1;
}
else
{
- attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size);
+ attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id,
+ type, data, data_size);
attr->id = attest->id;
attr->flag = 1;
}
static void
attr_collect (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
struct RequestHandle *handle = cls;
json_t *attr_obj;
const char *type;
char *id_str;
- if ((NULL == attr) && (NULL == reference))
+ if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Attribute Collection with empty Attribute/Reference\n");
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
- return;
- }
-
- if (NULL == attr)
- {
-
- if ((NULL == reference->name) || (NULL == reference->reference_value))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Attribute Collection with empty Reference Name/Value\n");
- return;
- }
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr2;
- attr2 = parse_jwt (attest, reference->reference_value);
+ struct GNUNET_RECLAIM_Attribute *attr2;
+ attr2 = parse_jwt (attest, attr->data);
if (NULL == attr2)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Attribute Collection with unparsed Attestation\n");
return;
}
- attr2->name = reference->name;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n",
- reference->name);
+ attr2->name = attr->name;
char *tmp_value;
- tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr2->type,
+ tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr2->type,
attr2->data,
attr2->data_size);
attr_obj = json_object ();
-
json_object_set_new (attr_obj, "value", json_string (tmp_value));
json_object_set_new (attr_obj, "name", json_string (attr2->name));
json_object_set_new (attr_obj, "flag", json_string ("1"));
- type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr2->type);
+ type = GNUNET_RECLAIM_attribute_number_to_typename (attr2->type);
json_object_set_new (attr_obj, "type", json_string (type));
id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id,
sizeof(attr2->id));
}
else
{
- if ((NULL == attr->name) || (NULL == attr->data))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Attribute Collection with empty Attribute Name/Value\n");
- GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
- return;
- }
char *tmp_value;
char *flag_str;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
- tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
+ tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
attr->data,
attr->data_size);
json_object_set_new (attr_obj, "name", json_string (attr->name));
GNUNET_asprintf (&flag_str,"%d",attr->flag);
json_object_set_new (attr_obj, "flag", json_string (flag_str));
- type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
+ type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
json_object_set_new (attr_obj, "type", json_string (type));
id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
sizeof(attr->id));
}
}
+
/**
* List attributes for identity request
*
{
const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
struct RequestHandle *handle = cls;
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr;
+ struct GNUNET_RECLAIM_Attribute attr;
struct EgoEntry *ego_entry;
char *identity_id_str;
char *identity;
}
priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
handle->idp = GNUNET_RECLAIM_connect (cfg);
- memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim));
+ memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
attr.name = "";
handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
static void
consume_cont (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
+ const struct GNUNET_RECLAIM_Attribute *attr,
+ const struct GNUNET_RECLAIM_Attestation *attest)
{
struct RequestHandle *handle = cls;
char *val_str;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
- val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
+ val_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
attr->data,
attr->data_size);
if (NULL == val_str)
GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
&delete_attribute_cont },
{ MHD_HTTP_METHOD_GET,
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE,
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION,
&list_attestation_cont },
{ MHD_HTTP_METHOD_POST,
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE,
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION,
&add_attestation_cont },
{ MHD_HTTP_METHOD_DELETE,
- GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE,
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION,
&delete_attestation_cont },
{ MHD_HTTP_METHOD_GET,
GNUNET_REST_API_NS_IDENTITY_TICKETS,
*/
uint16_t attr_len GNUNET_PACKED;
+ /**
+ * Length of serialized attestation data
+ */
+ uint16_t attestation_len GNUNET_PACKED;
+
/**
* always zero (for alignment)
*/
*/
};
+/**
+ * Attestation is returned from the idp.
+ */
+struct AttestationResultMessage
+{
+ /**
+ * Message header
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Unique identifier for this request (for key collisions).
+ */
+ uint32_t id GNUNET_PACKED;
+
+ /**
+ * Length of serialized attribute data
+ */
+ uint16_t attestation_len GNUNET_PACKED;
+
+ /**
+ * always zero (for alignment)
+ */
+ uint16_t reserved GNUNET_PACKED;
+
+ /**
+ * The public key of the identity.
+ */
+ struct GNUNET_CRYPTO_EcdsaPublicKey identity;
+
+ /* followed by:
+ * serialized attestation data
+ */
+};
+
+
/**
* Reference plus Attestation is returned from the idp.
*/
*/
uint16_t attrs_len GNUNET_PACKED;
+ /**
+ * Length of attestation data
+ */
+ uint16_t attestations_len;
+
/**
* always zero (for alignment)
*/
*/
GNUNET_RECLAIM_AttributeResult ar_cb;
+ /**
+ * Attestation result callback
+ */
+ GNUNET_RECLAIM_AttestationResult at_cb;
+
/**
* Revocation result callback
*/
uint32_t r_id;
};
+/**
+ * Handle for a attestation iterator operation
+ */
+struct GNUNET_RECLAIM_AttestationIterator
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct GNUNET_RECLAIM_AttestationIterator *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct GNUNET_RECLAIM_AttestationIterator *prev;
+
+ /**
+ * Main handle to access the service.
+ */
+ struct GNUNET_RECLAIM_Handle *h;
+
+ /**
+ * Function to call on completion.
+ */
+ GNUNET_SCHEDULER_TaskCallback finish_cb;
+
+ /**
+ * Closure for @e finish_cb.
+ */
+ void *finish_cb_cls;
+
+ /**
+ * The continuation to call with the results
+ */
+ GNUNET_RECLAIM_AttestationResult proc;
+
+ /**
+ * Closure for @e proc.
+ */
+ void *proc_cls;
+
+ /**
+ * Function to call on errors.
+ */
+ GNUNET_SCHEDULER_TaskCallback error_cb;
+
+ /**
+ * Closure for @e error_cb.
+ */
+ void *error_cb_cls;
+
+ /**
+ * Envelope of the message to send to the service, if not yet
+ * sent.
+ */
+ struct GNUNET_MQ_Envelope *env;
+
+ /**
+ * Private key of the zone.
+ */
+ struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
+
+ /**
+ * The operation id this zone iteration operation has
+ */
+ uint32_t r_id;
+};
+
/**
* Handle to the service.
*/
struct GNUNET_RECLAIM_AttributeIterator *it_tail;
+ /**
+ * Head of active iterations
+ */
+ struct GNUNET_RECLAIM_AttestationIterator *ait_head;
+
+ /**
+ * Tail of active iterations
+ */
+ struct GNUNET_RECLAIM_AttestationIterator *ait_tail;
+
/**
* Head of active iterations
*/
}
+/**
+ * Free @a it.
+ *
+ * @param ait entry to free
+ */
+static void
+free_ait (struct GNUNET_RECLAIM_AttestationIterator *ait)
+{
+ struct GNUNET_RECLAIM_Handle *h = ait->h;
+
+ GNUNET_CONTAINER_DLL_remove (h->ait_head, h->ait_tail, ait);
+ if (NULL != ait->env)
+ GNUNET_MQ_discard (ait->env);
+ GNUNET_free (ait);
+}
+
+
/**
* Free @a op
*
struct GNUNET_RECLAIM_Handle *h = cls;
struct GNUNET_RECLAIM_Operation *op;
size_t attrs_len;
+ size_t attests_len;
uint32_t r_id = ntohl (msg->id);
+ char *read_ptr;
attrs_len = ntohs (msg->attrs_len);
+ attests_len = ntohs (msg->attestations_len);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
return;
{
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le2;
+ struct GNUNET_RECLAIM_AttributeList *attrs;
+ struct GNUNET_RECLAIM_AttributeListEntry *le;
+ struct GNUNET_RECLAIM_AttestationList *attests;
+ struct GNUNET_RECLAIM_AttestationListEntry *ale;
attrs =
- GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len);
+ GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len);
+ read_ptr = ((char *) &msg[1]) + attrs_len;
+ attests =
+ GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len);
if (NULL != op->ar_cb)
{
if (NULL == attrs)
{
- op->ar_cb (op->cls, &msg->identity, NULL, NULL, NULL);
+ op->ar_cb (op->cls, &msg->identity, NULL, NULL);
}
else
{
for (le = attrs->list_head; NULL != le; le = le->next)
{
- if ((le->reference != NULL) && (le->attest == NULL))
+ if (GNUNET_NO ==
+ GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
{
- for (le2 = attrs->list_head; NULL != le2; le2 = le2->next)
+ for (ale = attests->list_head; NULL != ale; ale = ale->next)
{
- if ((le2->attest != NULL) &&
- (0 == memcmp (&le2->attest->id,
- &le->reference->id_attest,
- sizeof (le2->attest->id))))
+ if (GNUNET_YES ==
+ GNUNET_RECLAIM_id_is_equal (&le->attribute->id,
+ &ale->attestation->id))
{
- op->ar_cb (op->cls, &msg->identity, le->claim, le2->attest,
- le->reference);
+ op->ar_cb (op->cls, &msg->identity,
+ le->attribute, ale->attestation);
break;
}
}
}
+ else // No attestations
+ {
+ op->ar_cb (op->cls, &msg->identity,
+ le->attribute, NULL);
+ }
}
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
+ GNUNET_RECLAIM_attribute_list_destroy (attrs);
+ GNUNET_RECLAIM_attestation_list_destroy (attests);
attrs = NULL;
+ attests = NULL;
}
- op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
+ op->ar_cb (op->cls, NULL, NULL, NULL);
}
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
free_op (op);
struct GNUNET_RECLAIM_AttributeIterator *it;
struct GNUNET_RECLAIM_Operation *op;
size_t attr_len;
+ size_t attest_len;
uint32_t r_id = ntohl (msg->id);
attr_len = ntohs (msg->attr_len);
+ attest_len = ntohs (msg->attestation_len);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
+ op->ar_cb (op->cls, NULL, NULL, NULL);
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
free_op (op);
}
}
{
- struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
- attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len);
+ struct GNUNET_RECLAIM_Attribute *attr;
+ struct GNUNET_RECLAIM_Attestation *attest;
+ char *read_ptr;
+ attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len);
+ read_ptr = ((char *) &msg[1]) + attr_len;
+ attest = GNUNET_RECLAIM_attestation_deserialize (read_ptr, attest_len);
if (NULL != it)
{
if (NULL != it->proc)
- it->proc (it->proc_cls, &msg->identity, attr, NULL, NULL);
+ it->proc (it->proc_cls, &msg->identity, attr, attest);
}
else if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, &msg->identity, attr, NULL, NULL);
+ op->ar_cb (op->cls, &msg->identity, attr, attest);
}
GNUNET_free (attr);
return;
/**
* Handle an incoming message of type
- * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
+ * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT
*
* @param cls
* @param msg the message we received
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
-check_attestation_result (void *cls, const struct AttributeResultMessage *msg)
+check_attestation_result (void *cls, const struct AttestationResultMessage *msg)
{
size_t msg_len;
size_t attr_len;
msg_len = ntohs (msg->header.size);
- attr_len = ntohs (msg->attr_len);
- if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
+ attr_len = ntohs (msg->attestation_len);
+ if (msg_len != sizeof(struct AttestationResultMessage) + attr_len)
{
GNUNET_break (0);
return GNUNET_SYSERR;
/**
* Handle an incoming message of type
- * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
+ * #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT
*
* @param cls
* @param msg the message we received
*/
static void
-handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
+handle_attestation_result (void *cls, const struct
+ AttestationResultMessage *msg)
{
static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
struct GNUNET_RECLAIM_Handle *h = cls;
- struct GNUNET_RECLAIM_AttributeIterator *it;
+ struct GNUNET_RECLAIM_AttestationIterator *it;
struct GNUNET_RECLAIM_Operation *op;
- size_t attr_len;
+ size_t att_len;
uint32_t r_id = ntohl (msg->id);
- attr_len = ntohs (msg->attr_len);
+ att_len = ntohs (msg->attestation_len);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n");
- for (it = h->it_head; NULL != it; it = it->next)
+ for (it = h->ait_head; NULL != it; it = it->next)
if (it->r_id == r_id)
break;
for (op = h->op_head; NULL != op; op = op->next)
{
if (NULL != it->finish_cb)
it->finish_cb (it->finish_cb_cls);
- free_it (it);
+ free_ait (it);
}
if (NULL != op)
{
- if (NULL != op->ar_cb)
- op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
+ if (NULL != op->at_cb)
+ op->at_cb (op->cls, NULL, NULL);
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
free_op (op);
}
}
{
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
- attr = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], attr_len);
+ struct GNUNET_RECLAIM_Attestation *att;
+ att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len);
if (NULL != it)
{
if (NULL != it->proc)
- it->proc (it->proc_cls, &msg->identity, NULL, attr, NULL);
+ it->proc (it->proc_cls, &msg->identity, att);
}
else if (NULL != op)
{
- if (NULL != op->ar_cb)
- op->ar_cb (op->cls, &msg->identity, NULL, attr, NULL);
+ if (NULL != op->at_cb)
+ op->at_cb (op->cls, &msg->identity, att);
}
- GNUNET_free (attr);
- return;
- }
- GNUNET_assert (0);
-}
-
-
-/**
- * Handle an incoming message of type
- * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
- *
- * @param cls
- * @param msg the message we received
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-static int
-check_reference_result (void *cls, const struct ReferenceResultMessage *msg)
-{
- size_t msg_len;
- size_t attr_len;
- size_t ref_len;
-
- msg_len = ntohs (msg->header.size);
- attr_len = ntohs (msg->attest_len);
- ref_len = ntohs (msg->ref_len);
- if (msg_len != sizeof(struct ReferenceResultMessage) + attr_len + ref_len)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
-* Handle an incoming message of type
-* #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
-*
-* @param cls
-* @param msg the message we received
-*/
-static void
-handle_reference_result (void *cls, const struct ReferenceResultMessage *msg)
-{
- static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
- struct GNUNET_RECLAIM_Handle *h = cls;
- struct GNUNET_RECLAIM_AttributeIterator *it;
- struct GNUNET_RECLAIM_Operation *op;
- size_t attest_len;
- size_t ref_len;
- uint32_t r_id = ntohl (msg->id);
- attest_len = ntohs (msg->attest_len);
- ref_len = ntohs (msg->ref_len);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
- for (it = h->it_head; NULL != it; it = it->next)
- if (it->r_id == r_id)
- break;
- for (op = h->op_head; NULL != op; op = op->next)
- if (op->r_id == r_id)
- break;
- if ((NULL == it) && (NULL == op))
- return;
-
- if ((0 ==
- (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
- {
- if ((NULL == it) && (NULL == op))
- {
- GNUNET_break (0);
- force_reconnect (h);
- return;
- }
- if (NULL != it)
- {
- if (NULL != it->finish_cb)
- it->finish_cb (it->finish_cb_cls);
- free_it (it);
- }
- if (NULL != op)
- {
- if (NULL != op->ar_cb)
- op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
- GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
- free_op (op);
- }
- return;
- }
-
- {
- struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref;
- struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
- attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1],
- attest_len);
- ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1]
- + attest_len,
- ref_len);
- if (NULL != it)
- {
- if (NULL != it->proc)
- it->proc (it->proc_cls, &msg->identity, NULL, attest, ref);
- }
- else if (NULL != op)
- {
- if (NULL != op->ar_cb)
- op->ar_cb (op->cls, &msg->identity, NULL, attest, ref);
- }
- GNUNET_free (ref);
- GNUNET_free (attest);
+ GNUNET_free (att);
return;
}
GNUNET_assert (0);
h),
GNUNET_MQ_hd_var_size (attestation_result,
GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT,
- struct AttributeResultMessage,
- h),
- GNUNET_MQ_hd_var_size (reference_result,
- GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT,
- struct ReferenceResultMessage,
+ struct AttestationResultMessage,
h),
GNUNET_MQ_hd_fixed_size (ticket_result,
GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
GNUNET_RECLAIM_attribute_store (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
+ const struct GNUNET_RECLAIM_Attribute *attr,
const struct GNUNET_TIME_Relative *exp_interval,
GNUNET_RECLAIM_ContinuationWithStatus cont,
void *cont_cls)
op->cls = cont_cls;
op->r_id = h->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr);
+ attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr);
op->env = GNUNET_MQ_msg_extra (sam,
attr_len,
GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE);
sam->id = htonl (op->r_id);
sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
- GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]);
+ GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]);
sam->attr_len = htons (attr_len);
if (NULL != h->mq)
GNUNET_RECLAIM_attribute_delete (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
+ const struct GNUNET_RECLAIM_Attribute *attr,
GNUNET_RECLAIM_ContinuationWithStatus cont,
void *cont_cls)
{
op->cls = cont_cls;
op->r_id = h->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr);
+ attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (attr);
op->env = GNUNET_MQ_msg_extra (dam,
attr_len,
GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE);
dam->identity = *pkey;
dam->id = htonl (op->r_id);
- GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]);
+ GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]);
dam->attr_len = htons (attr_len);
if (NULL != h->mq)
GNUNET_RECLAIM_attestation_store (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
+ const struct GNUNET_RECLAIM_Attestation *attr,
const struct GNUNET_TIME_Relative *exp_interval,
GNUNET_RECLAIM_ContinuationWithStatus cont,
void *cont_cls)
op->cls = cont_cls;
op->r_id = h->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attr);
+ attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr);
op->env = GNUNET_MQ_msg_extra (sam,
attr_len,
GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE);
sam->id = htonl (op->r_id);
sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
- GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &sam[1]);
+ GNUNET_RECLAIM_attestation_serialize (attr, (char *) &sam[1]);
sam->attr_len = htons (attr_len);
if (NULL != h->mq)
GNUNET_RECLAIM_attestation_delete (
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
+ const struct GNUNET_RECLAIM_Attestation *attr,
GNUNET_RECLAIM_ContinuationWithStatus cont,
void *cont_cls)
{
op->cls = cont_cls;
op->r_id = h->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (attr);
+ attr_len = GNUNET_RECLAIM_attestation_serialize_get_size (attr);
op->env = GNUNET_MQ_msg_extra (dam,
attr_len,
GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE);
dam->identity = *pkey;
dam->id = htonl (op->r_id);
- GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &dam[1]);
-
- dam->attr_len = htons (attr_len);
- if (NULL != h->mq)
- GNUNET_MQ_send_copy (h->mq, op->env);
- return op;
-}
-
-
-/**
- * Store an attestation reference. If the reference is already present,
- * it is replaced with the new reference.
- *
- * @param h handle to the re:claimID service
- * @param pkey private key of the identity
- * @param attr the reference value
- * @param exp_interval the relative expiration interval for the reference
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_RECLAIM_Operation *
-GNUNET_RECLAIM_attestation_reference_store (
- struct GNUNET_RECLAIM_Handle *h,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
- const struct GNUNET_TIME_Relative *exp_interval,
- GNUNET_RECLAIM_ContinuationWithStatus cont,
- void *cont_cls)
-{
- struct GNUNET_RECLAIM_Operation *op;
- struct AttributeStoreMessage *sam;
- size_t attr_len;
- op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
- op->h = h;
- op->as_cb = cont;
- op->cls = cont_cls;
- op->r_id = h->r_id_gen++;
- GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr);
- op->env = GNUNET_MQ_msg_extra (sam,
- attr_len,
- GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE);
- sam->identity = *pkey;
- sam->id = htonl (op->r_id);
- sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
-
- GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &sam[1]);
-
- sam->attr_len = htons (attr_len);
- if (NULL != h->mq)
- GNUNET_MQ_send_copy (h->mq, op->env);
- return op;
-}
-
-
-/**
- * Delete an attestation reference. Tickets used to share this reference are updated
- * accordingly.
- *
- * @param h handle to the re:claimID service
- * @param pkey Private key of the identity to delete the reference from
- * @param attr The reference
- * @param cont Continuation to call when done
- * @param cont_cls Closure for @a cont
- * @return handle Used to to abort the request
- */
-struct GNUNET_RECLAIM_Operation *
-GNUNET_RECLAIM_attestation_reference_delete (
- struct GNUNET_RECLAIM_Handle *h,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
- GNUNET_RECLAIM_ContinuationWithStatus cont,
- void *cont_cls)
-{
-
- struct GNUNET_RECLAIM_Operation *op;
- struct AttributeDeleteMessage *dam;
- size_t attr_len;
-
- op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
- op->h = h;
- op->as_cb = cont;
- op->cls = cont_cls;
- op->r_id = h->r_id_gen++;
- GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr);
- op->env = GNUNET_MQ_msg_extra (dam,
- attr_len,
- GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE);
- dam->identity = *pkey;
- dam->id = htonl (op->r_id);
- GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &dam[1]);
+ GNUNET_RECLAIM_attestation_serialize (attr, (char *) &dam[1]);
dam->attr_len = htons (attr_len);
if (NULL != h->mq)
struct GNUNET_RECLAIM_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ const struct GNUNET_RECLAIM_AttributeList *attrs,
GNUNET_RECLAIM_TicketCallback cb,
void *cb_cls)
{
op->cls = cb_cls;
op->r_id = h->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
+ attr_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
op->env = GNUNET_MQ_msg_extra (tim,
attr_len,
GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET);
tim->rp = *rp;
tim->id = htonl (op->r_id);
- GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]);
+ GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]);
tim->attr_len = htons (attr_len);
if (NULL != h->mq)