aboutsummaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
authorAdnan H <acednan@gmail.com>2016-12-02 15:38:10 +0100
committerAdnan H <acednan@gmail.com>2016-12-02 15:38:10 +0100
commit6fb6ddb3cb9b4153033747ac42cbad66f9bc3268 (patch)
treefbdb8bc0b7238766cd98bb40d9acc7f87271f719 /src/credential
parent299525b4df387bd197b0ded1fb51e74f6d12cd86 (diff)
downloadgnunet-6fb6ddb3cb9b4153033747ac42cbad66f9bc3268.tar.gz
gnunet-6fb6ddb3cb9b4153033747ac42cbad66f9bc3268.zip
- added DLL and some checks
Diffstat (limited to 'src/credential')
-rw-r--r--src/credential/gnunet-service-credential.c108
1 files changed, 81 insertions, 27 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 58be7853b..620256cd9 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -45,26 +45,48 @@
45/** 45/**
46 * DLL for record 46 * DLL for record
47 */ 47 */
48struct AttributeRecordEntry 48struct CredentialRecordEntry
49{ 49{
50 /** 50 /**
51 * DLL 51 * DLL
52 */ 52 */
53 struct AttributeRecordEntry *next; 53 struct CredentialRecordEntry *next;
54 54
55 /** 55 /**
56 * DLL 56 * DLL
57 */ 57 */
58 struct AttributeRecordEntry *prev; 58 struct CredentialRecordEntry *prev;
59 59
60 60
61 /** 61 /**
62 * Payload 62 * Payload
63 */ 63 */
64 struct GNUNET_CREDENTIAL_AttributeRecordData record_data; 64 struct GNUNET_CREDENTIAL_CredentialRecordData record_data;
65}; 65};
66 66
67/** 67/**
68 * DLL for attributes - Used as a queue
69 * Insert tail - Pop head
70 */
71struct AttributeRecordEntry
72{
73 /**
74 * DLL
75 */
76 struct AttributeRecordEntry *next;
77
78 /**
79 * DLL
80 */
81 struct AttributeRecordEntry *prev;
82
83 /**
84 *
85 */
86 struct GNUNET_CREDENTIAL_AttributeDelegationRecordData;
87}
88
89/**
68 * Handle to a lookup operation from api 90 * Handle to a lookup operation from api
69 */ 91 */
70struct VerifyRequestHandle 92struct VerifyRequestHandle
@@ -101,14 +123,24 @@ struct VerifyRequestHandle
101 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; 123 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
102 124
103 /** 125 /**
104 * Attribute Chain 126 * Credential Chain
105 */ 127 */
106 struct AttributeRecordEntry *attr_chain_head; 128 struct CredentialRecordEntry *cred_chain_head;
107 129
108 /** 130 /**
109 * Attribute Chain 131 * Credential Chain
132 */
133 struct CredentialRecordEntry *cred_chain_tail;
134
135 /**
136 * Attribute Queue
137 */
138 struct AttributeRecordEntry *attr_queue_head;
139
140 /**
141 * Attribute Queue
110 */ 142 */
111 struct AttributeRecordEntry *attr_chain_tail; 143 struct AttributeRecordEntry *attr_queue_tail;
112 144
113 /** 145 /**
114 * request id 146 * request id
@@ -228,19 +260,26 @@ send_lookup_response (void* cls,
228 struct VerifyRequestHandle *vrh = cls; 260 struct VerifyRequestHandle *vrh = cls;
229 size_t len; 261 size_t len;
230 int i; 262 int i;
231 int attr_record_count; 263 int cred_record_count;
232 struct GNUNET_MQ_Envelope *env; 264 struct GNUNET_MQ_Envelope *env;
233 struct VerifyResultMessage *rmsg; 265 struct VerifyResultMessage *rmsg;
234 const struct GNUNET_CREDENTIAL_AttributeRecordData *ard; 266 const struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
235 struct AttributeRecordEntry *ar_entry; 267 struct GNUNET_CREDENTIAL_AttributeDelegationRecordData *adrd;
236 268 struct CredentialRecordEntry *cr_entry;
237 attr_record_count = 0; 269 struct AttributeRecordEntry *attr_entry;
270 bool cred_verified;
271
272 cred_record_count = 0;
273 adrd = GNUNET_CREDENTIAL_AttributeDelegationRecordData
274 GNUNET_CONTAINER_DLL_insert_tail (vrh->attr_queue_head,
275 vrh->attr_queue_tail,
276 attr_entry);
238 for (i=0; i < rd_count; i++) 277 for (i=0; i < rd_count; i++)
239 { 278 {
240 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type) 279 if (GNUNET_GNSRECORD_TYPE_CREDENTIAL != rd[i].record_type)
241 continue; 280 continue;
242 attr_record_count++; 281 cred_record_count++;
243 ard = rd[i].data; 282 crd = rd[i].data;
244 /** 283 /**
245 * TODO: 284 * TODO:
246 * Check if we have already found our credential here 285 * Check if we have already found our credential here
@@ -249,18 +288,33 @@ send_lookup_response (void* cls,
249 * Save all found attributes/issues and prepare forward 288 * Save all found attributes/issues and prepare forward
250 * resolution of issuer attribute 289 * resolution of issuer attribute
251 */ 290 */
252 ar_entry = GNUNET_new (struct AttributeRecordEntry); 291 cr_entry = GNUNET_new (struct CredentialRecordEntry);
253 ar_entry->record_data = *ard; 292 cr_entry->record_data = *crd;
254 GNUNET_CONTAINER_DLL_insert_tail (vrh->attr_chain_head, 293 GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
255 vrh->attr_chain_tail, 294 vrh->cred_chain_tail,
256 ar_entry); 295 cr_entry);
296
297 if(GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL, purpose, sig, issuer_key))
298 {
299 cred_verified = true;
300 break;
301 }
257 302
258 } 303 }
304
305
306 /**
307 * Check for attributes from the issuer and follow the chain
308 * till you get the required subject's attributes
309 */
310 if(cred_verified != true){
311 for(i=0 ; i < rd_count ; i++){
312
259 313
260 /** 314 /**
261 * Get serialized record data size 315 * Get serialized record data size
262 */ 316 */
263 len = attr_record_count * sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData); 317 len = cred_record_count * sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData);
264 318
265 /** 319 /**
266 * Prepare a lookup result response message for the client 320 * Prepare a lookup result response message for the client
@@ -277,12 +331,12 @@ send_lookup_response (void* cls,
277 * Append at the end of rmsg 331 * Append at the end of rmsg
278 */ 332 */
279 i = 0; 333 i = 0;
280 struct GNUNET_CREDENTIAL_AttributeRecordData *tmp_record = (struct GNUNET_CREDENTIAL_AttributeRecordData*) &rmsg[1]; 334 struct GNUNET_CREDENTIAL_CredentialRecordData *tmp_record = (struct GNUNET_CREDENTIAL_CredentialRecordData*) &rmsg[1];
281 for (ar_entry = vrh->attr_chain_head; NULL != ar_entry; ar_entry = ar_entry->next) 335 for (ar_entry = vrh->attr_chain_head; NULL != ar_entry; ar_entry = ar_entry->next)
282 { 336 {
283 memcpy (tmp_record, 337 memcpy (tmp_record,
284 &ar_entry->record_data, 338 &ar_entry->record_data,
285 sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData)); 339 sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData));
286 tmp_record++; 340 tmp_record++;
287 } 341 }
288 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client), 342 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client),
@@ -301,13 +355,13 @@ send_lookup_response (void* cls,
301 "Completed verifications", 1, 355 "Completed verifications", 1,
302 GNUNET_NO); 356 GNUNET_NO);
303 GNUNET_STATISTICS_update (statistics, 357 GNUNET_STATISTICS_update (statistics,
304 "Attributes resolved", 358 "Credentials resolved",
305 rd_count, 359 rd_count,
306 GNUNET_NO); 360 GNUNET_NO);
307} 361}
308 362
309/** 363/**
310 * Handle attribute verification requests from client 364 * Handle Credential verification requests from client
311 * 365 *
312 * @param cls the closure 366 * @param cls the closure
313 * @param client the client 367 * @param client the client
@@ -361,7 +415,7 @@ handle_verify (void *cls,
361 vrh->lookup_request = GNUNET_GNS_lookup (gns, 415 vrh->lookup_request = GNUNET_GNS_lookup (gns,
362 subject_attribute, 416 subject_attribute,
363 &v_msg->subject_key, //subject_pkey, 417 &v_msg->subject_key, //subject_pkey,
364 GNUNET_GNSRECORD_TYPE_ATTRIBUTE, 418 GNUNET_GNSRECORD_TYPE_CREDENTIAL,
365 GNUNET_GNS_LO_DEFAULT, 419 GNUNET_GNS_LO_DEFAULT,
366 NULL, //shorten_key, always NULL 420 NULL, //shorten_key, always NULL
367 &send_lookup_response, 421 &send_lookup_response,