aboutsummaryrefslogtreecommitdiff
path: root/src/credential/gnunet-service-credential.c
diff options
context:
space:
mode:
authorAdnan H <acednan@gmail.com>2016-12-05 22:17:37 +0100
committerAdnan H <acednan@gmail.com>2016-12-05 22:17:37 +0100
commit38153c76241311666e9aa26f2cec534f62900c72 (patch)
treecdadc6bf060ee284cdac5e1ed2c1743cbffb4ea8 /src/credential/gnunet-service-credential.c
parent0f854e736bf6f2d62649fe38e25967dd71aec97f (diff)
parent01fcfd11a5e4c170e0b31c60157fb9748c0d3277 (diff)
downloadgnunet-38153c76241311666e9aa26f2cec534f62900c72.tar.gz
gnunet-38153c76241311666e9aa26f2cec534f62900c72.zip
Merge branch 'credentials' of git+ssh://gnunet.org/gnunet into credentials
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r--src/credential/gnunet-service-credential.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 047ea0075..792d8741e 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -228,9 +228,7 @@ check_verify (void *cls,
228 const struct VerifyMessage *v_msg) 228 const struct VerifyMessage *v_msg)
229{ 229{
230 size_t msg_size; 230 size_t msg_size;
231 size_t attr_len; 231 const char* attrs;
232 const char* s_attr;
233 const char* i_attr;
234 232
235 msg_size = ntohs (v_msg->header.size); 233 msg_size = ntohs (v_msg->header.size);
236 if (msg_size < sizeof (struct VerifyMessage)) 234 if (msg_size < sizeof (struct VerifyMessage))
@@ -238,17 +236,16 @@ check_verify (void *cls,
238 GNUNET_break (0); 236 GNUNET_break (0);
239 return GNUNET_SYSERR; 237 return GNUNET_SYSERR;
240 } 238 }
241 i_attr = (const char *) &v_msg[1]; 239 if ((ntohs (v_msg->issuer_attribute_len) > GNUNET_CREDENTIAL_MAX_LENGTH) ||
242 if ( ('\0' != i_attr[v_msg->header.size - sizeof (struct VerifyMessage) - 1]) || 240 (ntohs (v_msg->subject_attribute_len) > GNUNET_CREDENTIAL_MAX_LENGTH))
243 (strlen (i_attr) > GNUNET_CREDENTIAL_MAX_LENGTH) )
244 { 241 {
245 GNUNET_break (0); 242 GNUNET_break (0);
246 return GNUNET_SYSERR; 243 return GNUNET_SYSERR;
247 } 244 }
248 attr_len = strlen (i_attr); 245 attrs = (const char *) &v_msg[1];
249 s_attr = ((const char *) &v_msg[1]) + attr_len + 1; 246
250 if ( ('\0' != s_attr[v_msg->header.size - sizeof (struct VerifyMessage) - 1]) || 247 if ( ('\0' != attrs[ntohs(v_msg->header.size) - sizeof (struct VerifyMessage) - 1]) ||
251 (strlen (s_attr) > GNUNET_CREDENTIAL_MAX_LENGTH) ) 248 (strlen (attrs) > GNUNET_CREDENTIAL_MAX_LENGTH * 2) )
252 { 249 {
253 GNUNET_break (0); 250 GNUNET_break (0);
254 return GNUNET_SYSERR; 251 return GNUNET_SYSERR;
@@ -328,8 +325,8 @@ send_lookup_response (void* cls,
328 struct GNUNET_MQ_Envelope *env; 325 struct GNUNET_MQ_Envelope *env;
329 struct VerifyResultMessage *rmsg; 326 struct VerifyResultMessage *rmsg;
330 const struct GNUNET_CREDENTIAL_CredentialRecordData *crd; 327 const struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
328 struct GNUNET_CRYPTO_EccSignaturePurpose *purp;
331 struct CredentialRecordEntry *cr_entry; 329 struct CredentialRecordEntry *cr_entry;
332 int cred_verified;
333 330
334 cred_record_count = 0; 331 cred_record_count = 0;
335 struct AttributeRecordEntry *attr_entry; 332 struct AttributeRecordEntry *attr_entry;
@@ -361,14 +358,23 @@ send_lookup_response (void* cls,
361 GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head, 358 GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
362 vrh->cred_chain_tail, 359 vrh->cred_chain_tail,
363 cr_entry); 360 cr_entry);
364 361 purp = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
362 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
363 strlen ((char*)&crd[1]) +1 );
364 purp->size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
365 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
366 strlen ((char*)&crd[1]) +1 );
367
368 purp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
365 if(GNUNET_OK == GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL, 369 if(GNUNET_OK == GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL,
366 &crd->purpose, 370 purp,
367 &crd->sig, &crd->issuer_key)) 371 &crd->sig,
368 { 372 &crd->issuer_key))
369 cred_verified = GNUNET_YES; 373 {
374 GNUNET_free (purp);
370 break; 375 break;
371 } 376 }
377 GNUNET_free (purp);
372 378
373 } 379 }
374 380
@@ -394,7 +400,6 @@ send_lookup_response (void* cls,
394 } 400 }
395 401
396 402
397
398 /** 403 /**
399 * TODO 404 * TODO
400 * Start resolution of Attribute delegations from issuer 405 * Start resolution of Attribute delegations from issuer
@@ -466,12 +471,12 @@ static void
466handle_verify (void *cls, 471handle_verify (void *cls,
467 const struct VerifyMessage *v_msg) 472 const struct VerifyMessage *v_msg)
468{ 473{
474 char attrs[GNUNET_CREDENTIAL_MAX_LENGTH*2 + 1];
469 char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; 475 char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
470 char subject_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; 476 char subject_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
471 size_t issuer_attribute_len;
472 struct VerifyRequestHandle *vrh; 477 struct VerifyRequestHandle *vrh;
473 struct GNUNET_SERVICE_Client *client = cls; 478 struct GNUNET_SERVICE_Client *client = cls;
474 char *attrptr = issuer_attribute; 479 char *attrptr = attrs;
475 const char *utf_in; 480 const char *utf_in;
476 481
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -479,10 +484,11 @@ handle_verify (void *cls,
479 484
480 utf_in = (const char *) &v_msg[1]; 485 utf_in = (const char *) &v_msg[1];
481 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); 486 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
482 issuer_attribute_len = strlen (utf_in); 487
483 utf_in = (const char *) (&v_msg[1] + issuer_attribute_len + 1); 488 GNUNET_memcpy (issuer_attribute, attrs, ntohs (v_msg->issuer_attribute_len));
484 attrptr = subject_attribute; 489 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
485 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); 490 GNUNET_memcpy (subject_attribute, attrs+strlen(issuer_attribute), ntohs (v_msg->subject_attribute_len));
491 subject_attribute[ntohs (v_msg->subject_attribute_len)] = '\0';
486 vrh = GNUNET_new (struct VerifyRequestHandle); 492 vrh = GNUNET_new (struct VerifyRequestHandle);
487 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); 493 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
488 vrh->client = client; 494 vrh->client = client;