diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-01-30 15:59:28 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-01-30 15:59:28 +0000 |
commit | fb0fd00ae3d28e937b4e15a9aa50b62fb8440268 (patch) | |
tree | 9757773f9da6660c6b9e97b8422d8d665751f77a /src/util/gnunet-ecc.c | |
parent | f57cbab24fb7a22fc982eb8b6c4a2d18402be460 (diff) | |
download | gnunet-fb0fd00ae3d28e937b4e15a9aa50b62fb8440268.tar.gz gnunet-fb0fd00ae3d28e937b4e15a9aa50b62fb8440268.zip |
Allow gnunet-ecc to list all public keys in a file
Diffstat (limited to 'src/util/gnunet-ecc.c')
-rw-r--r-- | src/util/gnunet-ecc.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index 4af9f084d..5e8afe3c7 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -271,9 +271,6 @@ static void | |||
271 | run (void *cls, char *const *args, const char *cfgfile, | 271 | run (void *cls, char *const *args, const char *cfgfile, |
272 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 272 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
273 | { | 273 | { |
274 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; | ||
275 | struct GNUNET_CRYPTO_EddsaPublicKey pub; | ||
276 | |||
277 | if (print_examples_flag) | 274 | if (print_examples_flag) |
278 | { | 275 | { |
279 | print_examples (); | 276 | print_examples (); |
@@ -296,32 +293,43 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
296 | create_keys (args[0]); | 293 | create_keys (args[0]); |
297 | return; | 294 | return; |
298 | } | 295 | } |
299 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (args[0]); | ||
300 | if (NULL == pk) | ||
301 | return; | ||
302 | if (print_public_key) | 296 | if (print_public_key) |
303 | { | 297 | { |
298 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; | ||
299 | struct GNUNET_CRYPTO_EddsaPublicKey pub; | ||
304 | char *s; | 300 | char *s; |
305 | 301 | ||
302 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (args[0]); | ||
303 | if (NULL == pk) | ||
304 | return; | ||
306 | GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub); | 305 | GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub); |
307 | s = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); | 306 | s = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); |
308 | FPRINTF (stdout, | 307 | FPRINTF (stdout, |
309 | "%s\n", | 308 | "%s\n", |
310 | s); | 309 | s); |
311 | GNUNET_free (s); | 310 | GNUNET_free (s); |
311 | GNUNET_free (pk); | ||
312 | } | 312 | } |
313 | if (print_peer_identity) | 313 | if (print_peer_identity) |
314 | { | 314 | { |
315 | char *str; | 315 | char *str; |
316 | 316 | struct GNUNET_DISK_FileHandle *keyfile; | |
317 | GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub); | 317 | struct GNUNET_CRYPTO_EddsaPrivateKey pk; |
318 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); | 318 | struct GNUNET_CRYPTO_EddsaPublicKey pub; |
319 | FPRINTF (stdout, | 319 | |
320 | "%s\n", | 320 | keyfile = GNUNET_DISK_file_open (args[0], GNUNET_DISK_OPEN_READ, |
321 | str); | 321 | GNUNET_DISK_PERM_NONE); |
322 | GNUNET_free (str); | 322 | if (NULL == keyfile) |
323 | return; | ||
324 | while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk))) | ||
325 | { | ||
326 | GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub); | ||
327 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); | ||
328 | FPRINTF (stdout, "%s\n", str); | ||
329 | GNUNET_free (str); | ||
330 | } | ||
323 | } | 331 | } |
324 | GNUNET_free (pk); | 332 | |
325 | } | 333 | } |
326 | 334 | ||
327 | 335 | ||