From 01fcfd11a5e4c170e0b31c60157fb9748c0d3277 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Mon, 5 Dec 2016 22:09:11 +0100 Subject: [PATCH] - remove purpose from cred --- src/credential/credential_api.c | 21 +++++++++++++++------ src/credential/gnunet-service-credential.c | 21 ++++++++++++++++----- src/include/gnunet_credential_service.h | 5 ----- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index b6c585c72..3be2d8bbb 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c @@ -428,23 +428,32 @@ GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle, const char *attribute) { struct GNUNET_CREDENTIAL_CredentialRecordData *crd; + struct GNUNET_CRYPTO_EccSignaturePurpose *purp; crd = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (attribute) + 1); - crd->purpose.size = htonl (strlen (attribute) + 1 + - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + - sizeof (struct GNUNET_TIME_AbsoluteNBO)); - crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); + purp = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + + strlen (attribute) + 1); + purp->size = htonl (strlen (attribute) + 1 + + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + + sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); + + purp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); GNUNET_CRYPTO_ecdsa_key_get_public (issuer, &crd->issuer_key); crd->subject_key = *subject; GNUNET_memcpy (&crd[1], attribute, strlen (attribute)); + GNUNET_memcpy (&purp[1], + subject, + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); + GNUNET_memcpy (&purp[1] + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), + attribute, + strlen (attribute)); if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (issuer, - &crd->purpose, + purp, &crd->sig)) { GNUNET_break (0); diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index 117156379..20f6fe4e0 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c @@ -262,6 +262,7 @@ send_lookup_response (void* cls, struct GNUNET_MQ_Envelope *env; struct VerifyResultMessage *rmsg; const struct GNUNET_CREDENTIAL_CredentialRecordData *crd; + struct GNUNET_CRYPTO_EccSignaturePurpose *purp; struct CredentialRecordEntry *cr_entry; cred_record_count = 0; @@ -284,16 +285,26 @@ send_lookup_response (void* cls, GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head, vrh->cred_chain_tail, cr_entry); - + purp = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + + strlen ((char*)&crd[1]) +1 ); + purp->size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + + strlen ((char*)&crd[1]) +1 ); + + purp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); if(GNUNET_OK == GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL, - &crd->purpose, - &crd->sig, &crd->issuer_key)) - { + purp, + &crd->sig, + &crd->issuer_key)) + { + GNUNET_free (purp); break; } + GNUNET_free (purp); } - + /** diff --git a/src/include/gnunet_credential_service.h b/src/include/gnunet_credential_service.h index 088d0c75e..151587768 100644 --- a/src/include/gnunet_credential_service.h +++ b/src/include/gnunet_credential_service.h @@ -89,11 +89,6 @@ struct GNUNET_CREDENTIAL_CredentialRecordData { */ 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 */ -- 2.25.1