aboutsummaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
Diffstat (limited to 'src/credential')
-rw-r--r--src/credential/gnunet-credential.c23
-rw-r--r--src/credential/gnunet-service-credential.c41
-rw-r--r--src/credential/plugin_rest_credential.c16
3 files changed, 14 insertions, 66 deletions
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c
index 82f0e349c..a728939dc 100644
--- a/src/credential/gnunet-credential.c
+++ b/src/credential/gnunet-credential.c
@@ -170,27 +170,18 @@ handle_verify_result (void *cls,
170 { 170 {
171 for (i=0;i<d_count;i++) 171 for (i=0;i<d_count;i++)
172 { 172 {
173 char iss_attr[dc[i].issuer_attribute_len];
174 char* iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key); 173 char* iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key);
175 char* sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key); 174 char* sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
176
177 char sub_attr[dc[i].subject_attribute_len];
178 memcpy (iss_attr,
179 dc[i].issuer_attribute,
180 dc[i].issuer_attribute_len);
181 iss_attr[dc[i].issuer_attribute_len] = '\0';
182 printf ("%s.%s <- ",iss_key, iss_attr);
183 printf ("%s",sub_key);
184 if (0 != dc[i].subject_attribute_len) 175 if (0 != dc[i].subject_attribute_len)
185 { 176 {
186 memcpy (sub_attr, 177 printf ("%s.%s <- %s.%s\n",
187 dc[i].subject_attribute, 178 iss_key, dc[i].issuer_attribute,
188 dc[i].subject_attribute_len); 179 sub_key, dc[i].subject_attribute);
189 sub_attr[dc[i].subject_attribute_len] = '\0'; 180 } else {
190 181 printf ("%s.%s <- %s\n",
191 printf (".%s",sub_attr); 182 iss_key, dc[i].issuer_attribute,
183 sub_key);
192 } 184 }
193 printf ("\n");
194 } 185 }
195 printf ("Successful.\n"); 186 printf ("Successful.\n");
196 } 187 }
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 74e1e1cd2..01b955726 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -457,12 +457,12 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
457 dd[i].issuer_key = dq_entry->delegation_chain_entry->issuer_key; 457 dd[i].issuer_key = dq_entry->delegation_chain_entry->issuer_key;
458 dd[i].subject_key = dq_entry->delegation_chain_entry->subject_key; 458 dd[i].subject_key = dq_entry->delegation_chain_entry->subject_key;
459 dd[i].issuer_attribute = dq_entry->delegation_chain_entry->issuer_attribute; 459 dd[i].issuer_attribute = dq_entry->delegation_chain_entry->issuer_attribute;
460 dd[i].issuer_attribute_len = strlen (dq_entry->delegation_chain_entry->issuer_attribute); 460 dd[i].issuer_attribute_len = strlen (dq_entry->delegation_chain_entry->issuer_attribute)+1;
461 dd[i].subject_attribute_len = 0; 461 dd[i].subject_attribute_len = 0;
462 if (NULL != dq_entry->delegation_chain_entry->subject_attribute) 462 if (NULL != dq_entry->delegation_chain_entry->subject_attribute)
463 { 463 {
464 dd[i].subject_attribute = dq_entry->delegation_chain_entry->subject_attribute; 464 dd[i].subject_attribute = dq_entry->delegation_chain_entry->subject_attribute;
465 dd[i].subject_attribute_len = strlen(dq_entry->delegation_chain_entry->subject_attribute); 465 dd[i].subject_attribute_len = strlen(dq_entry->delegation_chain_entry->subject_attribute)+1;
466 } 466 }
467 dq_entry = dq_entry->parent; 467 dq_entry = dq_entry->parent;
468 } 468 }
@@ -471,7 +471,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
471 * Get serialized record data 471 * Get serialized record data
472 * Append at the end of rmsg 472 * Append at the end of rmsg
473 */ 473 */
474 cred.issuer_key = vrh->credential->issuer_key; 474 cred.issuer_key = vrh->credential->issuer_key;
475 cred.subject_key = vrh->credential->issuer_key; 475 cred.subject_key = vrh->credential->issuer_key;
476 cred.issuer_attribute_len = strlen((char*)&vrh->credential[1]); 476 cred.issuer_attribute_len = strlen((char*)&vrh->credential[1]);
477 cred.issuer_attribute = (char*)&vrh->credential[1]; 477 cred.issuer_attribute = (char*)&vrh->credential[1];
@@ -496,41 +496,6 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
496 size, 496 size,
497 (char*)&rmsg[1])); 497 (char*)&rmsg[1]));
498 498
499
500 /*for (dq_entry = vrh->chain_end; NULL != dq_entry; dq_entry = dq_entry->parent)
501 {
502 if (NULL == dq_entry->delegation_chain_entry)
503 break;
504 size += sizeof (struct GNUNET_CREDENTIAL_DelegationChainEntry);
505 if (NULL != dq_entry->delegation_chain_entry->subject_attribute)
506 size += strlen (dq_entry->delegation_chain_entry->subject_attribute) + 1;
507 size += strlen(dq_entry->delegation_chain_entry->issuer_attribute) + 1;
508 d_count++;
509 }*/
510
511 //TODO refactor into serializer module
512 /*write_ptr = (char*)&rmsg[1] + vrh->credential_size;
513 for (dq_entry = vrh->chain_end; NULL != dq_entry; dq_entry = dq_entry->parent)
514 {
515 if (NULL == dq_entry->delegation_chain_entry)
516 break;
517 memcpy (write_ptr,
518 dq_entry->delegation_chain_entry,
519 sizeof (struct GNUNET_CREDENTIAL_DelegationChainEntry));
520 write_ptr += sizeof (struct GNUNET_CREDENTIAL_DelegationChainEntry);
521 if (NULL != dq_entry->delegation_chain_entry->subject_attribute)
522 {
523 GNUNET_snprintf (write_ptr,
524 strlen (dq_entry->delegation_chain_entry->subject_attribute) + 2,
525 "%s;",
526 dq_entry->delegation_chain_entry->subject_attribute);
527 write_ptr += strlen (dq_entry->delegation_chain_entry->subject_attribute) + 1;
528 }
529 memcpy (write_ptr,
530 dq_entry->delegation_chain_entry->issuer_attribute,
531 strlen(dq_entry->delegation_chain_entry->issuer_attribute));
532 write_ptr += strlen(dq_entry->delegation_chain_entry->issuer_attribute) + 1;
533 }*/
534 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client), 499 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client),
535 env); 500 env);
536 GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); 501 GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh);
diff --git a/src/credential/plugin_rest_credential.c b/src/credential/plugin_rest_credential.c
index 798f76049..cdd0e86e9 100644
--- a/src/credential/plugin_rest_credential.c
+++ b/src/credential/plugin_rest_credential.c
@@ -190,8 +190,6 @@ attribute_delegation_to_json (struct GNUNET_CREDENTIAL_Delegation *delegation_ch
190{ 190{
191 char *subject; 191 char *subject;
192 char *issuer; 192 char *issuer;
193 char iss_attribute[delegation_chain_entry->issuer_attribute_len];
194 char sub_attribute[delegation_chain_entry->subject_attribute_len];
195 json_t *attr_obj; 193 json_t *attr_obj;
196 194
197 issuer = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->issuer_key); 195 issuer = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->issuer_key);
@@ -208,22 +206,16 @@ attribute_delegation_to_json (struct GNUNET_CREDENTIAL_Delegation *delegation_ch
208 return NULL; 206 return NULL;
209 } 207 }
210 attr_obj = json_object (); 208 attr_obj = json_object ();
211 memcpy (iss_attribute,
212 delegation_chain_entry->issuer_attribute,
213 delegation_chain_entry->issuer_attribute_len);
214 iss_attribute[delegation_chain_entry->issuer_attribute_len] = '\0';
215 209
216 json_object_set_new (attr_obj, "subject", json_string (subject)); 210 json_object_set_new (attr_obj, "subject", json_string (subject));
217 json_object_set_new (attr_obj, "issuer", json_string (issuer)); 211 json_object_set_new (attr_obj, "issuer", json_string (issuer));
218 json_object_set_new (attr_obj, "issuer_attribute", json_string (iss_attribute)); 212 json_object_set_new (attr_obj, "issuer_attribute",
213 json_string (delegation_chain_entry->issuer_attribute));
219 214
220 if (0 < delegation_chain_entry->subject_attribute_len) 215 if (0 < delegation_chain_entry->subject_attribute_len)
221 { 216 {
222 memcpy (sub_attribute, 217 json_object_set_new (attr_obj, "subject_attribute",
223 delegation_chain_entry->subject_attribute, 218 json_string (delegation_chain_entry->subject_attribute));
224 delegation_chain_entry->subject_attribute_len);
225 sub_attribute[delegation_chain_entry->subject_attribute_len] = '\0';
226 json_object_set_new (attr_obj, "subject_attribute", json_string (sub_attribute));
227 } 219 }
228 GNUNET_free (subject); 220 GNUNET_free (subject);
229 return attr_obj; 221 return attr_obj;