aboutsummaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
Diffstat (limited to 'src/credential')
-rw-r--r--src/credential/credential_serialization.c4
-rw-r--r--src/credential/gnunet-service-credential.c30
2 files changed, 30 insertions, 4 deletions
diff --git a/src/credential/credential_serialization.c b/src/credential/credential_serialization.c
index 76bf491c9..1fc72c203 100644
--- a/src/credential/credential_serialization.c
+++ b/src/credential/credential_serialization.c
@@ -192,7 +192,7 @@ GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
192 c_rec.signature = cd[i].signature; 192 c_rec.signature = cd[i].signature;
193 c_rec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); 193 c_rec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
194 c_rec.purpose.size = htonl ((sizeof (struct CredentialEntry) + cd[i].issuer_attribute_len) - sizeof (struct GNUNET_CRYPTO_EcdsaSignature)); 194 c_rec.purpose.size = htonl ((sizeof (struct CredentialEntry) + cd[i].issuer_attribute_len) - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
195 c_rec.expiration = htonl ((uint32_t) cd[i].expiration.abs_value_us); 195 c_rec.expiration = GNUNET_htonll (cd[i].expiration.abs_value_us);
196 if (off + sizeof (c_rec) > dest_size) 196 if (off + sizeof (c_rec) > dest_size)
197 return -1; 197 return -1;
198 GNUNET_memcpy (&dest[off], 198 GNUNET_memcpy (&dest[off],
@@ -241,7 +241,7 @@ GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
241 cd[i].issuer_key = c_rec.issuer_key; 241 cd[i].issuer_key = c_rec.issuer_key;
242 cd[i].subject_key = c_rec.subject_key; 242 cd[i].subject_key = c_rec.subject_key;
243 cd[i].signature = c_rec.signature; 243 cd[i].signature = c_rec.signature;
244 cd[i].expiration.abs_value_us = ntohl((uint32_t) c_rec.expiration); 244 cd[i].expiration.abs_value_us = GNUNET_ntohll(c_rec.expiration);
245 off += sizeof (c_rec); 245 off += sizeof (c_rec);
246 if (off + cd[i].issuer_attribute_len > len) 246 if (off + cd[i].issuer_attribute_len > len)
247 return GNUNET_SYSERR; 247 return GNUNET_SYSERR;
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index ec89da323..75ed6d5da 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -92,7 +92,11 @@ struct CredentialRecordEntry
92 * DLL 92 * DLL
93 */ 93 */
94 struct CredentialRecordEntry *prev; 94 struct CredentialRecordEntry *prev;
95 95
96 /**
97 * Number of references in delegation chains
98 */
99 uint32_t refcount;
96 100
97 /** 101 /**
98 * Payload 102 * Payload
@@ -485,6 +489,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
485 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; 489 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
486 struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size]; 490 struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size];
487 struct CredentialRecordEntry *cd; 491 struct CredentialRecordEntry *cd;
492 struct CredentialRecordEntry *tmp;
488 size_t size; 493 size_t size;
489 int i; 494 int i;
490 495
@@ -508,6 +513,26 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
508 } 513 }
509 514
510 /** 515 /**
516 * Remove all credentials not needed
517 */
518 for (cd = vrh->cred_chain_head; NULL != cd;)
519 {
520 if (cd->refcount > 0)
521 {
522 cd = cd->next;
523 continue;
524 }
525 tmp = cd;
526 cd = cd->next;
527 GNUNET_CONTAINER_DLL_remove (vrh->cred_chain_head,
528 vrh->cred_chain_tail,
529 tmp);
530 GNUNET_free (tmp->credential);
531 GNUNET_free (tmp);
532 vrh->cred_chain_size--;
533 }
534
535 /**
511 * Get serialized record data 536 * Get serialized record data
512 * Append at the end of rmsg 537 * Append at the end of rmsg
513 */ 538 */
@@ -681,7 +706,7 @@ backward_resolution (void* cls,
681 706
682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
683 "Found issuer\n"); 708 "Found issuer\n");
684 709 cred_pointer->refcount++;
685 //Backtrack 710 //Backtrack
686 for (tmp_set = ds_entry; 711 for (tmp_set = ds_entry;
687 NULL != tmp_set->parent_queue_entry; 712 NULL != tmp_set->parent_queue_entry;
@@ -796,6 +821,7 @@ delegation_chain_resolution_start (void* cls)
796 continue; 821 continue;
797 if (0 != strcmp (cr_entry->credential->issuer_attribute, vrh->issuer_attribute)) 822 if (0 != strcmp (cr_entry->credential->issuer_attribute, vrh->issuer_attribute))
798 continue; 823 continue;
824 cr_entry->refcount++;
799 //Found match prematurely 825 //Found match prematurely
800 send_lookup_response (vrh); 826 send_lookup_response (vrh);
801 return; 827 return;