aboutsummaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
authorAdnan H <acednan@gmail.com>2016-12-05 22:15:25 +0100
committerAdnan H <acednan@gmail.com>2016-12-05 22:15:25 +0100
commit0f854e736bf6f2d62649fe38e25967dd71aec97f (patch)
treeeed64c57e30c0354abaa66f9fd38db643b4b287f /src/credential
parent646723dd495657a184d1f7e439f4958a72bee1df (diff)
downloadgnunet-0f854e736bf6f2d62649fe38e25967dd71aec97f.tar.gz
gnunet-0f854e736bf6f2d62649fe38e25967dd71aec97f.zip
- starting backward resolution
Diffstat (limited to 'src/credential')
-rw-r--r--src/credential/gnunet-service-credential.c99
1 files changed, 97 insertions, 2 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index aa3c02003..047ea0075 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -82,11 +82,12 @@ struct AttributeRecordEntry
82 struct AttributeRecordEntry *prev; 82 struct AttributeRecordEntry *prev;
83 83
84 /** 84 /**
85 * 85 * Payload
86 */ 86 */
87 struct GNUNET_CREDENTIAL_AttributeRecordData record_data; 87 struct GNUNET_CREDENTIAL_AttributeRecordData record_data;
88}; 88};
89 89
90
90/** 91/**
91 * Handle to a lookup operation from api 92 * Handle to a lookup operation from api
92 */ 93 */
@@ -117,6 +118,11 @@ struct VerifyRequestHandle
117 * Issuer public key 118 * Issuer public key
118 */ 119 */
119 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; 120 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
121
122 /**
123 * Issuer attribute
124 */
125 char *issuer_attribute;
120 126
121 /** 127 /**
122 * Subject public key 128 * Subject public key
@@ -142,6 +148,11 @@ struct VerifyRequestHandle
142 * Attribute Queue 148 * Attribute Queue
143 */ 149 */
144 struct AttributeRecordEntry *attr_queue_tail; 150 struct AttributeRecordEntry *attr_queue_tail;
151
152 /**
153 * Current Attribute Pointer
154 */
155 struct AttributeRecordEntry* attr_pointer;
145 156
146 /** 157 /**
147 * request id 158 * request id
@@ -245,6 +256,58 @@ check_verify (void *cls,
245 return GNUNET_OK; 256 return GNUNET_OK;
246} 257}
247 258
259static void
260start_backward_resolution (void* cls,
261 uint32_t rd_count,
262 const struct GNUNET_GNSRECORD_Data *rd)
263{
264 struct VerifyRequestHandle *vrh = cls;
265 int i;
266 struct GNUNET_CREDENTIAL_CredentialRecordData *cred;
267 struct GNUNET_CREDENTIAL_AttributeRecordData *attr;
268 struct CredentialRecordEntry *cred_pointer;
269 const char *attribute;
270 const char *cred_attribute;
271 char *issuer_key;
272 char *cred_issuer_key;
273 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key_ecdsa;
274 const struct GNUNET_CRYPTO_EcdsaPublicKey *cred_issuer_key_ecdsa;
275
276 for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL;
277 cred_pointer = cred_pointer->next){
278 cred = &cred_pointer->record_data;
279 issuer_key_ecdsa = &vrh->attr_pointer->record_data.subject_key;
280 cred_issuer_key_ecdsa = &cred_pointer->record_data.issuer_key;
281
282 issuer_key = GNUNET_CRYPTO_ecdsa_public_key_to_string(issuer_key_ecdsa);
283 cred_issuer_key = GNUNET_CRYPTO_ecdsa_public_key_to_string(cred_issuer_key_ecdsa);
284 if(0 == strcmp(issuer_key,cred_issuer_key))
285 {
286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
287 "Found issuer\n");
288 }
289
290 }
291
292
293
294 //Start from next to head
295 for(vrh->attr_pointer = vrh->attr_queue_head->next ; vrh->attr_pointer->next != NULL ;
296 vrh->attr_pointer = vrh->attr_pointer->next ){
297
298 //Start with backward resolution
299 GNUNET_GNS_lookup (gns,
300 vrh->issuer_attribute,
301 &vrh->issuer_key, //issuer_key,
302 GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
303 GNUNET_GNS_LO_DEFAULT,
304 NULL, //shorten_key, always NULL
305 &start_backward_resolution,
306 vrh);
307 }
308
309
310}
248 311
249/** 312/**
250 * Result from GNS lookup. 313 * Result from GNS lookup.
@@ -269,6 +332,16 @@ send_lookup_response (void* cls,
269 int cred_verified; 332 int cred_verified;
270 333
271 cred_record_count = 0; 334 cred_record_count = 0;
335 struct AttributeRecordEntry *attr_entry;
336
337 struct GNUNET_CREDENTIAL_AttributeRecordData *ard =
338 GNUNET_new(struct GNUNET_CREDENTIAL_AttributeRecordData);
339
340 attr_entry->record_data = *ard;
341 ard->subject_key = vrh->issuer_key;
342 GNUNET_CONTAINER_DLL_insert_tail (vrh->attr_queue_head,
343 vrh->attr_queue_tail,
344 attr_entry);
272 for (i=0; i < rd_count; i++) 345 for (i=0; i < rd_count; i++)
273 { 346 {
274 if (GNUNET_GNSRECORD_TYPE_CREDENTIAL != rd[i].record_type) 347 if (GNUNET_GNSRECORD_TYPE_CREDENTIAL != rd[i].record_type)
@@ -298,7 +371,28 @@ send_lookup_response (void* cls,
298 } 371 }
299 372
300 } 373 }
301 374
375
376 /**
377 * Check for attributes from the issuer and follow the chain
378 * till you get the required subject's attributes
379 */
380 if(cred_verified != GNUNET_YES){
381
382
383 vrh->attr_pointer = vrh->attr_queue_head;
384
385 //Start with backward resolution
386 GNUNET_GNS_lookup (gns,
387 vrh->issuer_attribute,
388 &vrh->issuer_key, //issuer_key,
389 GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
390 GNUNET_GNS_LO_DEFAULT,
391 NULL, //shorten_key, always NULL
392 &start_backward_resolution,
393 vrh);
394 }
395
302 396
303 397
304 /** 398 /**
@@ -395,6 +489,7 @@ handle_verify (void *cls,
395 vrh->request_id = v_msg->id; 489 vrh->request_id = v_msg->id;
396 vrh->issuer_key = v_msg->issuer_key; 490 vrh->issuer_key = v_msg->issuer_key;
397 vrh->subject_key = v_msg->subject_key; 491 vrh->subject_key = v_msg->subject_key;
492 vrh->issuer_attribute = issuer_attribute;
398 493
399 if (NULL == subject_attribute) 494 if (NULL == subject_attribute)
400 { 495 {