diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-14 17:35:49 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-14 17:35:49 +0100 |
commit | 745f0dc8f07ef5275f829b13524d6afcc251e58a (patch) | |
tree | 32c8109d341b614fc6841831a111026713db0481 /src | |
parent | 02066879bd7eb841d01e1359021de3bc3aca11e0 (diff) | |
download | gnunet-745f0dc8f07ef5275f829b13524d6afcc251e58a.tar.gz gnunet-745f0dc8f07ef5275f829b13524d6afcc251e58a.zip |
-fixes, prettify
Diffstat (limited to 'src')
-rw-r--r-- | src/credential/credential.h | 7 | ||||
-rw-r--r-- | src/credential/credential_api.c | 10 | ||||
-rw-r--r-- | src/credential/credential_serialization.c | 75 | ||||
-rw-r--r-- | src/credential/credential_serialization.h | 6 | ||||
-rw-r--r-- | src/credential/gnunet-credential.c | 29 | ||||
-rw-r--r-- | src/credential/gnunet-service-credential.c | 82 | ||||
-rw-r--r-- | src/credential/plugin_gnsrecord_credential.c | 15 | ||||
-rw-r--r-- | src/credential/plugin_rest_credential.c | 26 | ||||
-rwxr-xr-x | src/credential/test_credential_verify.sh | 4 | ||||
-rw-r--r-- | src/include/gnunet_credential_service.h | 24 |
10 files changed, 160 insertions, 118 deletions
diff --git a/src/credential/credential.h b/src/credential/credential.h index 209fcdcaa..3ba8e9c9e 100644 --- a/src/credential/credential.h +++ b/src/credential/credential.h | |||
@@ -90,10 +90,15 @@ struct VerifyResultMessage | |||
90 | uint32_t cred_found GNUNET_PACKED; | 90 | uint32_t cred_found GNUNET_PACKED; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * The number of credentials in the response | 93 | * The number of delegations in the response |
94 | */ | 94 | */ |
95 | uint32_t d_count GNUNET_PACKED; | 95 | uint32_t d_count GNUNET_PACKED; |
96 | 96 | ||
97 | /** | ||
98 | * The number of credentials in the response | ||
99 | */ | ||
100 | uint32_t c_count GNUNET_PACKED; | ||
101 | |||
97 | /* followed by ad_count GNUNET_CREDENTIAL_RecordData structs*/ | 102 | /* followed by ad_count GNUNET_CREDENTIAL_RecordData structs*/ |
98 | 103 | ||
99 | }; | 104 | }; |
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index cae670206..860504e61 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c | |||
@@ -216,8 +216,9 @@ handle_result (void *cls, | |||
216 | struct GNUNET_CREDENTIAL_Request *vr; | 216 | struct GNUNET_CREDENTIAL_Request *vr; |
217 | size_t mlen = ntohs (vr_msg->header.size) - sizeof (*vr_msg); | 217 | size_t mlen = ntohs (vr_msg->header.size) - sizeof (*vr_msg); |
218 | uint32_t d_count = ntohl (vr_msg->d_count); | 218 | uint32_t d_count = ntohl (vr_msg->d_count); |
219 | uint32_t c_count = ntohl (vr_msg->c_count); | ||
219 | struct GNUNET_CREDENTIAL_Delegation d_chain[d_count]; | 220 | struct GNUNET_CREDENTIAL_Delegation d_chain[d_count]; |
220 | struct GNUNET_CREDENTIAL_Credential cred; | 221 | struct GNUNET_CREDENTIAL_Credential creds[c_count]; |
221 | GNUNET_CREDENTIAL_VerifyResultProcessor proc; | 222 | GNUNET_CREDENTIAL_VerifyResultProcessor proc; |
222 | void *proc_cls; | 223 | void *proc_cls; |
223 | 224 | ||
@@ -239,18 +240,21 @@ handle_result (void *cls, | |||
239 | (const char*) &vr_msg[1], | 240 | (const char*) &vr_msg[1], |
240 | d_count, | 241 | d_count, |
241 | d_chain, | 242 | d_chain, |
242 | &cred)); | 243 | c_count, |
244 | creds)); | ||
243 | if (GNUNET_NO == ntohl (vr_msg->cred_found)) | 245 | if (GNUNET_NO == ntohl (vr_msg->cred_found)) |
244 | { | 246 | { |
245 | proc (proc_cls, | 247 | proc (proc_cls, |
246 | 0, | 248 | 0, |
247 | NULL, | 249 | NULL, |
250 | 0, | ||
248 | NULL); // TODO | 251 | NULL); // TODO |
249 | } else { | 252 | } else { |
250 | proc (proc_cls, | 253 | proc (proc_cls, |
251 | d_count, | 254 | d_count, |
252 | d_chain, | 255 | d_chain, |
253 | &cred); | 256 | c_count, |
257 | creds); | ||
254 | } | 258 | } |
255 | } | 259 | } |
256 | 260 | ||
diff --git a/src/credential/credential_serialization.c b/src/credential/credential_serialization.c index 99138441e..b08920d96 100644 --- a/src/credential/credential_serialization.c +++ b/src/credential/credential_serialization.c | |||
@@ -184,18 +184,21 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
184 | * | 184 | * |
185 | * @param d_count number of delegation chain entries | 185 | * @param d_count number of delegation chain entries |
186 | * @param dd array of #GNUNET_CREDENTIAL_Delegation | 186 | * @param dd array of #GNUNET_CREDENTIAL_Delegation |
187 | * @param c_count number of credential entries | ||
187 | * @param cd a #GNUNET_CREDENTIAL_Credential | 188 | * @param cd a #GNUNET_CREDENTIAL_Credential |
188 | * @return the required size to serialize | 189 | * @return the required size to serialize |
189 | */ | 190 | */ |
190 | size_t | 191 | size_t |
191 | GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, | 192 | GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, |
192 | const struct GNUNET_CREDENTIAL_Delegation *dd, | 193 | const struct GNUNET_CREDENTIAL_Delegation *dd, |
194 | unsigned int c_count, | ||
193 | const struct GNUNET_CREDENTIAL_Credential *cd) | 195 | const struct GNUNET_CREDENTIAL_Credential *cd) |
194 | { | 196 | { |
195 | unsigned int i; | 197 | unsigned int i; |
196 | size_t ret; | 198 | size_t ret; |
197 | 199 | ||
198 | ret = sizeof (struct ChainEntry) * (d_count + 1); | 200 | ret = sizeof (struct ChainEntry) * (d_count); |
201 | ret += sizeof (struct ChainEntry) * (c_count); | ||
199 | 202 | ||
200 | for (i=0; i<d_count;i++) | 203 | for (i=0; i<d_count;i++) |
201 | { | 204 | { |
@@ -204,8 +207,11 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, | |||
204 | dd[i].subject_attribute_len) >= ret); | 207 | dd[i].subject_attribute_len) >= ret); |
205 | ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len; | 208 | ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len; |
206 | } | 209 | } |
207 | GNUNET_assert ((ret + cd->issuer_attribute_len) >= ret); | 210 | for (i=0; i<c_count;i++) |
208 | ret += cd->issuer_attribute_len; | 211 | { |
212 | GNUNET_assert ((ret + cd[i].issuer_attribute_len) >= ret); | ||
213 | ret += cd[i].issuer_attribute_len; | ||
214 | } | ||
209 | return ret; | 215 | return ret; |
210 | } | 216 | } |
211 | 217 | ||
@@ -214,6 +220,7 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, | |||
214 | * | 220 | * |
215 | * @param d_count number of delegation chain entries | 221 | * @param d_count number of delegation chain entries |
216 | * @param dd array of #GNUNET_CREDENTIAL_Delegation | 222 | * @param dd array of #GNUNET_CREDENTIAL_Delegation |
223 | * @param c_count number of credential entries | ||
217 | * @param cd a #GNUNET_CREDENTIAL_Credential | 224 | * @param cd a #GNUNET_CREDENTIAL_Credential |
218 | * @param dest_size size of the destination | 225 | * @param dest_size size of the destination |
219 | * @param dest where to store the result | 226 | * @param dest where to store the result |
@@ -222,6 +229,7 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, | |||
222 | ssize_t | 229 | ssize_t |
223 | GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, | 230 | GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, |
224 | const struct GNUNET_CREDENTIAL_Delegation *dd, | 231 | const struct GNUNET_CREDENTIAL_Delegation *dd, |
232 | unsigned int c_count, | ||
225 | const struct GNUNET_CREDENTIAL_Credential *cd, | 233 | const struct GNUNET_CREDENTIAL_Credential *cd, |
226 | size_t dest_size, | 234 | size_t dest_size, |
227 | char *dest) | 235 | char *dest) |
@@ -258,21 +266,25 @@ GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, | |||
258 | dd[i].subject_attribute_len); | 266 | dd[i].subject_attribute_len); |
259 | off += dd[i].subject_attribute_len; | 267 | off += dd[i].subject_attribute_len; |
260 | } | 268 | } |
261 | rec.issuer_attribute_len = htonl ((uint32_t) cd->issuer_attribute_len); | 269 | for (i=0;i<c_count;i++) |
262 | rec.subject_attribute_len = htonl (0); | 270 | { |
263 | rec.issuer_key = cd->issuer_key; | 271 | rec.issuer_attribute_len = htonl ((uint32_t) cd[i].issuer_attribute_len); |
264 | if (off + sizeof (rec) > dest_size) | 272 | rec.subject_attribute_len = htonl (0); |
265 | return -1; | 273 | rec.issuer_key = cd[i].issuer_key; |
266 | GNUNET_memcpy (&dest[off], | 274 | rec.subject_key = cd[i].subject_key; |
267 | &rec, | 275 | if (off + sizeof (rec) > dest_size) |
268 | sizeof (rec)); | 276 | return -1; |
269 | off += sizeof (rec); | 277 | GNUNET_memcpy (&dest[off], |
270 | if (off + cd->issuer_attribute_len > dest_size) | 278 | &rec, |
271 | return -1; | 279 | sizeof (rec)); |
272 | GNUNET_memcpy (&dest[off], | 280 | off += sizeof (rec); |
273 | cd->issuer_attribute, | 281 | if (off + cd[i].issuer_attribute_len > dest_size) |
274 | cd->issuer_attribute_len); | 282 | return -1; |
275 | off += cd->issuer_attribute_len; | 283 | GNUNET_memcpy (&dest[off], |
284 | cd[i].issuer_attribute, | ||
285 | cd[i].issuer_attribute_len); | ||
286 | off += cd[i].issuer_attribute_len; | ||
287 | } | ||
276 | 288 | ||
277 | return off; | 289 | return off; |
278 | } | 290 | } |
@@ -285,6 +297,7 @@ GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, | |||
285 | * @param src the serialized data | 297 | * @param src the serialized data |
286 | * @param d_count the number of delegation chain entries | 298 | * @param d_count the number of delegation chain entries |
287 | * @param dd where to put the delegation chain entries | 299 | * @param dd where to put the delegation chain entries |
300 | * @param c_count the number of credential entries | ||
288 | * @param cd where to put the credential data | 301 | * @param cd where to put the credential data |
289 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 302 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
290 | */ | 303 | */ |
@@ -293,6 +306,7 @@ GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len, | |||
293 | const char *src, | 306 | const char *src, |
294 | unsigned int d_count, | 307 | unsigned int d_count, |
295 | struct GNUNET_CREDENTIAL_Delegation *dd, | 308 | struct GNUNET_CREDENTIAL_Delegation *dd, |
309 | unsigned int c_count, | ||
296 | struct GNUNET_CREDENTIAL_Credential *cd) | 310 | struct GNUNET_CREDENTIAL_Credential *cd) |
297 | { | 311 | { |
298 | struct ChainEntry rec; | 312 | struct ChainEntry rec; |
@@ -319,17 +333,20 @@ GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len, | |||
319 | dd[i].subject_attribute = &src[off]; | 333 | dd[i].subject_attribute = &src[off]; |
320 | off += dd[i].subject_attribute_len; | 334 | off += dd[i].subject_attribute_len; |
321 | } | 335 | } |
322 | if (off + sizeof (rec) > len) | 336 | for (i=0;i<c_count;i++) |
323 | return GNUNET_SYSERR; | 337 | { |
324 | GNUNET_memcpy (&rec, &src[off], sizeof (rec)); | 338 | if (off + sizeof (rec) > len) |
325 | cd->issuer_attribute_len = ntohl ((uint32_t) rec.issuer_attribute_len); | 339 | return GNUNET_SYSERR; |
326 | cd->issuer_key = rec.issuer_key; | 340 | GNUNET_memcpy (&rec, &src[off], sizeof (rec)); |
327 | cd->subject_key = rec.subject_key; | 341 | cd[i].issuer_attribute_len = ntohl ((uint32_t) rec.issuer_attribute_len); |
328 | off += sizeof (rec); | 342 | cd[i].issuer_key = rec.issuer_key; |
329 | if (off + cd->issuer_attribute_len > len) | 343 | cd[i].subject_key = rec.subject_key; |
330 | return GNUNET_SYSERR; | 344 | off += sizeof (rec); |
331 | cd->issuer_attribute = &src[off]; | 345 | if (off + cd[i].issuer_attribute_len > len) |
332 | off += cd->issuer_attribute_len; | 346 | return GNUNET_SYSERR; |
347 | cd[i].issuer_attribute = &src[off]; | ||
348 | off += cd[i].issuer_attribute_len; | ||
349 | } | ||
333 | return GNUNET_OK; | 350 | return GNUNET_OK; |
334 | } | 351 | } |
335 | 352 | ||
diff --git a/src/credential/credential_serialization.h b/src/credential/credential_serialization.h index 7f6d0dda9..39ac0103b 100644 --- a/src/credential/credential_serialization.h +++ b/src/credential/credential_serialization.h | |||
@@ -79,12 +79,14 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
79 | * | 79 | * |
80 | * @param d_count number of delegation chain entries | 80 | * @param d_count number of delegation chain entries |
81 | * @param dd array of #GNUNET_CREDENTIAL_Delegation | 81 | * @param dd array of #GNUNET_CREDENTIAL_Delegation |
82 | * @param c_count number of credential entries | ||
82 | * @param cd a #GNUNET_CREDENTIAL_Credential | 83 | * @param cd a #GNUNET_CREDENTIAL_Credential |
83 | * @return the required size to serialize | 84 | * @return the required size to serialize |
84 | */ | 85 | */ |
85 | size_t | 86 | size_t |
86 | GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, | 87 | GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, |
87 | const struct GNUNET_CREDENTIAL_Delegation *dd, | 88 | const struct GNUNET_CREDENTIAL_Delegation *dd, |
89 | unsigned int c_count, | ||
88 | const struct GNUNET_CREDENTIAL_Credential *cd); | 90 | const struct GNUNET_CREDENTIAL_Credential *cd); |
89 | 91 | ||
90 | /** | 92 | /** |
@@ -92,6 +94,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
92 | * | 94 | * |
93 | * @param d_count number of delegation chain entries | 95 | * @param d_count number of delegation chain entries |
94 | * @param dd array of #GNUNET_CREDENTIAL_Delegation | 96 | * @param dd array of #GNUNET_CREDENTIAL_Delegation |
97 | * @param c_count number of credential entries | ||
95 | * @param cd a #GNUNET_CREDENTIAL_Credential | 98 | * @param cd a #GNUNET_CREDENTIAL_Credential |
96 | * @param dest_size size of the destination | 99 | * @param dest_size size of the destination |
97 | * @param dest where to store the result | 100 | * @param dest where to store the result |
@@ -100,6 +103,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
100 | ssize_t | 103 | ssize_t |
101 | GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, | 104 | GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, |
102 | const struct GNUNET_CREDENTIAL_Delegation *dd, | 105 | const struct GNUNET_CREDENTIAL_Delegation *dd, |
106 | unsigned int c_count, | ||
103 | const struct GNUNET_CREDENTIAL_Credential *cd, | 107 | const struct GNUNET_CREDENTIAL_Credential *cd, |
104 | size_t dest_size, | 108 | size_t dest_size, |
105 | char *dest); | 109 | char *dest); |
@@ -112,6 +116,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
112 | * @param src the serialized data | 116 | * @param src the serialized data |
113 | * @param d_count the number of delegation chain entries | 117 | * @param d_count the number of delegation chain entries |
114 | * @param dd where to put the delegation chain entries | 118 | * @param dd where to put the delegation chain entries |
119 | * @param c_count number of credential entries | ||
115 | * @param cd where to put the credential data | 120 | * @param cd where to put the credential data |
116 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 121 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
117 | */ | 122 | */ |
@@ -120,5 +125,6 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | |||
120 | const char *src, | 125 | const char *src, |
121 | unsigned int d_count, | 126 | unsigned int d_count, |
122 | struct GNUNET_CREDENTIAL_Delegation *dd, | 127 | struct GNUNET_CREDENTIAL_Delegation *dd, |
128 | unsigned int c_count, | ||
123 | struct GNUNET_CREDENTIAL_Credential *cd); | 129 | struct GNUNET_CREDENTIAL_Credential *cd); |
124 | /* end of credential_serialization.h */ | 130 | /* end of credential_serialization.h */ |
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c index 41b17ef66..a743458d5 100644 --- a/src/credential/gnunet-credential.c +++ b/src/credential/gnunet-credential.c | |||
@@ -159,6 +159,7 @@ static void | |||
159 | handle_verify_result (void *cls, | 159 | handle_verify_result (void *cls, |
160 | unsigned int d_count, | 160 | unsigned int d_count, |
161 | struct GNUNET_CREDENTIAL_Delegation *dc, | 161 | struct GNUNET_CREDENTIAL_Delegation *dc, |
162 | unsigned int c_count, | ||
162 | struct GNUNET_CREDENTIAL_Credential *cred) | 163 | struct GNUNET_CREDENTIAL_Credential *cred) |
163 | { | 164 | { |
164 | int i; | 165 | int i; |
@@ -170,30 +171,36 @@ handle_verify_result (void *cls, | |||
170 | printf ("Failed.\n"); | 171 | printf ("Failed.\n"); |
171 | else | 172 | else |
172 | { | 173 | { |
173 | iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->issuer_key); | 174 | printf("Delegation Chain:\n"); |
174 | sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key); | ||
175 | printf ("(0) %s.%s <- %s (Subject)\n", | ||
176 | iss_key, cred->issuer_attribute, | ||
177 | sub_key); | ||
178 | GNUNET_free (iss_key); | ||
179 | GNUNET_free (sub_key); | ||
180 | for (i=0;i<d_count;i++) | 175 | for (i=0;i<d_count;i++) |
181 | { | 176 | { |
182 | iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key); | 177 | iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key); |
183 | sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key); | 178 | sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key); |
184 | if (0 != dc[i].subject_attribute_len) | 179 | if (0 != dc[i].subject_attribute_len) |
185 | { | 180 | { |
186 | printf ("(%d) %s.%s <- %s.%s\n", i+1, | 181 | printf ("(%d) %s.%s <- %s.%s\n", i, |
187 | iss_key, dc[i].issuer_attribute, | 182 | iss_key, dc[i].issuer_attribute, |
188 | sub_key, dc[i].subject_attribute); | 183 | sub_key, dc[i].subject_attribute); |
189 | } else { | 184 | } else { |
190 | printf ("(%d) %s.%s <- %s\n", i+1, | 185 | printf ("(%d) %s.%s <- %s\n", i, |
191 | iss_key, dc[i].issuer_attribute, | 186 | iss_key, dc[i].issuer_attribute, |
192 | sub_key); | 187 | sub_key); |
193 | } | 188 | } |
194 | GNUNET_free (iss_key); | 189 | GNUNET_free (iss_key); |
195 | GNUNET_free (sub_key); | 190 | GNUNET_free (sub_key); |
196 | } | 191 | } |
192 | printf("\nCredentials:\n"); | ||
193 | for (i=0;i<c_count;i++) | ||
194 | { | ||
195 | iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].issuer_key); | ||
196 | sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].subject_key); | ||
197 | printf ("%s.%s <- %s\n", | ||
198 | iss_key, cred[i].issuer_attribute, | ||
199 | sub_key); | ||
200 | GNUNET_free (iss_key); | ||
201 | GNUNET_free (sub_key); | ||
202 | |||
203 | } | ||
197 | printf ("Successful.\n"); | 204 | printf ("Successful.\n"); |
198 | } | 205 | } |
199 | 206 | ||
@@ -347,7 +354,9 @@ run (void *cls, | |||
347 | _("You must provide issuer and subject attributes\n")); | 354 | _("You must provide issuer and subject attributes\n")); |
348 | GNUNET_SCHEDULER_shutdown (); | 355 | GNUNET_SCHEDULER_shutdown (); |
349 | } | 356 | } |
350 | 357 | ||
358 | printf ("Trying to find a chain from a credential under %s of %s to the attribute %s issued by %s\n", | ||
359 | subject_credential, subject_key, issuer_attr, issuer_key); | ||
351 | 360 | ||
352 | verify_request = GNUNET_CREDENTIAL_verify(credential, | 361 | verify_request = GNUNET_CREDENTIAL_verify(credential, |
353 | &issuer_pkey, | 362 | &issuer_pkey, |
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index 8843abfd6..2b3eb8b4c 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c | |||
@@ -282,16 +282,21 @@ struct VerifyRequestHandle | |||
282 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; | 282 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; |
283 | 283 | ||
284 | /** | 284 | /** |
285 | * Credential Chain | 285 | * Credential DLL |
286 | */ | 286 | */ |
287 | struct CredentialRecordEntry *cred_chain_head; | 287 | struct CredentialRecordEntry *cred_chain_head; |
288 | 288 | ||
289 | /** | 289 | /** |
290 | * Credential Chain | 290 | * Credential DLL |
291 | */ | 291 | */ |
292 | struct CredentialRecordEntry *cred_chain_tail; | 292 | struct CredentialRecordEntry *cred_chain_tail; |
293 | 293 | ||
294 | /** | 294 | /** |
295 | * Credential DLL size | ||
296 | */ | ||
297 | uint32_t cred_chain_size; | ||
298 | |||
299 | /** | ||
295 | * Root Delegation Set | 300 | * Root Delegation Set |
296 | */ | 301 | */ |
297 | struct DelegationSetEntry *root_set; | 302 | struct DelegationSetEntry *root_set; |
@@ -402,7 +407,7 @@ static void | |||
402 | cleanup_handle (struct VerifyRequestHandle *vrh) | 407 | cleanup_handle (struct VerifyRequestHandle *vrh) |
403 | { | 408 | { |
404 | struct CredentialRecordEntry *cr_entry; | 409 | struct CredentialRecordEntry *cr_entry; |
405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
406 | "Cleaning up...\n"); | 411 | "Cleaning up...\n"); |
407 | if (NULL != vrh->lookup_request) | 412 | if (NULL != vrh->lookup_request) |
408 | { | 413 | { |
@@ -439,7 +444,7 @@ shutdown_task (void *cls) | |||
439 | { | 444 | { |
440 | struct VerifyRequestHandle *vrh; | 445 | struct VerifyRequestHandle *vrh; |
441 | 446 | ||
442 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
443 | "Shutting down!\n"); | 448 | "Shutting down!\n"); |
444 | 449 | ||
445 | while (NULL != (vrh = vrh_head)) | 450 | while (NULL != (vrh = vrh_head)) |
@@ -515,10 +520,12 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
515 | struct DelegationChainEntry *dce; | 520 | struct DelegationChainEntry *dce; |
516 | size_t size = vrh->credential_size; | 521 | size_t size = vrh->credential_size; |
517 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; | 522 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; |
518 | struct GNUNET_CREDENTIAL_Credential cred; | 523 | struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size]; |
524 | struct GNUNET_CREDENTIAL_CredentialRecordData *crd; | ||
525 | struct CredentialRecordEntry *cd; | ||
519 | int i; | 526 | int i; |
520 | 527 | ||
521 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 528 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
522 | "Sending response\n"); | 529 | "Sending response\n"); |
523 | i = 0; | 530 | i = 0; |
524 | for (dce = vrh->delegation_chain_head; | 531 | for (dce = vrh->delegation_chain_head; |
@@ -542,21 +549,29 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
542 | * Get serialized record data | 549 | * Get serialized record data |
543 | * Append at the end of rmsg | 550 | * Append at the end of rmsg |
544 | */ | 551 | */ |
545 | cred.issuer_key = vrh->credential->issuer_key; | 552 | i = 0; |
546 | cred.subject_key = vrh->credential->subject_key; | 553 | for (cd = vrh->cred_chain_head; |
547 | cred.issuer_attribute_len = strlen((char*)&vrh->credential[1])+1; | 554 | NULL != cd; |
548 | cred.issuer_attribute = (char*)&vrh->credential[1]; | 555 | cd = cd->next) |
556 | { | ||
557 | crd = cd->data; | ||
558 | cred[i].issuer_key = crd->issuer_key; | ||
559 | cred[i].subject_key = crd->subject_key; | ||
560 | cred[i].issuer_attribute_len = strlen((char*)&crd[1])+1; | ||
561 | cred[i].issuer_attribute = (char*)&crd[1]; | ||
562 | i++; | ||
563 | } | ||
549 | size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size, | 564 | size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size, |
550 | dd, | 565 | dd, |
551 | &cred); | 566 | vrh->cred_chain_size, |
552 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 567 | cred); |
553 | "SIZE; %llu count: %d\n",size,vrh->delegation_chain_size); | ||
554 | env = GNUNET_MQ_msg_extra (rmsg, | 568 | env = GNUNET_MQ_msg_extra (rmsg, |
555 | size, | 569 | size, |
556 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT); | 570 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT); |
557 | //Assign id so that client can find associated request | 571 | //Assign id so that client can find associated request |
558 | rmsg->id = vrh->request_id; | 572 | rmsg->id = vrh->request_id; |
559 | rmsg->d_count = htonl (vrh->delegation_chain_size); | 573 | rmsg->d_count = htonl (vrh->delegation_chain_size); |
574 | rmsg->c_count = htonl (vrh->cred_chain_size); | ||
560 | 575 | ||
561 | if (NULL != vrh->credential) | 576 | if (NULL != vrh->credential) |
562 | rmsg->cred_found = htonl (GNUNET_YES); | 577 | rmsg->cred_found = htonl (GNUNET_YES); |
@@ -566,7 +581,8 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
566 | GNUNET_assert (-1 != | 581 | GNUNET_assert (-1 != |
567 | GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, | 582 | GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, |
568 | dd, | 583 | dd, |
569 | &cred, | 584 | vrh->cred_chain_size, |
585 | cred, | ||
570 | size, | 586 | size, |
571 | (char*)&rmsg[1])); | 587 | (char*)&rmsg[1])); |
572 | 588 | ||
@@ -605,7 +621,7 @@ backward_resolution (void* cls, | |||
605 | current_set->lookup_request = NULL; | 621 | current_set->lookup_request = NULL; |
606 | vrh = current_set->handle; | 622 | vrh = current_set->handle; |
607 | vrh->pending_lookups--; | 623 | vrh->pending_lookups--; |
608 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
609 | "Got %d attrs\n", rd_count); | 625 | "Got %d attrs\n", rd_count); |
610 | 626 | ||
611 | // Each OR | 627 | // Each OR |
@@ -616,7 +632,7 @@ backward_resolution (void* cls, | |||
616 | 632 | ||
617 | sets = rd[i].data; | 633 | sets = rd[i].data; |
618 | struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets->set_count)]; | 634 | struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets->set_count)]; |
619 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 635 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
620 | "Found new attribute delegation with %d sets. Creating new Job...\n", | 636 | "Found new attribute delegation with %d sets. Creating new Job...\n", |
621 | ntohl (sets->set_count)); | 637 | ntohl (sets->set_count)); |
622 | 638 | ||
@@ -653,13 +669,13 @@ backward_resolution (void* cls, | |||
653 | set[j].subject_attribute, | 669 | set[j].subject_attribute, |
654 | current_set->attr_trailer); | 670 | current_set->attr_trailer); |
655 | } | 671 | } |
656 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 672 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
657 | "Expanded to %s\n", expanded_attr); | 673 | "Expanded to %s\n", expanded_attr); |
658 | ds_entry->unresolved_attribute_delegation = expanded_attr; | 674 | ds_entry->unresolved_attribute_delegation = expanded_attr; |
659 | } else { | 675 | } else { |
660 | if (0 != set[j].subject_attribute_len) | 676 | if (0 != set[j].subject_attribute_len) |
661 | { | 677 | { |
662 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
663 | "Not Expanding %s\n", set[j].subject_attribute); | 679 | "Not Expanding %s\n", set[j].subject_attribute); |
664 | ds_entry->unresolved_attribute_delegation = GNUNET_strdup (set[j].subject_attribute); | 680 | ds_entry->unresolved_attribute_delegation = GNUNET_strdup (set[j].subject_attribute); |
665 | } | 681 | } |
@@ -682,7 +698,7 @@ backward_resolution (void* cls, | |||
682 | dq_entry->set_entries_tail, | 698 | dq_entry->set_entries_tail, |
683 | ds_entry); | 699 | ds_entry); |
684 | 700 | ||
685 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 701 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
686 | "Checking for cred match\n"); | 702 | "Checking for cred match\n"); |
687 | /** | 703 | /** |
688 | * Check if this delegation already matches one of our credentials | 704 | * Check if this delegation already matches one of our credentials |
@@ -695,14 +711,14 @@ backward_resolution (void* cls, | |||
695 | &cred_pointer->data->issuer_key, | 711 | &cred_pointer->data->issuer_key, |
696 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) | 712 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) |
697 | continue; | 713 | continue; |
698 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 714 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
699 | "Checking if %s matches %s\n", | 715 | "Checking if %s matches %s\n", |
700 | ds_entry->unresolved_attribute_delegation, (char*)&cred[1]); | 716 | ds_entry->unresolved_attribute_delegation, (char*)&cred[1]); |
701 | 717 | ||
702 | if (0 != strcmp (ds_entry->unresolved_attribute_delegation, (char*)&cred[1])) | 718 | if (0 != strcmp (ds_entry->unresolved_attribute_delegation, (char*)&cred[1])) |
703 | continue; | 719 | continue; |
704 | 720 | ||
705 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
706 | "Found issuer\n"); | 722 | "Found issuer\n"); |
707 | 723 | ||
708 | //Backtrack | 724 | //Backtrack |
@@ -724,7 +740,7 @@ backward_resolution (void* cls, | |||
724 | 740 | ||
725 | if (NULL == tmp_set->parent_queue_entry) | 741 | if (NULL == tmp_set->parent_queue_entry) |
726 | { | 742 | { |
727 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
728 | "All solutions found\n"); | 744 | "All solutions found\n"); |
729 | vrh->credential = GNUNET_malloc (cred_pointer->data_size); | 745 | vrh->credential = GNUNET_malloc (cred_pointer->data_size); |
730 | memcpy (vrh->credential, | 746 | memcpy (vrh->credential, |
@@ -735,9 +751,12 @@ backward_resolution (void* cls, | |||
735 | send_lookup_response (vrh); | 751 | send_lookup_response (vrh); |
736 | return; | 752 | return; |
737 | } | 753 | } |
754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
755 | "Not all solutions found yet.\n"); | ||
756 | continue; | ||
738 | 757 | ||
739 | } | 758 | } |
740 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 759 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
741 | "Building new lookup request from %s\n", | 760 | "Building new lookup request from %s\n", |
742 | ds_entry->unresolved_attribute_delegation); | 761 | ds_entry->unresolved_attribute_delegation); |
743 | //Continue with backward resolution | 762 | //Continue with backward resolution |
@@ -759,10 +778,10 @@ backward_resolution (void* cls, | |||
759 | ds_entry->attr_trailer = GNUNET_strdup (next_attr); | 778 | ds_entry->attr_trailer = GNUNET_strdup (next_attr); |
760 | } | 779 | } |
761 | 780 | ||
762 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 781 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
763 | "Looking up %s\n", ds_entry->lookup_attribute); | 782 | "Looking up %s\n", ds_entry->lookup_attribute); |
764 | if (NULL != ds_entry->attr_trailer) | 783 | if (NULL != ds_entry->attr_trailer) |
765 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
766 | "%s still to go...\n", ds_entry->attr_trailer); | 785 | "%s still to go...\n", ds_entry->attr_trailer); |
767 | 786 | ||
768 | vrh->pending_lookups++; | 787 | vrh->pending_lookups++; |
@@ -781,7 +800,7 @@ backward_resolution (void* cls, | |||
781 | 800 | ||
782 | if(0 == vrh->pending_lookups) | 801 | if(0 == vrh->pending_lookups) |
783 | { | 802 | { |
784 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
785 | "We are all out of attributes...\n"); | 804 | "We are all out of attributes...\n"); |
786 | send_lookup_response (vrh); | 805 | send_lookup_response (vrh); |
787 | return; | 806 | return; |
@@ -835,6 +854,7 @@ handle_credential_query (void* cls, | |||
835 | GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head, | 854 | GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head, |
836 | vrh->cred_chain_tail, | 855 | vrh->cred_chain_tail, |
837 | cr_entry); | 856 | cr_entry); |
857 | vrh->cred_chain_size++; | ||
838 | 858 | ||
839 | if (0 != memcmp (&crd->issuer_key, | 859 | if (0 != memcmp (&crd->issuer_key, |
840 | &vrh->issuer_key, | 860 | &vrh->issuer_key, |
@@ -862,7 +882,7 @@ handle_credential_query (void* cls, | |||
862 | vrh->issuer_attribute); | 882 | vrh->issuer_attribute); |
863 | strcpy (issuer_attribute_name + strlen (vrh->issuer_attribute), | 883 | strcpy (issuer_attribute_name + strlen (vrh->issuer_attribute), |
864 | ".gnu"); | 884 | ".gnu"); |
865 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
866 | "Looking up %s\n", issuer_attribute_name); | 886 | "Looking up %s\n", issuer_attribute_name); |
867 | ds_entry = GNUNET_new (struct DelegationSetEntry); | 887 | ds_entry = GNUNET_new (struct DelegationSetEntry); |
868 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | 888 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); |
@@ -905,7 +925,7 @@ handle_verify (void *cls, | |||
905 | char *attrptr = attrs; | 925 | char *attrptr = attrs; |
906 | const char *utf_in; | 926 | const char *utf_in; |
907 | 927 | ||
908 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 928 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
909 | "Received VERIFY message\n"); | 929 | "Received VERIFY message\n"); |
910 | 930 | ||
911 | utf_in = (const char *) &v_msg[1]; | 931 | utf_in = (const char *) &v_msg[1]; |
@@ -939,7 +959,7 @@ handle_verify (void *cls, | |||
939 | send_lookup_response (vrh); | 959 | send_lookup_response (vrh); |
940 | return; | 960 | return; |
941 | } | 961 | } |
942 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 962 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
943 | "Looking up %s\n", | 963 | "Looking up %s\n", |
944 | subject_attribute); | 964 | subject_attribute); |
945 | /** | 965 | /** |
@@ -967,7 +987,7 @@ client_disconnect_cb (void *cls, | |||
967 | struct GNUNET_SERVICE_Client *client, | 987 | struct GNUNET_SERVICE_Client *client, |
968 | void *app_ctx) | 988 | void *app_ctx) |
969 | { | 989 | { |
970 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 990 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
971 | "Client %p disconnected\n", | 991 | "Client %p disconnected\n", |
972 | client); | 992 | client); |
973 | } | 993 | } |
@@ -985,7 +1005,7 @@ client_connect_cb (void *cls, | |||
985 | struct GNUNET_SERVICE_Client *client, | 1005 | struct GNUNET_SERVICE_Client *client, |
986 | struct GNUNET_MQ_Handle *mq) | 1006 | struct GNUNET_MQ_Handle *mq) |
987 | { | 1007 | { |
988 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1008 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
989 | "Client %p connected\n", | 1009 | "Client %p connected\n", |
990 | client); | 1010 | client); |
991 | return client; | 1011 | return client; |
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c index d21185981..1358afdb1 100644 --- a/src/credential/plugin_gnsrecord_credential.c +++ b/src/credential/plugin_gnsrecord_credential.c | |||
@@ -65,12 +65,6 @@ credential_value_to_string (void *cls, | |||
65 | memcpy (&sets, | 65 | memcpy (&sets, |
66 | data, | 66 | data, |
67 | sizeof (sets)); | 67 | sizeof (sets)); |
68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
69 | "SIZE %llu needed: %llu + %llu\n", | ||
70 | data_size, | ||
71 | GNUNET_ntohll (sets.data_size), | ||
72 | sizeof (sets)); | ||
73 | |||
74 | cdata = data; | 68 | cdata = data; |
75 | struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets.set_count)]; | 69 | struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets.set_count)]; |
76 | if (GNUNET_OK != GNUNET_CREDENTIAL_delegation_set_deserialize (GNUNET_ntohll (sets.data_size), | 70 | if (GNUNET_OK != GNUNET_CREDENTIAL_delegation_set_deserialize (GNUNET_ntohll (sets.data_size), |
@@ -238,15 +232,8 @@ credential_string_to_value (void *cls, | |||
238 | strlen (subject_pkey), | 232 | strlen (subject_pkey), |
239 | &set[i].subject_key); | 233 | &set[i].subject_key); |
240 | if (2 == matches) { | 234 | if (2 == matches) { |
241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
242 | "Adding %s (data size %llu)\n", | ||
243 | attr_str, | ||
244 | tmp_data_size); | ||
245 | /*GNUNET_memcpy (&set[1], | ||
246 | attr_str, | ||
247 | strlen (attr_str)+1);*/ | ||
248 | set[i].subject_attribute_len = strlen (attr_str) + 1; | 235 | set[i].subject_attribute_len = strlen (attr_str) + 1; |
249 | set[i].subject_attribute = GNUNET_strdup (attr_str);//(const char*)&set[1]; | 236 | set[i].subject_attribute = GNUNET_strdup (attr_str); |
250 | } | 237 | } |
251 | token = strtok (NULL , ","); | 238 | token = strtok (NULL , ","); |
252 | } | 239 | } |
diff --git a/src/credential/plugin_rest_credential.c b/src/credential/plugin_rest_credential.c index cdd0e86e9..f6e4fc5a8 100644 --- a/src/credential/plugin_rest_credential.c +++ b/src/credential/plugin_rest_credential.c | |||
@@ -41,7 +41,7 @@ | |||
41 | 41 | ||
42 | #define GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO "credential" | 42 | #define GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO "credential" |
43 | 43 | ||
44 | #define GNUNET_REST_JSONAPI_CREDENTIAL_CHAIN "chain" | 44 | #define GNUNET_REST_JSONAPI_DELEGATIONS "delegations" |
45 | 45 | ||
46 | #define GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR "attribute" | 46 | #define GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR "attribute" |
47 | 47 | ||
@@ -273,6 +273,7 @@ static void | |||
273 | handle_verify_response (void *cls, | 273 | handle_verify_response (void *cls, |
274 | unsigned int d_count, | 274 | unsigned int d_count, |
275 | struct GNUNET_CREDENTIAL_Delegation *delegation_chain, | 275 | struct GNUNET_CREDENTIAL_Delegation *delegation_chain, |
276 | unsigned int c_count, | ||
276 | struct GNUNET_CREDENTIAL_Credential *cred) | 277 | struct GNUNET_CREDENTIAL_Credential *cred) |
277 | { | 278 | { |
278 | 279 | ||
@@ -282,7 +283,8 @@ handle_verify_response (void *cls, | |||
282 | struct GNUNET_JSONAPI_Resource *json_resource; | 283 | struct GNUNET_JSONAPI_Resource *json_resource; |
283 | json_t *cred_obj; | 284 | json_t *cred_obj; |
284 | json_t *attr_obj; | 285 | json_t *attr_obj; |
285 | json_t *result_array; | 286 | json_t *cred_array; |
287 | json_t *attr_array; | ||
286 | char *result; | 288 | char *result; |
287 | uint32_t i; | 289 | uint32_t i; |
288 | 290 | ||
@@ -298,25 +300,33 @@ handle_verify_response (void *cls, | |||
298 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO, | 300 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO, |
299 | handle->issuer_attr); | 301 | handle->issuer_attr); |
300 | cred_obj = credential_to_json (cred); | 302 | cred_obj = credential_to_json (cred); |
301 | result_array = json_array (); | 303 | attr_array = json_array (); |
302 | for (i = 0; i < d_count; i++) | 304 | for (i = 0; i < d_count; i++) |
303 | { | 305 | { |
304 | attr_obj = attribute_delegation_to_json (&delegation_chain[i]); | 306 | attr_obj = attribute_delegation_to_json (&delegation_chain[i]); |
305 | json_array_append (result_array, attr_obj); | 307 | json_array_append (attr_array, attr_obj); |
306 | json_decref (attr_obj); | 308 | json_decref (attr_obj); |
307 | } | 309 | } |
310 | cred_array = json_array (); | ||
311 | for (i=0;i<c_count;i++) | ||
312 | { | ||
313 | cred_obj = credential_to_json (&cred[i]); | ||
314 | json_array_append (cred_array, cred_obj); | ||
315 | json_decref (cred_obj); | ||
316 | } | ||
308 | GNUNET_JSONAPI_resource_add_attr (json_resource, | 317 | GNUNET_JSONAPI_resource_add_attr (json_resource, |
309 | GNUNET_REST_JSONAPI_CREDENTIAL, | 318 | GNUNET_REST_JSONAPI_CREDENTIAL, |
310 | cred_obj); | 319 | cred_array); |
311 | GNUNET_JSONAPI_resource_add_attr (json_resource, | 320 | GNUNET_JSONAPI_resource_add_attr (json_resource, |
312 | GNUNET_REST_JSONAPI_CREDENTIAL_CHAIN, | 321 | GNUNET_REST_JSONAPI_DELEGATIONS, |
313 | result_array); | 322 | attr_array); |
314 | GNUNET_JSONAPI_document_resource_add (json_document, json_resource); | 323 | GNUNET_JSONAPI_document_resource_add (json_document, json_resource); |
315 | GNUNET_JSONAPI_document_serialize (json_document, &result); | 324 | GNUNET_JSONAPI_document_serialize (json_document, &result); |
316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
317 | "Result %s\n", | 326 | "Result %s\n", |
318 | result); | 327 | result); |
319 | json_decref (result_array); | 328 | json_decref (attr_array); |
329 | json_decref (cred_array); | ||
320 | GNUNET_JSONAPI_document_delete (json_document); | 330 | GNUNET_JSONAPI_document_delete (json_document); |
321 | resp = GNUNET_REST_create_response (result); | 331 | resp = GNUNET_REST_create_response (result); |
322 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 332 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
diff --git a/src/credential/test_credential_verify.sh b/src/credential/test_credential_verify.sh index 52a4fd2fc..6d69e337b 100755 --- a/src/credential/test_credential_verify.sh +++ b/src/credential/test_credential_verify.sh | |||
@@ -23,7 +23,7 @@ rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | |||
23 | 23 | ||
24 | 24 | ||
25 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 25 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" |
26 | #gnunet-arm -s -c test_credential_lookup.conf | 26 | gnunet-arm -s -c test_credential_lookup.conf |
27 | gnunet-identity -C service -c test_credential_lookup.conf | 27 | gnunet-identity -C service -c test_credential_lookup.conf |
28 | gnunet-identity -C alice -c test_credential_lookup.conf | 28 | gnunet-identity -C alice -c test_credential_lookup.conf |
29 | gnunet-identity -C gnu -c test_credential_lookup.conf | 29 | gnunet-identity -C gnu -c test_credential_lookup.conf |
@@ -44,8 +44,6 @@ TEST_CREDENTIAL="mygnunetcreds" | |||
44 | # (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU | 44 | # (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU |
45 | gnunet-namestore -p -z service -a -n $USER_ATTR -t ATTR -V "$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" -e 5m -c test_credential_lookup.conf | 45 | gnunet-namestore -p -z service -a -n $USER_ATTR -t ATTR -V "$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" -e 5m -c test_credential_lookup.conf |
46 | 46 | ||
47 | valgrind gnunet-namestore -D -z service -c test_credential_lookup.conf | ||
48 | |||
49 | # (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute | 47 | # (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute |
50 | gnunet-namestore -p -z gnu -a -n $GNU_PROJECT_ATTR -t ATTR -V "$GNUNET_KEY" -e 5m -c test_credential_lookup.conf | 48 | gnunet-namestore -p -z gnu -a -n $GNU_PROJECT_ATTR -t ATTR -V "$GNUNET_KEY" -e 5m -c test_credential_lookup.conf |
51 | 49 | ||
diff --git a/src/include/gnunet_credential_service.h b/src/include/gnunet_credential_service.h index b28d90140..7419407d3 100644 --- a/src/include/gnunet_credential_service.h +++ b/src/include/gnunet_credential_service.h | |||
@@ -112,22 +112,6 @@ struct GNUNET_CREDENTIAL_CredentialRecordData { | |||
112 | /** | 112 | /** |
113 | * The attribute delegation record | 113 | * The attribute delegation record |
114 | */ | 114 | */ |
115 | struct GNUNET_CREDENTIAL_AttributeRecordData { | ||
116 | |||
117 | /** | ||
118 | * Public key of the subject this attribute was delegated to | ||
119 | */ | ||
120 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; | ||
121 | |||
122 | /** | ||
123 | * Followed by the attribute that was delegated to as string | ||
124 | * May be empty | ||
125 | */ | ||
126 | }; | ||
127 | |||
128 | /** | ||
129 | * The attribute delegation record | ||
130 | */ | ||
131 | struct GNUNET_CREDENTIAL_DelegationRecordData { | 115 | struct GNUNET_CREDENTIAL_DelegationRecordData { |
132 | 116 | ||
133 | uint32_t set_count; | 117 | uint32_t set_count; |
@@ -257,13 +241,15 @@ GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle); | |||
257 | * Iterator called on obtained result for an attribute verification. | 241 | * Iterator called on obtained result for an attribute verification. |
258 | * | 242 | * |
259 | * @param cls closure | 243 | * @param cls closure |
260 | * @param issuer the issuer of the attribute NULL if verification failed | 244 | * @param d_count the number of delegations processed |
261 | * @param result the result of the verification | 245 | * @param delegation_chain the delegations processed |
262 | * @param rd the records in reply | 246 | * @param c_count the number of credentials found |
247 | * @param credential the credentials | ||
263 | */ | 248 | */ |
264 | typedef void (*GNUNET_CREDENTIAL_VerifyResultProcessor) (void *cls, | 249 | typedef void (*GNUNET_CREDENTIAL_VerifyResultProcessor) (void *cls, |
265 | unsigned int d_count, | 250 | unsigned int d_count, |
266 | struct GNUNET_CREDENTIAL_Delegation *delegation_chain, | 251 | struct GNUNET_CREDENTIAL_Delegation *delegation_chain, |
252 | unsigned int c_count, | ||
267 | struct GNUNET_CREDENTIAL_Credential *credential); | 253 | struct GNUNET_CREDENTIAL_Credential *credential); |
268 | 254 | ||
269 | /** | 255 | /** |