diff options
Diffstat (limited to 'src/identity/gnunet-identity.c')
-rw-r--r-- | src/identity/gnunet-identity.c | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c index d0f5546f3..a01cd1ed7 100644 --- a/src/identity/gnunet-identity.c +++ b/src/identity/gnunet-identity.c | |||
@@ -66,6 +66,11 @@ static unsigned int verbose; | |||
66 | static int quiet; | 66 | static int quiet; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Was "eddsa" specified? | ||
70 | */ | ||
71 | static int type_eddsa; | ||
72 | |||
73 | /** | ||
69 | * -C option | 74 | * -C option |
70 | */ | 75 | */ |
71 | static char *create_ego; | 76 | static char *create_ego; |
@@ -108,7 +113,7 @@ static struct GNUNET_IDENTITY_Operation *delete_op; | |||
108 | /** | 113 | /** |
109 | * Private key from command line option, or NULL. | 114 | * Private key from command line option, or NULL. |
110 | */ | 115 | */ |
111 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; | 116 | struct GNUNET_IDENTITY_PrivateKey pk; |
112 | 117 | ||
113 | /** | 118 | /** |
114 | * Value to return from #main(). | 119 | * Value to return from #main(). |
@@ -197,7 +202,7 @@ delete_finished (void *cls, | |||
197 | */ | 202 | */ |
198 | static void | 203 | static void |
199 | create_finished (void *cls, | 204 | create_finished (void *cls, |
200 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 205 | const struct GNUNET_IDENTITY_PrivateKey *pk, |
201 | const char *emsg) | 206 | const char *emsg) |
202 | { | 207 | { |
203 | struct GNUNET_IDENTITY_Operation **op = cls; | 208 | struct GNUNET_IDENTITY_Operation **op = cls; |
@@ -212,16 +217,16 @@ create_finished (void *cls, | |||
212 | } | 217 | } |
213 | else if (verbose) | 218 | else if (verbose) |
214 | { | 219 | { |
215 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 220 | struct GNUNET_IDENTITY_PublicKey pub; |
216 | char *pubs; | 221 | char *pubs; |
217 | 222 | ||
218 | GNUNET_CRYPTO_ecdsa_key_get_public (pk, &pub); | 223 | GNUNET_IDENTITY_key_get_public (pk, &pub); |
219 | pubs = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub); | 224 | pubs = GNUNET_IDENTITY_public_key_to_string (&pub); |
220 | if (private_keys) | 225 | if (private_keys) |
221 | { | 226 | { |
222 | char *privs; | 227 | char *privs; |
223 | 228 | ||
224 | privs = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); | 229 | privs = GNUNET_IDENTITY_private_key_to_string (pk); |
225 | fprintf (stdout, "%s - %s\n", pubs, privs); | 230 | fprintf (stdout, "%s - %s\n", pubs, privs); |
226 | GNUNET_free (privs); | 231 | GNUNET_free (privs); |
227 | } | 232 | } |
@@ -293,7 +298,7 @@ print_ego (void *cls, | |||
293 | void **ctx, | 298 | void **ctx, |
294 | const char *identifier) | 299 | const char *identifier) |
295 | { | 300 | { |
296 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 301 | struct GNUNET_IDENTITY_PublicKey pk; |
297 | char *s; | 302 | char *s; |
298 | char *privs; | 303 | char *privs; |
299 | 304 | ||
@@ -342,8 +347,8 @@ print_ego (void *cls, | |||
342 | set_ego)) ) | 347 | set_ego)) ) |
343 | return; | 348 | return; |
344 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | 349 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); |
345 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | 350 | s = GNUNET_IDENTITY_public_key_to_string (&pk); |
346 | privs = GNUNET_CRYPTO_ecdsa_private_key_to_string ( | 351 | privs = GNUNET_IDENTITY_private_key_to_string ( |
347 | GNUNET_IDENTITY_ego_get_private_key (ego)); | 352 | GNUNET_IDENTITY_ego_get_private_key (ego)); |
348 | if ((monitor) || (NULL != identifier)) | 353 | if ((monitor) || (NULL != identifier)) |
349 | { | 354 | { |
@@ -357,9 +362,16 @@ print_ego (void *cls, | |||
357 | else | 362 | else |
358 | { | 363 | { |
359 | if (private_keys) | 364 | if (private_keys) |
360 | fprintf (stdout, "%s - %s - %s\n", identifier, s, privs); | 365 | fprintf (stdout, "%s - %s - %s - %s\n", |
366 | identifier, s, privs, | ||
367 | (ntohl (pk.type) == GNUNET_IDENTITY_TYPE_ECDSA) ? | ||
368 | "ECDSA" : "EdDSA"); | ||
361 | else | 369 | else |
362 | fprintf (stdout, "%s - %s\n", identifier, s); | 370 | fprintf (stdout, "%s - %s - %s\n", |
371 | identifier, s, | ||
372 | (ntohl (pk.type) == GNUNET_IDENTITY_TYPE_ECDSA) ? | ||
373 | "ECDSA" : "EdDSA"); | ||
374 | |||
363 | } | 375 | } |
364 | } | 376 | } |
365 | GNUNET_free (privs); | 377 | GNUNET_free (privs); |
@@ -407,11 +419,12 @@ run (void *cls, | |||
407 | strlen (privkey_ego), | 419 | strlen (privkey_ego), |
408 | &pk, | 420 | &pk, |
409 | sizeof(struct | 421 | sizeof(struct |
410 | GNUNET_CRYPTO_EcdsaPrivateKey)); | 422 | GNUNET_IDENTITY_PrivateKey)); |
411 | create_op = | 423 | create_op = |
412 | GNUNET_IDENTITY_create (sh, | 424 | GNUNET_IDENTITY_create (sh, |
413 | create_ego, | 425 | create_ego, |
414 | &pk, | 426 | &pk, |
427 | 0, // Ignored | ||
415 | &create_finished, | 428 | &create_finished, |
416 | &create_op); | 429 | &create_op); |
417 | } | 430 | } |
@@ -420,6 +433,9 @@ run (void *cls, | |||
420 | GNUNET_IDENTITY_create (sh, | 433 | GNUNET_IDENTITY_create (sh, |
421 | create_ego, | 434 | create_ego, |
422 | NULL, | 435 | NULL, |
436 | (type_eddsa) ? | ||
437 | GNUNET_IDENTITY_TYPE_EDDSA : | ||
438 | GNUNET_IDENTITY_TYPE_ECDSA, | ||
423 | &create_finished, | 439 | &create_finished, |
424 | &create_op); | 440 | &create_op); |
425 | } | 441 | } |
@@ -456,6 +472,11 @@ main (int argc, char *const *argv) | |||
456 | gettext_noop ( | 472 | gettext_noop ( |
457 | "set the private key for the identity to PRIVATE_KEY (use together with -C)"), | 473 | "set the private key for the identity to PRIVATE_KEY (use together with -C)"), |
458 | &privkey_ego), | 474 | &privkey_ego), |
475 | GNUNET_GETOPT_option_flag ('X', | ||
476 | "eddsa", | ||
477 | gettext_noop ( | ||
478 | "generate an EdDSA identity. (use together with -C) EXPERIMENTAL"), | ||
479 | &type_eddsa), | ||
459 | GNUNET_GETOPT_option_flag ('d', | 480 | GNUNET_GETOPT_option_flag ('d', |
460 | "display", | 481 | "display", |
461 | gettext_noop ("display all egos"), | 482 | gettext_noop ("display all egos"), |