From: Schanzenbach, Martin Date: Fri, 2 Dec 2016 13:20:08 +0000 (+0100) Subject: - add signatures to creds, add converter X-Git-Tag: gnunet-0.11.0rc0~24^2~138 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=113150fb91211dc0cc0901c2373f148b8486d9c9;p=oweals%2Fgnunet.git - add signatures to creds, add converter --- diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c index 480dc4c62..d321a43a4 100644 --- a/src/credential/plugin_gnsrecord_credential.c +++ b/src/credential/plugin_gnsrecord_credential.c @@ -51,6 +51,26 @@ credential_value_to_string (void *cls, switch (type) { + case GNUNET_GNSRECORD_TYPE_ATTRIBUTE: + { + struct GNUNET_CREDENTIAL_AttributeRecordData attr; + char *attr_str; + char *subject_pkey; + + if (data_size < sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData)) + return NULL; /* malformed */ + memcpy (&attr, + data, + sizeof (attr)); + cdata = data; + subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&attr.subject_key); + GNUNET_asprintf (&attr_str, + "%s.%s", + subject_pkey, + &cdata[sizeof (attr)]); + GNUNET_free (subject_pkey); + return attr_str; + } case GNUNET_GNSRECORD_TYPE_CREDENTIAL: { struct GNUNET_CREDENTIAL_CredentialRecordData cred; diff --git a/src/include/gnunet_credential_service.h b/src/include/gnunet_credential_service.h index 5675cd990..b996b77db 100644 --- a/src/include/gnunet_credential_service.h +++ b/src/include/gnunet_credential_service.h @@ -79,16 +79,27 @@ GNUNET_NETWORK_STRUCT_BEGIN struct GNUNET_CREDENTIAL_CredentialRecordData { /** - * Public key of the subject this credential was issued to + * The signature for this credential by the issuer */ - struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; + struct GNUNET_CRYPTO_EcdsaSignature sig; + /** * Public key of the issuer */ struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; + + /** + * Signature purpose (data to sign, kind of signature) + */ + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** + * Public key of the subject this credential was issued to + */ + struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; + + /** * Flags for this credential */ uint32_t credential_flags GNUNET_PACKED; @@ -98,12 +109,7 @@ struct GNUNET_CREDENTIAL_CredentialRecordData { */ uint64_t expiration GNUNET_PACKED; - /** - * The signature for this credential by the issuer - */ - struct GNUNET_CRYPTO_EcdsaSignature sig; - - /** + /** * Followed by the attribute string */ }; diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index 1e372bbea..353287cbf 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h @@ -190,6 +190,11 @@ extern "C" */ #define GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET 27 +/** + * Signature for a GNUnet credential + */ +#define GNUNET_SIGNATURE_PURPOSE_CREDENTIAL 28 + #if 0 /* keep Emacsens' auto-indent happy */ { #endif