summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-02 15:41:55 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-02 15:41:55 +0100
commitded88c36e813c2a6b669d7082ecda1695f5b24bd (patch)
treec7fc87c8c907f8d659c45ab70bad2611de996beb /src
parentf89b1efa793f9c2201ab9f4575c0f283b3bba288 (diff)
parent191fd80caf3288ff2a620541f4aa623647b589fa (diff)
downloadgnunet-ded88c36e813c2a6b669d7082ecda1695f5b24bd.tar.gz
gnunet-ded88c36e813c2a6b669d7082ecda1695f5b24bd.zip
Merge branch 'credentials' of git+ssh://gnunet.org/gnunet into credentials
Diffstat (limited to 'src')
-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 3ad2e2e1d..ed7d249e3 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
110 */ 132 */
111 struct AttributeRecordEntry *attr_chain_tail; 133 struct CredentialRecordEntry *cred_chain_tail;
134
135 /**
136 * Attribute Queue
137 */
138 struct AttributeRecordEntry *attr_queue_head;
139
140 /**
141 * Attribute Queue
142 */
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,13 +288,28 @@ 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 * TODO 315 * TODO
@@ -271,7 +325,7 @@ send_lookup_response (void* cls,
271 /** 325 /**
272 * Get serialized record data size 326 * Get serialized record data size
273 */ 327 */
274 len = attr_record_count * sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData); 328 len = cred_record_count * sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData);
275 329
276 /** 330 /**
277 * Prepare a lookup result response message for the client 331 * Prepare a lookup result response message for the client
@@ -288,12 +342,12 @@ send_lookup_response (void* cls,
288 * Append at the end of rmsg 342 * Append at the end of rmsg
289 */ 343 */
290 i = 0; 344 i = 0;
291 struct GNUNET_CREDENTIAL_AttributeRecordData *tmp_record = (struct GNUNET_CREDENTIAL_AttributeRecordData*) &rmsg[1]; 345 struct GNUNET_CREDENTIAL_CredentialRecordData *tmp_record = (struct GNUNET_CREDENTIAL_CredentialRecordData*) &rmsg[1];
292 for (ar_entry = vrh->attr_chain_head; NULL != ar_entry; ar_entry = ar_entry->next) 346 for (ar_entry = vrh->attr_chain_head; NULL != ar_entry; ar_entry = ar_entry->next)
293 { 347 {
294 memcpy (tmp_record, 348 memcpy (tmp_record,
295 &ar_entry->record_data, 349 &ar_entry->record_data,
296 sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData)); 350 sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData));
297 tmp_record++; 351 tmp_record++;
298 } 352 }
299 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client), 353 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client),
@@ -312,13 +366,13 @@ send_lookup_response (void* cls,
312 "Completed verifications", 1, 366 "Completed verifications", 1,
313 GNUNET_NO); 367 GNUNET_NO);
314 GNUNET_STATISTICS_update (statistics, 368 GNUNET_STATISTICS_update (statistics,
315 "Attributes resolved", 369 "Credentials resolved",
316 rd_count, 370 rd_count,
317 GNUNET_NO); 371 GNUNET_NO);
318} 372}
319 373
320/** 374/**
321 * Handle attribute verification requests from client 375 * Handle Credential verification requests from client
322 * 376 *
323 * @param cls the closure 377 * @param cls the closure
324 * @param client the client 378 * @param client the client
@@ -372,7 +426,7 @@ handle_verify (void *cls,
372 vrh->lookup_request = GNUNET_GNS_lookup (gns, 426 vrh->lookup_request = GNUNET_GNS_lookup (gns,
373 subject_attribute, 427 subject_attribute,
374 &v_msg->subject_key, //subject_pkey, 428 &v_msg->subject_key, //subject_pkey,
375 GNUNET_GNSRECORD_TYPE_ATTRIBUTE, 429 GNUNET_GNSRECORD_TYPE_CREDENTIAL,
376 GNUNET_GNS_LO_DEFAULT, 430 GNUNET_GNS_LO_DEFAULT,
377 NULL, //shorten_key, always NULL 431 NULL, //shorten_key, always NULL
378 &send_lookup_response, 432 &send_lookup_response,