diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-05 22:19:14 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-05 22:19:14 +0100 |
commit | 8c1425aa729914e0b2695fcab1ce29ea0aebffbb (patch) | |
tree | f565f058b35243cfece8ca16ce046af6aacf0f00 /src/credential | |
parent | a97e16efa84b72dd51dcb181d4ebdbcc58a111f9 (diff) | |
parent | 38153c76241311666e9aa26f2cec534f62900c72 (diff) | |
download | gnunet-8c1425aa729914e0b2695fcab1ce29ea0aebffbb.tar.gz gnunet-8c1425aa729914e0b2695fcab1ce29ea0aebffbb.zip |
Merge branch 'credentials' of git+ssh://gnunet.org/gnunet into credentials
Diffstat (limited to 'src/credential')
-rw-r--r-- | src/credential/gnunet-service-credential.c | 96 |
1 files changed, 95 insertions, 1 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index 20f6fe4e0..792d8741e 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 |
@@ -242,6 +253,58 @@ check_verify (void *cls, | |||
242 | return GNUNET_OK; | 253 | return GNUNET_OK; |
243 | } | 254 | } |
244 | 255 | ||
256 | static void | ||
257 | start_backward_resolution (void* cls, | ||
258 | uint32_t rd_count, | ||
259 | const struct GNUNET_GNSRECORD_Data *rd) | ||
260 | { | ||
261 | struct VerifyRequestHandle *vrh = cls; | ||
262 | int i; | ||
263 | struct GNUNET_CREDENTIAL_CredentialRecordData *cred; | ||
264 | struct GNUNET_CREDENTIAL_AttributeRecordData *attr; | ||
265 | struct CredentialRecordEntry *cred_pointer; | ||
266 | const char *attribute; | ||
267 | const char *cred_attribute; | ||
268 | char *issuer_key; | ||
269 | char *cred_issuer_key; | ||
270 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key_ecdsa; | ||
271 | const struct GNUNET_CRYPTO_EcdsaPublicKey *cred_issuer_key_ecdsa; | ||
272 | |||
273 | for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL; | ||
274 | cred_pointer = cred_pointer->next){ | ||
275 | cred = &cred_pointer->record_data; | ||
276 | issuer_key_ecdsa = &vrh->attr_pointer->record_data.subject_key; | ||
277 | cred_issuer_key_ecdsa = &cred_pointer->record_data.issuer_key; | ||
278 | |||
279 | issuer_key = GNUNET_CRYPTO_ecdsa_public_key_to_string(issuer_key_ecdsa); | ||
280 | cred_issuer_key = GNUNET_CRYPTO_ecdsa_public_key_to_string(cred_issuer_key_ecdsa); | ||
281 | if(0 == strcmp(issuer_key,cred_issuer_key)) | ||
282 | { | ||
283 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
284 | "Found issuer\n"); | ||
285 | } | ||
286 | |||
287 | } | ||
288 | |||
289 | |||
290 | |||
291 | //Start from next to head | ||
292 | for(vrh->attr_pointer = vrh->attr_queue_head->next ; vrh->attr_pointer->next != NULL ; | ||
293 | vrh->attr_pointer = vrh->attr_pointer->next ){ | ||
294 | |||
295 | //Start with backward resolution | ||
296 | GNUNET_GNS_lookup (gns, | ||
297 | vrh->issuer_attribute, | ||
298 | &vrh->issuer_key, //issuer_key, | ||
299 | GNUNET_GNSRECORD_TYPE_ATTRIBUTE, | ||
300 | GNUNET_GNS_LO_DEFAULT, | ||
301 | NULL, //shorten_key, always NULL | ||
302 | &start_backward_resolution, | ||
303 | vrh); | ||
304 | } | ||
305 | |||
306 | |||
307 | } | ||
245 | 308 | ||
246 | /** | 309 | /** |
247 | * Result from GNS lookup. | 310 | * Result from GNS lookup. |
@@ -266,6 +329,16 @@ send_lookup_response (void* cls, | |||
266 | struct CredentialRecordEntry *cr_entry; | 329 | struct CredentialRecordEntry *cr_entry; |
267 | 330 | ||
268 | cred_record_count = 0; | 331 | cred_record_count = 0; |
332 | struct AttributeRecordEntry *attr_entry; | ||
333 | |||
334 | struct GNUNET_CREDENTIAL_AttributeRecordData *ard = | ||
335 | GNUNET_new(struct GNUNET_CREDENTIAL_AttributeRecordData); | ||
336 | |||
337 | attr_entry->record_data = *ard; | ||
338 | ard->subject_key = vrh->issuer_key; | ||
339 | GNUNET_CONTAINER_DLL_insert_tail (vrh->attr_queue_head, | ||
340 | vrh->attr_queue_tail, | ||
341 | attr_entry); | ||
269 | for (i=0; i < rd_count; i++) | 342 | for (i=0; i < rd_count; i++) |
270 | { | 343 | { |
271 | if (GNUNET_GNSRECORD_TYPE_CREDENTIAL != rd[i].record_type) | 344 | if (GNUNET_GNSRECORD_TYPE_CREDENTIAL != rd[i].record_type) |
@@ -306,6 +379,26 @@ send_lookup_response (void* cls, | |||
306 | } | 379 | } |
307 | 380 | ||
308 | 381 | ||
382 | /** | ||
383 | * Check for attributes from the issuer and follow the chain | ||
384 | * till you get the required subject's attributes | ||
385 | */ | ||
386 | if(cred_verified != GNUNET_YES){ | ||
387 | |||
388 | |||
389 | vrh->attr_pointer = vrh->attr_queue_head; | ||
390 | |||
391 | //Start with backward resolution | ||
392 | GNUNET_GNS_lookup (gns, | ||
393 | vrh->issuer_attribute, | ||
394 | &vrh->issuer_key, //issuer_key, | ||
395 | GNUNET_GNSRECORD_TYPE_ATTRIBUTE, | ||
396 | GNUNET_GNS_LO_DEFAULT, | ||
397 | NULL, //shorten_key, always NULL | ||
398 | &start_backward_resolution, | ||
399 | vrh); | ||
400 | } | ||
401 | |||
309 | 402 | ||
310 | /** | 403 | /** |
311 | * TODO | 404 | * TODO |
@@ -402,6 +495,7 @@ handle_verify (void *cls, | |||
402 | vrh->request_id = v_msg->id; | 495 | vrh->request_id = v_msg->id; |
403 | vrh->issuer_key = v_msg->issuer_key; | 496 | vrh->issuer_key = v_msg->issuer_key; |
404 | vrh->subject_key = v_msg->subject_key; | 497 | vrh->subject_key = v_msg->subject_key; |
498 | vrh->issuer_attribute = issuer_attribute; | ||
405 | 499 | ||
406 | if (NULL == subject_attribute) | 500 | if (NULL == subject_attribute) |
407 | { | 501 | { |