aboutsummaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 19:26:27 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 19:26:27 +0100
commitfcb5ecaede036d2bb89e5123345fd391520c344a (patch)
tree28745989144d41fa0ee0171626092a7c7f8492ee /src/credential
parent646723dd495657a184d1f7e439f4958a72bee1df (diff)
downloadgnunet-fcb5ecaede036d2bb89e5123345fd391520c344a.tar.gz
gnunet-fcb5ecaede036d2bb89e5123345fd391520c344a.zip
-add issue test
Diffstat (limited to 'src/credential')
-rw-r--r--src/credential/credential_api.c2
-rw-r--r--src/credential/gnunet-credential.c28
-rw-r--r--src/credential/plugin_gnsrecord_credential.c56
3 files changed, 43 insertions, 43 deletions
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c
index 8d3c96ca8..88f5f4e17 100644
--- a/src/credential/credential_api.c
+++ b/src/credential/credential_api.c
@@ -433,7 +433,7 @@ GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
433 crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); 433 crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
434 GNUNET_CRYPTO_ecdsa_key_get_public (issuer, 434 GNUNET_CRYPTO_ecdsa_key_get_public (issuer,
435 &crd->issuer_key); 435 &crd->issuer_key);
436 436 crd->subject_key = *subject;
437 GNUNET_memcpy (&crd[1], 437 GNUNET_memcpy (&crd[1],
438 attribute, 438 attribute,
439 strlen (attribute)); 439 strlen (attribute));
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c
index eaad6d5cf..874aa29cb 100644
--- a/src/credential/gnunet-credential.c
+++ b/src/credential/gnunet-credential.c
@@ -180,6 +180,7 @@ identity_cb (void *cls,
180{ 180{
181 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 181 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
182 struct GNUNET_CREDENTIAL_CredentialRecordData *crd; 182 struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
183 char *res;
183 184
184 el = NULL; 185 el = NULL;
185 if (NULL == ego) 186 if (NULL == ego)
@@ -200,10 +201,11 @@ identity_cb (void *cls,
200 privkey, 201 privkey,
201 &subject_pkey, 202 &subject_pkey,
202 issuer_attr); 203 issuer_attr);
203 printf ("Success.\n"); 204 res = GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_CREDENTIAL,
204 printf (GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_CREDENTIAL, 205 crd,
205 crd, 206 sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (issuer_attr) + 1);
206 sizeof (crd) + strlen (issuer_attr) + 1)); 207 printf ("%s\n", res);
208 GNUNET_SCHEDULER_shutdown ();
207} 209}
208 210
209 211
@@ -225,15 +227,6 @@ run (void *cls,
225{ 227{
226 228
227 cfg = c; 229 cfg = c;
228 credential = GNUNET_CREDENTIAL_connect (cfg);
229
230 if (NULL == credential)
231 {
232 fprintf (stderr,
233 _("Failed to connect to CREDENTIAL\n"));
234 return;
235 }
236
237 230
238 231
239 tt = GNUNET_SCHEDULER_add_delayed (timeout, 232 tt = GNUNET_SCHEDULER_add_delayed (timeout,
@@ -281,6 +274,15 @@ run (void *cls,
281 issuer_key); 274 issuer_key);
282 GNUNET_SCHEDULER_shutdown (); 275 GNUNET_SCHEDULER_shutdown ();
283 } 276 }
277 credential = GNUNET_CREDENTIAL_connect (cfg);
278
279 if (NULL == credential)
280 {
281 fprintf (stderr,
282 _("Failed to connect to CREDENTIAL\n"));
283 return;
284 }
285
284 286
285 verify_request = GNUNET_CREDENTIAL_verify(credential, 287 verify_request = GNUNET_CREDENTIAL_verify(credential,
286 &issuer_pkey, 288 &issuer_pkey,
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c
index c7cbb8bdd..67fd32e49 100644
--- a/src/credential/plugin_gnsrecord_credential.c
+++ b/src/credential/plugin_gnsrecord_credential.c
@@ -73,33 +73,31 @@ credential_value_to_string (void *cls,
73 } 73 }
74 case GNUNET_GNSRECORD_TYPE_CREDENTIAL: 74 case GNUNET_GNSRECORD_TYPE_CREDENTIAL:
75 { 75 {
76 struct GNUNET_CREDENTIAL_CredentialRecordData cred; 76 struct GNUNET_CREDENTIAL_CredentialRecordData cred;
77 char *cred_str; 77 char *cred_str;
78 char *subject_pkey; 78 char *subject_pkey;
79 char *issuer_pkey; 79 char *issuer_pkey;
80 if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData)) 80 if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData))
81 return NULL; /* malformed */ 81 return NULL; /* malformed */
82 memcpy (&cred, 82 memcpy (&cred,
83 data, 83 data,
84 sizeof (cred)); 84 sizeof (cred));
85 cdata = data; 85 cdata = data;
86 subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key); 86 subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key);
87 issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key); 87 issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key);
88 88
89 GNUNET_asprintf (&cred_str, 89 GNUNET_asprintf (&cred_str,
90 "%s %s %s", 90 "%s %s %s",
91 subject_pkey, 91 subject_pkey,
92 issuer_pkey, 92 issuer_pkey,
93 &cdata[sizeof (cred)]); 93 &cdata[sizeof (cred)]);
94 GNUNET_free (subject_pkey); 94 GNUNET_free (subject_pkey);
95 GNUNET_free (issuer_pkey); 95 GNUNET_free (issuer_pkey);
96 96
97 97 return cred_str;
98 98 }
99 return cred_str; 99 default:
100 } 100 return NULL;
101 default:
102 return NULL;
103 } 101 }
104} 102}
105 103
@@ -117,10 +115,10 @@ credential_value_to_string (void *cls,
117 */ 115 */
118static int 116static int
119credential_string_to_value (void *cls, 117credential_string_to_value (void *cls,
120 uint32_t type, 118 uint32_t type,
121 const char *s, 119 const char *s,
122 void **data, 120 void **data,
123 size_t *data_size) 121 size_t *data_size)
124{ 122{
125 if (NULL == s) 123 if (NULL == s)
126 return GNUNET_SYSERR; 124 return GNUNET_SYSERR;