diff options
-rw-r--r-- | src/credential/credential.h | 6 | ||||
-rw-r--r-- | src/credential/credential_api.c | 37 | ||||
-rw-r--r-- | src/credential/credential_serialization.c | 12 | ||||
-rw-r--r-- | src/credential/credential_serialization.h | 6 | ||||
-rw-r--r-- | src/credential/gnunet-credential.c | 20 | ||||
-rw-r--r-- | src/credential/gnunet-service-credential.c | 217 | ||||
-rw-r--r-- | src/credential/plugin_gnsrecord_credential.c | 4 | ||||
-rwxr-xr-x | src/credential/test_credential_own.sh | 58 |
8 files changed, 134 insertions, 226 deletions
diff --git a/src/credential/credential.h b/src/credential/credential.h index 97fdfecbf..ca8fb78d7 100644 --- a/src/credential/credential.h +++ b/src/credential/credential.h | |||
@@ -91,9 +91,9 @@ struct VerifyMessage | |||
91 | struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; | 91 | struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Number of credentials | 94 | * Number of delegates |
95 | */ | 95 | */ |
96 | uint32_t c_count; | 96 | uint32_t d_count; |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Length of the issuer attribute | 99 | * Length of the issuer attribute |
@@ -132,7 +132,7 @@ struct DelegationChainResultMessage | |||
132 | /** | 132 | /** |
133 | * Indicates if credential has been found at all | 133 | * Indicates if credential has been found at all |
134 | */ | 134 | */ |
135 | uint32_t cred_found GNUNET_PACKED; | 135 | uint32_t del_found GNUNET_PACKED; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * The number of delegations in the response | 138 | * The number of delegations in the response |
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index 7323d3b1c..4fe32465a 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c | |||
@@ -217,8 +217,7 @@ handle_result (void *cls, | |||
217 | uint32_t d_count = ntohl (vr_msg->d_count); | 217 | uint32_t d_count = ntohl (vr_msg->d_count); |
218 | uint32_t c_count = ntohl (vr_msg->c_count); | 218 | uint32_t c_count = ntohl (vr_msg->c_count); |
219 | struct GNUNET_CREDENTIAL_Delegation d_chain[d_count]; | 219 | struct GNUNET_CREDENTIAL_Delegation d_chain[d_count]; |
220 | //TODO rename creds | 220 | struct GNUNET_CREDENTIAL_Delegate dels[c_count]; |
221 | struct GNUNET_CREDENTIAL_Delegate creds[c_count]; | ||
222 | GNUNET_CREDENTIAL_CredentialResultProcessor proc; | 221 | GNUNET_CREDENTIAL_CredentialResultProcessor proc; |
223 | void *proc_cls; | 222 | void *proc_cls; |
224 | 223 | ||
@@ -242,8 +241,8 @@ handle_result (void *cls, | |||
242 | d_count, | 241 | d_count, |
243 | d_chain, | 242 | d_chain, |
244 | c_count, | 243 | c_count, |
245 | creds)); | 244 | dels)); |
246 | if (GNUNET_NO == ntohl (vr_msg->cred_found)) | 245 | if (GNUNET_NO == ntohl (vr_msg->del_found)) |
247 | { | 246 | { |
248 | proc (proc_cls, | 247 | proc (proc_cls, |
249 | 0, | 248 | 0, |
@@ -255,7 +254,7 @@ handle_result (void *cls, | |||
255 | d_count, | 254 | d_count, |
256 | d_chain, | 255 | d_chain, |
257 | c_count, | 256 | c_count, |
258 | creds); | 257 | dels); |
259 | } | 258 | } |
260 | } | 259 | } |
261 | 260 | ||
@@ -415,8 +414,8 @@ GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle, | |||
415 | c_msg->subject_key = *subject_key; | 414 | c_msg->subject_key = *subject_key; |
416 | c_msg->issuer_key = *issuer_key; | 415 | c_msg->issuer_key = *issuer_key; |
417 | c_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); | 416 | c_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); |
418 | //c_msg->resolution_algo = htons(Backward); | 417 | c_msg->resolution_algo = htons(Backward); |
419 | c_msg->resolution_algo = htons(Forward); | 418 | //c_msg->resolution_algo = htons(Forward); |
420 | 419 | ||
421 | GNUNET_memcpy (&c_msg[1], | 420 | GNUNET_memcpy (&c_msg[1], |
422 | issuer_attribute, | 421 | issuer_attribute, |
@@ -441,8 +440,8 @@ GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle, | |||
441 | * @param issuer_key the issuer public key | 440 | * @param issuer_key the issuer public key |
442 | * @param issuer_attribute the issuer attribute | 441 | * @param issuer_attribute the issuer attribute |
443 | * @param subject_key the subject public key | 442 | * @param subject_key the subject public key |
444 | * @param credential_count number of credentials provided | 443 | * @param delegate_count number of delegates provided |
445 | * @param credentials subject credentials | 444 | * @param delegates subject delegates |
446 | * @param proc function to call on result | 445 | * @param proc function to call on result |
447 | * @param proc_cls closure for processor | 446 | * @param proc_cls closure for processor |
448 | * @return handle to the queued request | 447 | * @return handle to the queued request |
@@ -452,8 +451,8 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, | |||
452 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, | 451 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, |
453 | const char *issuer_attribute, | 452 | const char *issuer_attribute, |
454 | const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, | 453 | const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, |
455 | uint32_t credential_count, | 454 | uint32_t delegate_count, |
456 | const struct GNUNET_CREDENTIAL_Delegate *credentials, | 455 | const struct GNUNET_CREDENTIAL_Delegate *delegates, |
457 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, | 456 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, |
458 | void *proc_cls) | 457 | void *proc_cls) |
459 | { | 458 | { |
@@ -463,14 +462,14 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, | |||
463 | size_t nlen; | 462 | size_t nlen; |
464 | size_t clen; | 463 | size_t clen; |
465 | 464 | ||
466 | if (NULL == issuer_attribute || NULL == credentials) | 465 | if (NULL == issuer_attribute || NULL == delegates) |
467 | { | 466 | { |
468 | GNUNET_break (0); | 467 | GNUNET_break (0); |
469 | return NULL; | 468 | return NULL; |
470 | } | 469 | } |
471 | 470 | ||
472 | clen = GNUNET_CREDENTIAL_credentials_get_size (credential_count, | 471 | clen = GNUNET_CREDENTIAL_delegates_get_size (delegate_count, |
473 | credentials); | 472 | delegates); |
474 | 473 | ||
475 | //DEBUG LOG | 474 | //DEBUG LOG |
476 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 475 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -492,17 +491,17 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, | |||
492 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); | 491 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); |
493 | v_msg->id = htonl (vr->r_id); | 492 | v_msg->id = htonl (vr->r_id); |
494 | v_msg->subject_key = *subject_key; | 493 | v_msg->subject_key = *subject_key; |
495 | v_msg->c_count = htonl(credential_count); | 494 | v_msg->d_count = htonl(delegate_count); |
496 | v_msg->issuer_key = *issuer_key; | 495 | v_msg->issuer_key = *issuer_key; |
497 | v_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); | 496 | v_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); |
498 | //v_msg->resolution_algo = htons(Backward); | 497 | v_msg->resolution_algo = htons(Backward); |
499 | v_msg->resolution_algo = htons(Forward); | 498 | //v_msg->resolution_algo = htons(Forward); |
500 | 499 | ||
501 | GNUNET_memcpy (&v_msg[1], | 500 | GNUNET_memcpy (&v_msg[1], |
502 | issuer_attribute, | 501 | issuer_attribute, |
503 | strlen (issuer_attribute)); | 502 | strlen (issuer_attribute)); |
504 | GNUNET_CREDENTIAL_credentials_serialize (credential_count, | 503 | GNUNET_CREDENTIAL_delegates_serialize (delegate_count, |
505 | credentials, | 504 | delegates, |
506 | clen, | 505 | clen, |
507 | ((char*)&v_msg[1]) | 506 | ((char*)&v_msg[1]) |
508 | + strlen (issuer_attribute) + 1); | 507 | + strlen (issuer_attribute) + 1); |
diff --git a/src/credential/credential_serialization.c b/src/credential/credential_serialization.c index 4f3b11450..65a85e37e 100644 --- a/src/credential/credential_serialization.c +++ b/src/credential/credential_serialization.c | |||
@@ -147,7 +147,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize ( | |||
147 | * @return the required size to serialize | 147 | * @return the required size to serialize |
148 | */ | 148 | */ |
149 | size_t | 149 | size_t |
150 | GNUNET_CREDENTIAL_credentials_get_size ( | 150 | GNUNET_CREDENTIAL_delegates_get_size ( |
151 | unsigned int c_count, | 151 | unsigned int c_count, |
152 | const struct GNUNET_CREDENTIAL_Delegate *cd) | 152 | const struct GNUNET_CREDENTIAL_Delegate *cd) |
153 | { | 153 | { |
@@ -173,7 +173,7 @@ GNUNET_CREDENTIAL_credentials_get_size ( | |||
173 | * @return the size of the data, -1 on failure | 173 | * @return the size of the data, -1 on failure |
174 | */ | 174 | */ |
175 | ssize_t | 175 | ssize_t |
176 | GNUNET_CREDENTIAL_credentials_serialize ( | 176 | GNUNET_CREDENTIAL_delegates_serialize ( |
177 | unsigned int c_count, | 177 | unsigned int c_count, |
178 | const struct GNUNET_CREDENTIAL_Delegate *cd, | 178 | const struct GNUNET_CREDENTIAL_Delegate *cd, |
179 | size_t dest_size, | 179 | size_t dest_size, |
@@ -221,7 +221,7 @@ GNUNET_CREDENTIAL_credentials_serialize ( | |||
221 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 221 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
222 | */ | 222 | */ |
223 | int | 223 | int |
224 | GNUNET_CREDENTIAL_credentials_deserialize ( | 224 | GNUNET_CREDENTIAL_delegates_deserialize ( |
225 | size_t len, | 225 | size_t len, |
226 | const char *src, | 226 | const char *src, |
227 | unsigned int c_count, | 227 | unsigned int c_count, |
@@ -281,7 +281,7 @@ GNUNET_CREDENTIAL_delegation_chain_get_size ( | |||
281 | (ret + dd[i].issuer_attribute_len + dd[i].subject_attribute_len) >= ret); | 281 | (ret + dd[i].issuer_attribute_len + dd[i].subject_attribute_len) >= ret); |
282 | ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len; | 282 | ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len; |
283 | } | 283 | } |
284 | return ret + GNUNET_CREDENTIAL_credentials_get_size (c_count, cd); | 284 | return ret + GNUNET_CREDENTIAL_delegates_get_size (c_count, cd); |
285 | } | 285 | } |
286 | 286 | ||
287 | /** | 287 | /** |
@@ -334,7 +334,7 @@ GNUNET_CREDENTIAL_delegation_chain_serialize ( | |||
334 | dd[i].subject_attribute_len); | 334 | dd[i].subject_attribute_len); |
335 | off += dd[i].subject_attribute_len; | 335 | off += dd[i].subject_attribute_len; |
336 | } | 336 | } |
337 | return off + GNUNET_CREDENTIAL_credentials_serialize (c_count, | 337 | return off + GNUNET_CREDENTIAL_delegates_serialize (c_count, |
338 | cd, | 338 | cd, |
339 | dest_size - off, | 339 | dest_size - off, |
340 | &dest[off]); | 340 | &dest[off]); |
@@ -385,7 +385,7 @@ GNUNET_CREDENTIAL_delegation_chain_deserialize ( | |||
385 | dd[i].subject_attribute = &src[off]; | 385 | dd[i].subject_attribute = &src[off]; |
386 | off += dd[i].subject_attribute_len; | 386 | off += dd[i].subject_attribute_len; |
387 | } | 387 | } |
388 | return GNUNET_CREDENTIAL_credentials_deserialize (len - off, | 388 | return GNUNET_CREDENTIAL_delegates_deserialize (len - off, |
389 | &src[off], | 389 | &src[off], |
390 | c_count, | 390 | c_count, |
391 | cd); | 391 | cd); |
diff --git a/src/credential/credential_serialization.h b/src/credential/credential_serialization.h index 072beb44e..12988354b 100644 --- a/src/credential/credential_serialization.h +++ b/src/credential/credential_serialization.h | |||
@@ -131,18 +131,18 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
131 | unsigned int c_count, | 131 | unsigned int c_count, |
132 | struct GNUNET_CREDENTIAL_Delegate *cd); | 132 | struct GNUNET_CREDENTIAL_Delegate *cd); |
133 | size_t | 133 | size_t |
134 | GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count, | 134 | GNUNET_CREDENTIAL_delegates_get_size (unsigned int c_count, |
135 | const struct GNUNET_CREDENTIAL_Delegate *cd); | 135 | const struct GNUNET_CREDENTIAL_Delegate *cd); |
136 | 136 | ||
137 | ssize_t | 137 | ssize_t |
138 | GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count, | 138 | GNUNET_CREDENTIAL_delegates_serialize (unsigned int c_count, |
139 | const struct GNUNET_CREDENTIAL_Delegate *cd, | 139 | const struct GNUNET_CREDENTIAL_Delegate *cd, |
140 | size_t dest_size, | 140 | size_t dest_size, |
141 | char *dest); | 141 | char *dest); |
142 | 142 | ||
143 | 143 | ||
144 | int | 144 | int |
145 | GNUNET_CREDENTIAL_credentials_deserialize (size_t len, | 145 | GNUNET_CREDENTIAL_delegates_deserialize (size_t len, |
146 | const char *src, | 146 | const char *src, |
147 | unsigned int c_count, | 147 | unsigned int c_count, |
148 | struct GNUNET_CREDENTIAL_Delegate *cd); | 148 | struct GNUNET_CREDENTIAL_Delegate *cd); |
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c index 64f5c5a5f..07148a1b5 100644 --- a/src/credential/gnunet-credential.c +++ b/src/credential/gnunet-credential.c | |||
@@ -254,17 +254,17 @@ handle_collect_result (void *cls, | |||
254 | unsigned int d_count, | 254 | unsigned int d_count, |
255 | struct GNUNET_CREDENTIAL_Delegation *dc, | 255 | struct GNUNET_CREDENTIAL_Delegation *dc, |
256 | unsigned int c_count, | 256 | unsigned int c_count, |
257 | struct GNUNET_CREDENTIAL_Delegate *cred) | 257 | struct GNUNET_CREDENTIAL_Delegate *dele) |
258 | { | 258 | { |
259 | int i; | 259 | int i; |
260 | char *line; | 260 | char *line; |
261 | 261 | ||
262 | verify_request = NULL; | 262 | verify_request = NULL; |
263 | if (NULL != cred) | 263 | if (NULL != dele) |
264 | { | 264 | { |
265 | for (i = 0; i < c_count; i++) | 265 | for (i = 0; i < c_count; i++) |
266 | { | 266 | { |
267 | line = GNUNET_CREDENTIAL_delegate_to_string (&cred[i]); | 267 | line = GNUNET_CREDENTIAL_delegate_to_string (&dele[i]); |
268 | printf ("%s\n", line); | 268 | printf ("%s\n", line); |
269 | GNUNET_free (line); | 269 | GNUNET_free (line); |
270 | } | 270 | } |
@@ -272,7 +272,6 @@ handle_collect_result (void *cls, | |||
272 | printf("Received NULL\n"); | 272 | printf("Received NULL\n"); |
273 | } | 273 | } |
274 | 274 | ||
275 | |||
276 | GNUNET_SCHEDULER_shutdown (); | 275 | GNUNET_SCHEDULER_shutdown (); |
277 | } | 276 | } |
278 | 277 | ||
@@ -282,14 +281,14 @@ handle_verify_result (void *cls, | |||
282 | unsigned int d_count, | 281 | unsigned int d_count, |
283 | struct GNUNET_CREDENTIAL_Delegation *dc, | 282 | struct GNUNET_CREDENTIAL_Delegation *dc, |
284 | unsigned int c_count, | 283 | unsigned int c_count, |
285 | struct GNUNET_CREDENTIAL_Delegate *cred) | 284 | struct GNUNET_CREDENTIAL_Delegate *dele) |
286 | { | 285 | { |
287 | int i; | 286 | int i; |
288 | char *iss_key; | 287 | char *iss_key; |
289 | char *sub_key; | 288 | char *sub_key; |
290 | 289 | ||
291 | verify_request = NULL; | 290 | verify_request = NULL; |
292 | if (NULL == cred) | 291 | if (NULL == dele) |
293 | printf ("Failed.\n"); | 292 | printf ("Failed.\n"); |
294 | else | 293 | else |
295 | { | 294 | { |
@@ -319,19 +318,18 @@ handle_verify_result (void *cls, | |||
319 | GNUNET_free (iss_key); | 318 | GNUNET_free (iss_key); |
320 | GNUNET_free (sub_key); | 319 | GNUNET_free (sub_key); |
321 | } | 320 | } |
322 | printf ("\nCredentials:\n"); | 321 | printf ("\nDelegate(s):\n"); |
323 | for (i = 0; i < c_count; i++) | 322 | for (i = 0; i < c_count; i++) |
324 | { | 323 | { |
325 | iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].issuer_key); | 324 | iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].issuer_key); |
326 | sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].subject_key); | 325 | sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].subject_key); |
327 | printf ("%s.%s <- %s\n", iss_key, cred[i].issuer_attribute, sub_key); | 326 | printf ("%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key); |
328 | GNUNET_free (iss_key); | 327 | GNUNET_free (iss_key); |
329 | GNUNET_free (sub_key); | 328 | GNUNET_free (sub_key); |
330 | } | 329 | } |
331 | printf ("Successful.\n"); | 330 | printf ("Successful.\n"); |
332 | } | 331 | } |
333 | 332 | ||
334 | |||
335 | GNUNET_SCHEDULER_shutdown (); | 333 | GNUNET_SCHEDULER_shutdown (); |
336 | } | 334 | } |
337 | 335 | ||
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index da43334df..2d954f823 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c | |||
@@ -303,32 +303,17 @@ struct VerifyRequestHandle | |||
303 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; | 303 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; |
304 | 304 | ||
305 | /** | 305 | /** |
306 | * Credential DLL | 306 | * Delegate DLL |
307 | */ | ||
308 | struct CredentialRecordEntry *cred_chain_head; | ||
309 | |||
310 | /** | ||
311 | * Credential DLL | ||
312 | */ | ||
313 | struct CredentialRecordEntry *cred_chain_tail; | ||
314 | |||
315 | /** | ||
316 | * Credential DLL size | ||
317 | */ | ||
318 | uint32_t cred_chain_size; | ||
319 | |||
320 | /** | ||
321 | * Credential DLL | ||
322 | */ | 307 | */ |
323 | struct DelegateRecordEntry *del_chain_head; | 308 | struct DelegateRecordEntry *del_chain_head; |
324 | 309 | ||
325 | /** | 310 | /** |
326 | * Credential DLL | 311 | * Delegate DLL |
327 | */ | 312 | */ |
328 | struct DelegateRecordEntry *del_chain_tail; | 313 | struct DelegateRecordEntry *del_chain_tail; |
329 | 314 | ||
330 | /** | 315 | /** |
331 | * Credential DLL size | 316 | * Delegate DLL size |
332 | */ | 317 | */ |
333 | uint32_t del_chain_size; | 318 | uint32_t del_chain_size; |
334 | 319 | ||
@@ -358,19 +343,9 @@ struct VerifyRequestHandle | |||
358 | enum direction resolution_algo; | 343 | enum direction resolution_algo; |
359 | 344 | ||
360 | /** | 345 | /** |
361 | * Credential iterator | 346 | * Delegate iterator for lookup |
362 | */ | ||
363 | struct GNUNET_NAMESTORE_ZoneIterator *cred_collection_iter; | ||
364 | |||
365 | /** | ||
366 | * Credential iterator | ||
367 | */ | 347 | */ |
368 | struct GNUNET_NAMESTORE_QueueEntry *dele_qe; | 348 | struct GNUNET_NAMESTORE_QueueEntry *dele_qe; |
369 | |||
370 | /** | ||
371 | * Collect task | ||
372 | */ | ||
373 | struct GNUNET_SCHEDULER_Task *collect_next_task; | ||
374 | }; | 349 | }; |
375 | 350 | ||
376 | 351 | ||
@@ -443,7 +418,7 @@ cleanup_delegation_set (struct DelegationSetQueueEntry *ds_entry) | |||
443 | static void | 418 | static void |
444 | cleanup_handle (struct VerifyRequestHandle *vrh) | 419 | cleanup_handle (struct VerifyRequestHandle *vrh) |
445 | { | 420 | { |
446 | struct CredentialRecordEntry *cr_entry; | 421 | struct DelegateRecordEntry *del_entry; |
447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n"); | 422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n"); |
448 | if (NULL != vrh->lookup_request) { | 423 | if (NULL != vrh->lookup_request) { |
449 | GNUNET_GNS_lookup_cancel (vrh->lookup_request); | 424 | GNUNET_GNS_lookup_cancel (vrh->lookup_request); |
@@ -451,13 +426,13 @@ cleanup_handle (struct VerifyRequestHandle *vrh) | |||
451 | } | 426 | } |
452 | cleanup_delegation_set (vrh->root_set); | 427 | cleanup_delegation_set (vrh->root_set); |
453 | GNUNET_free_non_null (vrh->issuer_attribute); | 428 | GNUNET_free_non_null (vrh->issuer_attribute); |
454 | for (cr_entry = vrh->cred_chain_head; NULL != vrh->cred_chain_head; | 429 | for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head; |
455 | cr_entry = vrh->cred_chain_head) { | 430 | del_entry = vrh->del_chain_head) { |
456 | GNUNET_CONTAINER_DLL_remove (vrh->cred_chain_head, | 431 | GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, |
457 | vrh->cred_chain_tail, | 432 | vrh->del_chain_tail, |
458 | cr_entry); | 433 | del_entry); |
459 | GNUNET_free_non_null (cr_entry->credential); | 434 | GNUNET_free_non_null (del_entry->delegate); |
460 | GNUNET_free (cr_entry); | 435 | GNUNET_free (del_entry); |
461 | } | 436 | } |
462 | GNUNET_free (vrh); | 437 | GNUNET_free (vrh); |
463 | } | 438 | } |
@@ -497,10 +472,9 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
497 | struct DelegationChainResultMessage *rmsg; | 472 | struct DelegationChainResultMessage *rmsg; |
498 | struct DelegationChainEntry *dce; | 473 | struct DelegationChainEntry *dce; |
499 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; | 474 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; |
500 | //TODO rename cred/cd | ||
501 | //TODO rename all methods using credential | 475 | //TODO rename all methods using credential |
502 | struct GNUNET_CREDENTIAL_Delegate cred[vrh->del_chain_size]; | 476 | struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size]; |
503 | struct DelegateRecordEntry *cd; | 477 | struct DelegateRecordEntry *del; |
504 | struct DelegateRecordEntry *tmp; | 478 | struct DelegateRecordEntry *tmp; |
505 | size_t size; | 479 | size_t size; |
506 | 480 | ||
@@ -521,13 +495,13 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
521 | } | 495 | } |
522 | 496 | ||
523 | // Remove all not needed credentials | 497 | // Remove all not needed credentials |
524 | for (cd = vrh->del_chain_head; NULL != cd;) { | 498 | for (del = vrh->del_chain_head; NULL != del;) { |
525 | if (cd->refcount > 0) { | 499 | if (del->refcount > 0) { |
526 | cd = cd->next; | 500 | del = del->next; |
527 | continue; | 501 | continue; |
528 | } | 502 | } |
529 | tmp = cd; | 503 | tmp = del; |
530 | cd = cd->next; | 504 | del = del->next; |
531 | GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, | 505 | GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, |
532 | vrh->del_chain_tail, | 506 | vrh->del_chain_tail, |
533 | tmp); | 507 | tmp); |
@@ -536,25 +510,23 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
536 | vrh->del_chain_size--; | 510 | vrh->del_chain_size--; |
537 | } | 511 | } |
538 | 512 | ||
539 | /** | 513 | // Get serialized record data |
540 | * Get serialized record data | 514 | // Append at the end of rmsg |
541 | * Append at the end of rmsg | 515 | del = vrh->del_chain_head; |
542 | */ | ||
543 | cd = vrh->del_chain_head; | ||
544 | for (uint32_t i = 0; i < vrh->del_chain_size; i++) { | 516 | for (uint32_t i = 0; i < vrh->del_chain_size; i++) { |
545 | cred[i].issuer_key = cd->delegate->issuer_key; | 517 | dele[i].issuer_key = del->delegate->issuer_key; |
546 | cred[i].subject_key = cd->delegate->subject_key; | 518 | dele[i].subject_key = del->delegate->subject_key; |
547 | cred[i].issuer_attribute_len | 519 | dele[i].issuer_attribute_len |
548 | = strlen (cd->delegate->issuer_attribute) + 1; | 520 | = strlen (del->delegate->issuer_attribute) + 1; |
549 | cred[i].issuer_attribute = cd->delegate->issuer_attribute; | 521 | dele[i].issuer_attribute = del->delegate->issuer_attribute; |
550 | cred[i].expiration = cd->delegate->expiration; | 522 | dele[i].expiration = del->delegate->expiration; |
551 | cred[i].signature = cd->delegate->signature; | 523 | dele[i].signature = del->delegate->signature; |
552 | cd = cd->next; | 524 | del = del->next; |
553 | } | 525 | } |
554 | size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size, | 526 | size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size, |
555 | dd, | 527 | dd, |
556 | vrh->del_chain_size, | 528 | vrh->del_chain_size, |
557 | cred); | 529 | dele); |
558 | env = GNUNET_MQ_msg_extra (rmsg, | 530 | env = GNUNET_MQ_msg_extra (rmsg, |
559 | size, | 531 | size, |
560 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT); | 532 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT); |
@@ -564,16 +536,16 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
564 | rmsg->c_count = htonl (vrh->del_chain_size); | 536 | rmsg->c_count = htonl (vrh->del_chain_size); |
565 | 537 | ||
566 | if (0 < vrh->del_chain_size) | 538 | if (0 < vrh->del_chain_size) |
567 | rmsg->cred_found = htonl (GNUNET_YES); | 539 | rmsg->del_found = htonl (GNUNET_YES); |
568 | else | 540 | else |
569 | rmsg->cred_found = htonl (GNUNET_NO); | 541 | rmsg->del_found = htonl (GNUNET_NO); |
570 | 542 | ||
571 | GNUNET_assert ( | 543 | GNUNET_assert ( |
572 | -1 | 544 | -1 |
573 | != GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, | 545 | != GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, |
574 | dd, | 546 | dd, |
575 | vrh->del_chain_size, | 547 | vrh->del_chain_size, |
576 | cred, | 548 | dele, |
577 | size, | 549 | size, |
578 | (char *)&rmsg[1])); | 550 | (char *)&rmsg[1])); |
579 | 551 | ||
@@ -648,7 +620,7 @@ partial_match(char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issu | |||
648 | } | 620 | } |
649 | 621 | ||
650 | static void | 622 | static void |
651 | test_resolution (void *cls, | 623 | forward_resolution (void *cls, |
652 | uint32_t rd_count, | 624 | uint32_t rd_count, |
653 | const struct GNUNET_GNSRECORD_Data *rd) | 625 | const struct GNUNET_GNSRECORD_Data *rd) |
654 | { | 626 | { |
@@ -773,7 +745,7 @@ test_resolution (void *cls, | |||
773 | { | 745 | { |
774 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found: Solution\n"); | 746 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found: Solution\n"); |
775 | 747 | ||
776 | // Add to delegation_chain | 748 | // Add found solution into delegation_chain |
777 | struct DelegationSetQueueEntry *tmp_set; | 749 | struct DelegationSetQueueEntry *tmp_set; |
778 | for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; | 750 | for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; |
779 | tmp_set = tmp_set->parent_queue_entry->parent_set) { | 751 | tmp_set = tmp_set->parent_queue_entry->parent_set) { |
@@ -784,9 +756,6 @@ test_resolution (void *cls, | |||
784 | tmp_set->delegation_chain_entry); | 756 | tmp_set->delegation_chain_entry); |
785 | } | 757 | } |
786 | } | 758 | } |
787 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "tmpentrylast %s %s\n", | ||
788 | GNUNET_CRYPTO_ecdsa_public_key_to_string(&vrh->delegation_chain_head->subject_key), | ||
789 | vrh->delegation_chain_head->subject_attribute); | ||
790 | 759 | ||
791 | // Increase refcount for this delegate | 760 | // Increase refcount for this delegate |
792 | for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) { | 761 | for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) { |
@@ -819,7 +788,7 @@ test_resolution (void *cls, | |||
819 | &del->issuer_key, | 788 | &del->issuer_key, |
820 | GNUNET_GNSRECORD_TYPE_DELEGATE, | 789 | GNUNET_GNSRECORD_TYPE_DELEGATE, |
821 | GNUNET_GNS_LO_DEFAULT, | 790 | GNUNET_GNS_LO_DEFAULT, |
822 | &test_resolution, | 791 | &forward_resolution, |
823 | ds_entry); | 792 | ds_entry); |
824 | } | 793 | } |
825 | 794 | ||
@@ -875,8 +844,6 @@ backward_resolution (void *cls, | |||
875 | dq_entry->required_solutions = ntohl (sets->set_count); | 844 | dq_entry->required_solutions = ntohl (sets->set_count); |
876 | dq_entry->parent_set = current_set; | 845 | dq_entry->parent_set = current_set; |
877 | 846 | ||
878 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# New OR entry into queue\n"); | ||
879 | |||
880 | GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head, | 847 | GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head, |
881 | current_set->queue_entries_tail, | 848 | current_set->queue_entries_tail, |
882 | dq_entry); | 849 | dq_entry); |
@@ -953,7 +920,6 @@ backward_resolution (void *cls, | |||
953 | // Backtrack | 920 | // Backtrack |
954 | for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; | 921 | for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; |
955 | tmp_set = tmp_set->parent_queue_entry->parent_set) { | 922 | tmp_set = tmp_set->parent_queue_entry->parent_set) { |
956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# %s\n", tmp_set->unresolved_attribute_delegation); | ||
957 | tmp_set->parent_queue_entry->required_solutions--; | 923 | tmp_set->parent_queue_entry->required_solutions--; |
958 | if (NULL != tmp_set->delegation_chain_entry) { | 924 | if (NULL != tmp_set->delegation_chain_entry) { |
959 | vrh->delegation_chain_size++; | 925 | vrh->delegation_chain_size++; |
@@ -982,7 +948,6 @@ backward_resolution (void *cls, | |||
982 | issuer_attribute_name[strlen (ds_entry->unresolved_attribute_delegation) | 948 | issuer_attribute_name[strlen (ds_entry->unresolved_attribute_delegation) |
983 | + 1]; | 949 | + 1]; |
984 | strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation); | 950 | strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation); |
985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Issuer Att Name: %s\n", issuer_attribute_name); | ||
986 | char *next_attr = strtok (issuer_attribute_name, "."); | 951 | char *next_attr = strtok (issuer_attribute_name, "."); |
987 | if (NULL == next_attr) { | 952 | if (NULL == next_attr) { |
988 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 953 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1036,7 +1001,7 @@ backward_resolution (void *cls, | |||
1036 | * @param cls the closure (our client lookup handle) | 1001 | * @param cls the closure (our client lookup handle) |
1037 | */ | 1002 | */ |
1038 | static void | 1003 | static void |
1039 | delegation_chain_resolution_start (void *cls) | 1004 | delegation_chain_bw_resolution_start (void *cls) |
1040 | { | 1005 | { |
1041 | struct VerifyRequestHandle *vrh = cls; | 1006 | struct VerifyRequestHandle *vrh = cls; |
1042 | struct DelegationSetQueueEntry *ds_entry; | 1007 | struct DelegationSetQueueEntry *ds_entry; |
@@ -1064,10 +1029,9 @@ delegation_chain_resolution_start (void *cls) | |||
1064 | return; | 1029 | return; |
1065 | } | 1030 | } |
1066 | 1031 | ||
1067 | /** | 1032 | |
1068 | * Check for attributes from the issuer and follow the chain | 1033 | //Check for attributes from the issuer and follow the chain |
1069 | * till you get the required subject's attributes | 1034 | //till you get the required subject's attributes |
1070 | */ | ||
1071 | char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1]; | 1035 | char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1]; |
1072 | strcpy (issuer_attribute_name, vrh->issuer_attribute); | 1036 | strcpy (issuer_attribute_name, vrh->issuer_attribute); |
1073 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1083,8 +1047,9 @@ delegation_chain_resolution_start (void *cls) | |||
1083 | ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); | 1047 | ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); |
1084 | vrh->root_set = ds_entry; | 1048 | vrh->root_set = ds_entry; |
1085 | vrh->pending_lookups = 1; | 1049 | vrh->pending_lookups = 1; |
1050 | |||
1086 | // Start with backward resolution | 1051 | // Start with backward resolution |
1087 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Start Backward Resolution\n"); | 1052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Backward Resolution\n"); |
1088 | 1053 | ||
1089 | ds_entry->lookup_request = GNUNET_GNS_lookup (gns, | 1054 | ds_entry->lookup_request = GNUNET_GNS_lookup (gns, |
1090 | issuer_attribute_name, | 1055 | issuer_attribute_name, |
@@ -1146,8 +1111,6 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1146 | // ds_entry created belongs to the first lookup, vrh still has the | 1111 | // ds_entry created belongs to the first lookup, vrh still has the |
1147 | // issuer+attr we look for | 1112 | // issuer+attr we look for |
1148 | for (del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) { | 1113 | for (del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) { |
1149 | //char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1]; | ||
1150 | //strcpy (issuer_attribute_name, vrh->issuer_attribute); | ||
1151 | 1114 | ||
1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1153 | "Looking for %s.%s\n", | 1116 | "Looking for %s.%s\n", |
@@ -1159,23 +1122,20 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1159 | GNUNET_memcpy (ds_entry->issuer_key, | 1122 | GNUNET_memcpy (ds_entry->issuer_key, |
1160 | &del_entry->delegate->subject_key, | 1123 | &del_entry->delegate->subject_key, |
1161 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 1124 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
1162 | //ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute); | ||
1163 | ds_entry->attr_trailer = GNUNET_strdup(del_entry->delegate->issuer_attribute); | 1125 | ds_entry->attr_trailer = GNUNET_strdup(del_entry->delegate->issuer_attribute); |
1164 | ds_entry->handle = vrh; | 1126 | ds_entry->handle = vrh; |
1165 | // TODO: no lookup attribute for forward? | ||
1166 | //ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); | ||
1167 | 1127 | ||
1168 | vrh->root_set = ds_entry; | 1128 | vrh->root_set = ds_entry; |
1169 | vrh->pending_lookups ++; | 1129 | vrh->pending_lookups ++; |
1170 | // Start with forward resolution | 1130 | // Start with forward resolution |
1171 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Start Forward Resolution\n"); | 1131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n"); |
1172 | 1132 | ||
1173 | ds_entry->lookup_request = GNUNET_GNS_lookup (gns, | 1133 | ds_entry->lookup_request = GNUNET_GNS_lookup (gns, |
1174 | GNUNET_GNS_EMPTY_LABEL_AT, | 1134 | GNUNET_GNS_EMPTY_LABEL_AT, |
1175 | &del_entry->delegate->issuer_key, // issuer_key, | 1135 | &del_entry->delegate->issuer_key, // issuer_key, |
1176 | GNUNET_GNSRECORD_TYPE_DELEGATE, | 1136 | GNUNET_GNSRECORD_TYPE_DELEGATE, |
1177 | GNUNET_GNS_LO_DEFAULT, | 1137 | GNUNET_GNS_LO_DEFAULT, |
1178 | &test_resolution, | 1138 | &forward_resolution, |
1179 | ds_entry); | 1139 | ds_entry); |
1180 | } | 1140 | } |
1181 | } | 1141 | } |
@@ -1210,12 +1170,12 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1210 | struct VerifyRequestHandle *vrh; | 1170 | struct VerifyRequestHandle *vrh; |
1211 | struct GNUNET_SERVICE_Client *client = cls; | 1171 | struct GNUNET_SERVICE_Client *client = cls; |
1212 | struct DelegateRecordEntry *del_entry; | 1172 | struct DelegateRecordEntry *del_entry; |
1213 | uint32_t credentials_count; | 1173 | uint32_t delegate_count; |
1214 | uint32_t credential_data_size; | 1174 | uint32_t delegate_data_size; |
1215 | char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; | 1175 | char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; |
1216 | char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; | 1176 | char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; |
1217 | char *attrptr = attr; | 1177 | char *attrptr = attr; |
1218 | char *credential_data; | 1178 | char *delegate_data; |
1219 | const char *utf_in; | 1179 | const char *utf_in; |
1220 | 1180 | ||
1221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n"); | 1181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n"); |
@@ -1240,39 +1200,39 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1240 | } | 1200 | } |
1241 | 1201 | ||
1242 | // Parse delegates from verifaction message | 1202 | // Parse delegates from verifaction message |
1243 | credentials_count = ntohl (v_msg->c_count); | 1203 | delegate_count = ntohl (v_msg->d_count); |
1244 | credential_data_size = ntohs (v_msg->header.size) | 1204 | delegate_data_size = ntohs (v_msg->header.size) |
1245 | - sizeof (struct VerifyMessage) | 1205 | - sizeof (struct VerifyMessage) |
1246 | - ntohs (v_msg->issuer_attribute_len) - 1; | 1206 | - ntohs (v_msg->issuer_attribute_len) - 1; |
1247 | struct GNUNET_CREDENTIAL_Delegate credentials[credentials_count]; | 1207 | struct GNUNET_CREDENTIAL_Delegate delegates[delegate_count]; |
1248 | memset (credentials, | 1208 | memset (delegates, |
1249 | 0, | 1209 | 0, |
1250 | sizeof (struct GNUNET_CREDENTIAL_Delegate) * credentials_count); | 1210 | sizeof (struct GNUNET_CREDENTIAL_Delegate) * delegate_count); |
1251 | credential_data = (char *)&v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1; | 1211 | delegate_data = (char *)&v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1; |
1252 | if (GNUNET_OK | 1212 | if (GNUNET_OK |
1253 | != GNUNET_CREDENTIAL_credentials_deserialize (credential_data_size, | 1213 | != GNUNET_CREDENTIAL_delegates_deserialize (delegate_data_size, |
1254 | credential_data, | 1214 | delegate_data, |
1255 | credentials_count, | 1215 | delegate_count, |
1256 | credentials)) { | 1216 | delegates)) { |
1257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize credentials!\n"); | 1217 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n"); |
1258 | send_lookup_response (vrh); | 1218 | send_lookup_response (vrh); |
1259 | return; | 1219 | return; |
1260 | } | 1220 | } |
1261 | 1221 | ||
1262 | // Prepare vrh delegation chain for later validation | 1222 | // Prepare vrh delegation chain for later validation |
1263 | for (uint32_t i = 0; i < credentials_count; i++) { | 1223 | for (uint32_t i = 0; i < delegate_count; i++) { |
1264 | del_entry = GNUNET_new (struct DelegateRecordEntry); | 1224 | del_entry = GNUNET_new (struct DelegateRecordEntry); |
1265 | del_entry->delegate | 1225 | del_entry->delegate |
1266 | = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Delegate) | 1226 | = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Delegate) |
1267 | + credentials[i].issuer_attribute_len + 1); | 1227 | + delegates[i].issuer_attribute_len + 1); |
1268 | GNUNET_memcpy (del_entry->delegate, | 1228 | GNUNET_memcpy (del_entry->delegate, |
1269 | &credentials[i], | 1229 | &delegates[i], |
1270 | sizeof (struct GNUNET_CREDENTIAL_Delegate)); | 1230 | sizeof (struct GNUNET_CREDENTIAL_Delegate)); |
1271 | GNUNET_memcpy (&del_entry->delegate[1], | 1231 | GNUNET_memcpy (&del_entry->delegate[1], |
1272 | credentials[i].issuer_attribute, | 1232 | delegates[i].issuer_attribute, |
1273 | credentials[i].issuer_attribute_len); | 1233 | delegates[i].issuer_attribute_len); |
1274 | del_entry->delegate->issuer_attribute_len | 1234 | del_entry->delegate->issuer_attribute_len |
1275 | = credentials[i].issuer_attribute_len; | 1235 | = delegates[i].issuer_attribute_len; |
1276 | del_entry->delegate->issuer_attribute = (char *)&del_entry->delegate[1]; | 1236 | del_entry->delegate->issuer_attribute = (char *)&del_entry->delegate[1]; |
1277 | GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head, | 1237 | GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head, |
1278 | vrh->del_chain_tail, | 1238 | vrh->del_chain_tail, |
@@ -1282,10 +1242,8 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1282 | 1242 | ||
1283 | // Switch resolution algo | 1243 | // Switch resolution algo |
1284 | if(Backward == vrh->resolution_algo){ | 1244 | if(Backward == vrh->resolution_algo){ |
1285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++backward\n"); | 1245 | delegation_chain_bw_resolution_start (vrh); |
1286 | delegation_chain_resolution_start (vrh); | ||
1287 | } else if (Forward == vrh->resolution_algo){ | 1246 | } else if (Forward == vrh->resolution_algo){ |
1288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++forward\n"); | ||
1289 | delegation_chain_fw_resolution_start (vrh); | 1247 | delegation_chain_fw_resolution_start (vrh); |
1290 | } else{ | 1248 | } else{ |
1291 | //TODO | 1249 | //TODO |
@@ -1293,26 +1251,24 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1293 | } | 1251 | } |
1294 | 1252 | ||
1295 | static void | 1253 | static void |
1296 | handle_cred_collection_error_cb (void *cls) | 1254 | handle_delegate_collection_error_cb (void *cls) |
1297 | { | 1255 | { |
1298 | struct VerifyRequestHandle *vrh = cls; | 1256 | struct VerifyRequestHandle *vrh = cls; |
1299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1300 | "Got disconnected from namestore database.\n"); | 1258 | "Got disconnected from namestore database.\n"); |
1301 | vrh->cred_collection_iter = NULL; | 1259 | vrh->dele_qe = NULL; |
1302 | send_lookup_response (vrh); | 1260 | send_lookup_response (vrh); |
1303 | } | 1261 | } |
1304 | 1262 | ||
1305 | static void | 1263 | static void |
1306 | handle_cred_collection_finished_cb (void *cls) | 1264 | delegate_collection_finished (void *cls) |
1307 | { | 1265 | { |
1308 | struct VerifyRequestHandle *vrh = cls; | 1266 | struct VerifyRequestHandle *vrh = cls; |
1309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting credentials.\n"); | 1267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n"); |
1310 | vrh->cred_collection_iter = NULL; | 1268 | |
1311 | if(Backward == vrh->resolution_algo){ | 1269 | if(Backward == vrh->resolution_algo){ |
1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++backward\n"); | 1270 | delegation_chain_bw_resolution_start (vrh); |
1313 | delegation_chain_resolution_start (vrh); | ||
1314 | } else if (Forward == vrh->resolution_algo){ | 1271 | } else if (Forward == vrh->resolution_algo){ |
1315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++forward\n"); | ||
1316 | delegation_chain_fw_resolution_start (vrh); | 1272 | delegation_chain_fw_resolution_start (vrh); |
1317 | } else{ | 1273 | } else{ |
1318 | //TODO | 1274 | //TODO |
@@ -1320,7 +1276,7 @@ handle_cred_collection_finished_cb (void *cls) | |||
1320 | } | 1276 | } |
1321 | 1277 | ||
1322 | static void | 1278 | static void |
1323 | tmp_handle_cred_collection_cb (void *cls, | 1279 | handle_delegate_collection_cb (void *cls, |
1324 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 1280 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
1325 | const char *label, | 1281 | const char *label, |
1326 | unsigned int rd_count, | 1282 | unsigned int rd_count, |
@@ -1350,9 +1306,8 @@ tmp_handle_cred_collection_cb (void *cls, | |||
1350 | del_entry); | 1306 | del_entry); |
1351 | vrh->del_chain_size++; | 1307 | vrh->del_chain_size++; |
1352 | } | 1308 | } |
1353 | // No need to collect next, should have all already | 1309 | |
1354 | //vrh->collect_next_task = GNUNET_SCHEDULER_add_now (&collect_next, vrh); | 1310 | delegate_collection_finished(vrh); |
1355 | handle_cred_collection_finished_cb(vrh); | ||
1356 | } | 1311 | } |
1357 | 1312 | ||
1358 | static void | 1313 | static void |
@@ -1386,27 +1341,15 @@ handle_collect (void *cls, const struct CollectMessage *c_msg) | |||
1386 | send_lookup_response (vrh); | 1341 | send_lookup_response (vrh); |
1387 | return; | 1342 | return; |
1388 | } | 1343 | } |
1389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting credentials for subject\n"); | 1344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n"); |
1390 | /** | 1345 | |
1391 | * First, get attribute from subject | 1346 | // Get all delegates from subject |
1392 | */ | ||
1393 | // TODO NAMESTORE_lookup auf empty label statt iteration, iteration genutzt da nicht wusste welches label | ||
1394 | /*vrh->cred_collection_iter = GNUNET_NAMESTORE_zone_iteration_start ( | ||
1395 | namestore, | ||
1396 | &c_msg->subject_key, | ||
1397 | &handle_cred_collection_error_cb, | ||
1398 | vrh, | ||
1399 | &handle_cred_collection_cb, | ||
1400 | vrh, | ||
1401 | &handle_cred_collection_finished_cb, | ||
1402 | vrh);*/ | ||
1403 | //TODO rename tmp_handle_... and test_resolution.. | ||
1404 | vrh->dele_qe = GNUNET_NAMESTORE_records_lookup (namestore, | 1347 | vrh->dele_qe = GNUNET_NAMESTORE_records_lookup (namestore, |
1405 | &c_msg->subject_key, | 1348 | &c_msg->subject_key, |
1406 | GNUNET_GNS_EMPTY_LABEL_AT, | 1349 | GNUNET_GNS_EMPTY_LABEL_AT, |
1407 | &handle_cred_collection_error_cb, | 1350 | &handle_delegate_collection_error_cb, |
1408 | vrh, | 1351 | vrh, |
1409 | &tmp_handle_cred_collection_cb, | 1352 | &handle_delegate_collection_cb, |
1410 | vrh); | 1353 | vrh); |
1411 | GNUNET_SERVICE_client_continue (vrh->client); | 1354 | GNUNET_SERVICE_client_continue (vrh->client); |
1412 | } | 1355 | } |
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c index 90cd2f46a..784c7def1 100644 --- a/src/credential/plugin_gnsrecord_credential.c +++ b/src/credential/plugin_gnsrecord_credential.c | |||
@@ -79,9 +79,7 @@ credential_value_to_string (void *cls, | |||
79 | { | 79 | { |
80 | subject_pkey = | 80 | subject_pkey = |
81 | GNUNET_CRYPTO_ecdsa_public_key_to_string (&set[i].subject_key); | 81 | GNUNET_CRYPTO_ecdsa_public_key_to_string (&set[i].subject_key); |
82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 82 | |
83 | "%d len attr\n", | ||
84 | set[i].subject_attribute_len); | ||
85 | if (0 == set[i].subject_attribute_len) | 83 | if (0 == set[i].subject_attribute_len) |
86 | { | 84 | { |
87 | if (0 == i) | 85 | if (0 == i) |
diff --git a/src/credential/test_credential_own.sh b/src/credential/test_credential_own.sh index 19dd686a9..d2ed0b0ac 100755 --- a/src/credential/test_credential_own.sh +++ b/src/credential/test_credential_own.sh | |||
@@ -54,6 +54,7 @@ STATE_STUD_ATTR="student" | |||
54 | REG_STUD_ATTR="student" | 54 | REG_STUD_ATTR="student" |
55 | END_ATTR="end" | 55 | END_ATTR="end" |
56 | 56 | ||
57 | # FORWARD, subject side stored | ||
57 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=a --attribute="a" --subject="$AKEY b.c" --ttl="2019-12-12 10:00:00"` | 58 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=a --attribute="a" --subject="$AKEY b.c" --ttl="2019-12-12 10:00:00"` |
58 | gnunet-credential --createSubjectSide --ego=a --import "$SIGNED" | 59 | gnunet-credential --createSubjectSide --ego=a --import "$SIGNED" |
59 | gnunet-namestore -D -z a | 60 | gnunet-namestore -D -z a |
@@ -79,66 +80,35 @@ gnunet-credential --createSubjectSide --ego=g --import "$SIGNED" | |||
79 | gnunet-namestore -D -z g | 80 | gnunet-namestore -D -z g |
80 | 81 | ||
81 | 82 | ||
82 | 83 | # BACKWARD, issuer side stored | |
83 | TEST_CREDENTIAL="mygnunetcreds" | ||
84 | # Own issuer side storage: | ||
85 | #gnunet-credential --createIssuerSide --ego=epub --attribute="issside" --subject="$EORG_KEY asd" --ttl=5m | ||
86 | |||
87 | #gnunet-namestore -D -z epub | ||
88 | |||
89 | # Own subject side storage: | ||
90 | #SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd" --subject="$EORG_KEY" --ttl="2019-12-12 10:00:00"` | ||
91 | #gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED" | ||
92 | |||
93 | #SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd" --subject="$EORG_KEY efghijklmno" --ttl="2019-12-12 10:00:00"` | ||
94 | #gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED" | ||
95 | |||
96 | #SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd" --subject="$EORG_KEY efghijklmno.pqr" --ttl="2019-12-12 10:00:00"` | ||
97 | #gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED" | ||
98 | |||
99 | #SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd.stu" --subject="$EORG_KEY efghijklmno.pqr" --ttl="2019-12-12 10:00:00"` | ||
100 | #gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED" | ||
101 | |||
102 | #SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=stateu --attribute="aaa" --subject="$EPUB_KEY bbbb" --ttl="2019-12-12 10:00:00"` | ||
103 | #gnunet-credential --createSubjectSide --ego=epub --import "$SIGNED" | ||
104 | |||
105 | #gnunet-namestore -D -z eorg | ||
106 | |||
107 | # (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg | 84 | # (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg |
108 | gnunet-namestore -p -z epub -a -n $DISC_ATTR -t ATTR -V "$EORG_KEY $PREF_ATTR" -e 5m -c test_credential_lookup.conf | 85 | gnunet-credential --createIssuerSide --ego=epub --attribute=$DISC_ATTR --subject="$EORG_KEY $PREF_ATTR" --ttl=5m -c test_credential_lookup.conf |
109 | gnunet-namestore -p -z epub -a -n "random" -t ATTR -V "$GKEY random" -e 5m -c test_credential_lookup.conf | ||
110 | 86 | ||
111 | # (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU | 87 | # (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU |
112 | gnunet-namestore -p -z eorg -a -n $PREF_ATTR -t ATTR -V "$STATEU_KEY $STATE_STUD_ATTR" -e 5m -c test_credential_lookup.conf | 88 | gnunet-credential --createIssuerSide --ego=eorg --attribute=$PREF_ATTR --subject="$STATEU_KEY $STATE_STUD_ATTR" --ttl=5m -c test_credential_lookup.conf |
113 | 89 | ||
114 | # (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB | 90 | # (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB |
115 | gnunet-namestore -p -z stateu -a -n $STATE_STUD_ATTR -t ATTR -V "$REGISTRARB_KEY $REG_STUD_ATTR" -e 5m -c test_credential_lookup.conf | 91 | gnunet-credential --createIssuerSide --ego=stateu --attribute=$STATE_STUD_ATTR --subject="$REGISTRARB_KEY $REG_STUD_ATTR" --ttl=5m -c test_credential_lookup.conf |
116 | 92 | ||
117 | # (4) RegistrarB issues Alice the credential "student" | 93 | # (4) RegistrarB issues Alice the credential "student" |
118 | CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=registrarb --subject=$ALICE_KEY --attribute=$REG_STUD_ATTR --ttl=5m -c test_credential_lookup.conf` | ||
119 | |||
120 | # Alice stores the credential under "mygnunetcreds" | ||
121 | #gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf | ||
122 | |||
123 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=registrarb --attribute="$REG_STUD_ATTR" --subject="$ALICE_KEY" --ttl="2019-12-12 10:00:00"` | 94 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=registrarb --attribute="$REG_STUD_ATTR" --subject="$ALICE_KEY" --ttl="2019-12-12 10:00:00"` |
124 | gnunet-credential --createSubjectSide --ego=alice --import "$SIGNED" | 95 | gnunet-credential --createSubjectSide --ego=alice --import "$SIGNED" |
125 | 96 | ||
126 | # Starting to resolve | 97 | # Starting to resolve |
127 | echo "+++++Starting Collect" | 98 | echo "+++ Starting to Resolve +++" |
128 | 99 | ||
129 | CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=g -c test_credential_lookup.conf | paste -d, -s` | 100 | #CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=g -c test_credential_lookup.conf | paste -d, -s` |
130 | echo $CREDS | ||
131 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential=\'$CREDS\' -c test_credential_lookup.conf | ||
132 | RES_CRED=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential="$CREDS" -c test_credential_lookup.conf` | ||
133 | |||
134 | #CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s` | ||
135 | #echo $CREDS | 101 | #echo $CREDS |
136 | #echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential=\'$CREDS\' -c test_credential_lookup.conf | 102 | #echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential=\'$CREDS\' -c test_credential_lookup.conf |
137 | #RES_CRED=`gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential="$CREDS" -c test_credential_lookup.conf` | 103 | #RES_CRED=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential="$CREDS" -c test_credential_lookup.conf` |
104 | |||
105 | CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s` | ||
106 | echo $CREDS | ||
107 | echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential=\'$CREDS\' -c test_credential_lookup.conf | ||
108 | RES_CRED=`gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential="$CREDS" -c test_credential_lookup.conf` | ||
138 | 109 | ||
139 | 110 | ||
140 | # Cleanup properly | 111 | # Cleanup properly |
141 | gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf | ||
142 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | 112 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf |
143 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | 113 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf |
144 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | 114 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf |