aboutsummaryrefslogtreecommitdiff
path: root/src/credential/gnunet-credential.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-11-20 17:49:04 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-11-20 17:49:04 +0100
commitfad73f2435336733ae585c7a018df860bec3bdf1 (patch)
tree912becfd30ae7d6a4d1fcc53095eef5205daf5ec /src/credential/gnunet-credential.c
parent18f106166cf64cc72206cd35301276aa21ca100a (diff)
downloadgnunet-fad73f2435336733ae585c7a018df860bec3bdf1.tar.gz
gnunet-fad73f2435336733ae585c7a018df860bec3bdf1.zip
- add missing API; no impl
Diffstat (limited to 'src/credential/gnunet-credential.c')
-rw-r--r--src/credential/gnunet-credential.c108
1 files changed, 50 insertions, 58 deletions
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c
index 94a4b3899..31cd4fd8f 100644
--- a/src/credential/gnunet-credential.c
+++ b/src/credential/gnunet-credential.c
@@ -50,7 +50,7 @@ static char *lookup_credential;
50/** 50/**
51 * Handle to verify request 51 * Handle to verify request
52 */ 52 */
53static struct GNUNET_CREDENTIAL_VerifyRequest *verify_request; 53static struct GNUNET_CREDENTIAL_Request *verify_request;
54 54
55/** 55/**
56 * Lookup an ego with the identity service. 56 * Lookup an ego with the identity service.
@@ -82,11 +82,6 @@ static char *subject_key;
82 */ 82 */
83static char *issuer_key; 83static char *issuer_key;
84 84
85/*
86 * Credential flags
87 */
88static int credential_flags;
89
90 85
91 86
92/** 87/**
@@ -158,20 +153,18 @@ do_timeout (void *cls)
158 */ 153 */
159static void 154static void
160handle_verify_result (void *cls, 155handle_verify_result (void *cls,
161 struct GNUNET_IDENTITY_Ego *issuer, 156 struct GNUNET_CRYPTO_EcdsaPublicKey *issuer,
162 uint16_t issuer_len, 157 uint32_t status)
163 const struct GNUNET_CREDENTIAL_RecordData *data)
164{ 158{
165 159
166 160
167 verify_request = NULL; 161 verify_request = NULL;
168 if (0 == issuer_len) 162 if (GNUNET_NO == status)
169 printf ("No results.\n"); 163 printf ("Verify failed.\n");
170 else 164 else
171 printf ("%u\n", 165 printf ("Successful.\n");
172 issuer_len); 166
173 167
174
175 GNUNET_SCHEDULER_shutdown (); 168 GNUNET_SCHEDULER_shutdown ();
176} 169}
177 170
@@ -188,7 +181,7 @@ handle_verify_result (void *cls,
188static void 181static void
189lookup_credentials (struct GNUNET_IDENTITY_Ego *ego) 182lookup_credentials (struct GNUNET_IDENTITY_Ego *ego)
190{ 183{
191 184
192 struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey; 185 struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey;
193 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_pkey; 186 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_pkey;
194 187
@@ -217,21 +210,20 @@ lookup_credentials (struct GNUNET_IDENTITY_Ego *ego)
217 GNUNET_SCHEDULER_shutdown (); 210 GNUNET_SCHEDULER_shutdown ();
218 return; 211 return;
219 } 212 }
220 213
221 verify_request = GNUNET_CREDENTIAL_verify(credential, 214 verify_request = GNUNET_CREDENTIAL_verify(credential,
222 "", 215 &issuer_pkey,
223 lookup_credential, 216 "test", //TODO argument
224 &subject_pkey, 217 &subject_pkey,
225 &issuer_pkey, 218 lookup_credential,
226 credential_flags, 219 &handle_verify_result,
227 &handle_verify_result, 220 NULL);
228 NULL); 221 return;
229 return;
230 } 222 }
231 else 223 else
232 { 224 {
233 fprintf (stderr, 225 fprintf (stderr,
234 _("Please specify name to lookup, subject key and issuer key!\n")); 226 _("Please specify name to lookup, subject key and issuer key!\n"));
235 GNUNET_SCHEDULER_shutdown (); 227 GNUNET_SCHEDULER_shutdown ();
236 return; 228 return;
237 } 229 }
@@ -252,23 +244,23 @@ lookup_credentials (struct GNUNET_IDENTITY_Ego *ego)
252 */ 244 */
253static void 245static void
254identity_master_cb (void *cls, 246identity_master_cb (void *cls,
255 struct GNUNET_IDENTITY_Ego *ego, 247 struct GNUNET_IDENTITY_Ego *ego,
256 void **ctx, 248 void **ctx,
257 const char *name) 249 const char *name)
258{ 250{
259 251
260 id_op = NULL; 252 id_op = NULL;
261 if (NULL == ego) 253 if (NULL == ego)
262 { 254 {
263 fprintf (stderr, 255 fprintf (stderr,
264 _("Ego for `gns-master' not found, cannot perform lookup. Did you run gnunet-gns-import.sh?\n")); 256 _("Ego for `gns-master' not found, cannot perform lookup. Did you run gnunet-gns-import.sh?\n"));
265 GNUNET_SCHEDULER_shutdown (); 257 GNUNET_SCHEDULER_shutdown ();
266 return; 258 return;
267 } 259 }
268 260
269 lookup_credentials(ego); 261 lookup_credentials(ego);
270 262
271 263
272} 264}
273 265
274 266
@@ -286,41 +278,41 @@ run (void *cls,
286 const char *cfgfile, 278 const char *cfgfile,
287 const struct GNUNET_CONFIGURATION_Handle *c) 279 const struct GNUNET_CONFIGURATION_Handle *c)
288{ 280{
289 281
290 cfg = c; 282 cfg = c;
291 credential = GNUNET_CREDENTIAL_connect (cfg); 283 credential = GNUNET_CREDENTIAL_connect (cfg);
292 identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL); 284 identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
293 285
294
295 286
296 287
288
297 if (NULL == credential) 289 if (NULL == credential)
298 { 290 {
299 fprintf (stderr, 291 fprintf (stderr,
300 _("Failed to connect to CREDENTIAL\n")); 292 _("Failed to connect to CREDENTIAL\n"));
301 return; 293 return;
302 } 294 }
303 if (NULL == identity) 295 if (NULL == identity)
304 { 296 {
305 fprintf (stderr, 297 fprintf (stderr,
306 _("Failed to connect to IDENTITY\n")); 298 _("Failed to connect to IDENTITY\n"));
307 return; 299 return;
308 } 300 }
309 tt = GNUNET_SCHEDULER_add_delayed (timeout, 301 tt = GNUNET_SCHEDULER_add_delayed (timeout,
310 &do_timeout, NULL); 302 &do_timeout, NULL);
311 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); 303 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
312
313 304
314
315 GNUNET_break (NULL == id_op);
316 id_op = GNUNET_IDENTITY_get (identity,
317 "gns-master",//# TODO: Create credential-master
318 &identity_master_cb,
319 cls);
320 GNUNET_assert (NULL != id_op);
321 305
322 306
323 307 GNUNET_break (NULL == id_op);
308 id_op = GNUNET_IDENTITY_get (identity,
309 "gns-master",//# TODO: Create credential-master
310 &identity_master_cb,
311 cls);
312 GNUNET_assert (NULL != id_op);
313
314
315
324 316
325} 317}
326 318
@@ -339,15 +331,15 @@ main (int argc, char *const *argv)
339 {'u', "lookup", "CREDENTIAL", 331 {'u', "lookup", "CREDENTIAL",
340 gettext_noop ("Lookup a record for the given credential"), 1, 332 gettext_noop ("Lookup a record for the given credential"), 1,
341 &GNUNET_GETOPT_set_string, &lookup_credential}, 333 &GNUNET_GETOPT_set_string, &lookup_credential},
342 /** { 'T', "timeout", "DELAY", 334 /** { 'T', "timeout", "DELAY",
343 gettext_noop ("Specify timeout for the lookup"), 1, 335 gettext_noop ("Specify timeout for the lookup"), 1,
344 &GNUNET_GETOPT_set_relative_time, &timeout }, 336 &GNUNET_GETOPT_set_relative_time, &timeout },
345 {'t', "type", "TYPE", 337 {'t', "type", "TYPE",
346 gettext_noop ("Specify the type of the record to lookup"), 1, 338 gettext_noop ("Specify the type of the record to lookup"), 1,
347 &GNUNET_GETOPT_set_string, &lookup_type},**/ 339 &GNUNET_GETOPT_set_string, &lookup_type},**/
348 {'z', "zone", "NAME", 340 {'z', "zone", "NAME",
349 gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1, 341 gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1,
350 &GNUNET_GETOPT_set_string, &zone_ego_name}, 342 &GNUNET_GETOPT_set_string, &zone_ego_name},
351 {'s', "subject", "PKEY", 343 {'s', "subject", "PKEY",
352 gettext_noop ("Specify the public key of the subject to lookup the credential for"), 1, 344 gettext_noop ("Specify the public key of the subject to lookup the credential for"), 1,
353 &GNUNET_GETOPT_set_string, &subject_key}, 345 &GNUNET_GETOPT_set_string, &subject_key},
@@ -364,11 +356,11 @@ main (int argc, char *const *argv)
364 356
365 GNUNET_log_setup ("gnunet-credential", "WARNING", NULL); 357 GNUNET_log_setup ("gnunet-credential", "WARNING", NULL);
366 ret = 358 ret =
367 (GNUNET_OK == 359 (GNUNET_OK ==
368 GNUNET_PROGRAM_run (argc, argv, "gnunet-credential", 360 GNUNET_PROGRAM_run (argc, argv, "gnunet-credential",
369 _("GNUnet credential resolver tool"), 361 _("GNUnet credential resolver tool"),
370 options, 362 options,
371 &run, NULL)) ? 0 : 1; 363 &run, NULL)) ? 0 : 1;
372 GNUNET_free ((void*) argv); 364 GNUNET_free ((void*) argv);
373 return ret; 365 return ret;
374} 366}