[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32121 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32121 - gnunet/src/util |
Date: |
Thu, 30 Jan 2014 16:59:28 +0100 |
Author: bartpolot
Date: 2014-01-30 16:59:28 +0100 (Thu, 30 Jan 2014)
New Revision: 32121
Modified:
gnunet/src/util/gnunet-ecc.c
Log:
Allow gnunet-ecc to list all public keys in a file
Modified: gnunet/src/util/gnunet-ecc.c
===================================================================
--- gnunet/src/util/gnunet-ecc.c 2014-01-30 14:48:15 UTC (rev 32120)
+++ gnunet/src/util/gnunet-ecc.c 2014-01-30 15:59:28 UTC (rev 32121)
@@ -271,9 +271,6 @@
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
- struct GNUNET_CRYPTO_EddsaPublicKey pub;
-
if (print_examples_flag)
{
print_examples ();
@@ -296,32 +293,43 @@
create_keys (args[0]);
return;
}
- pk = GNUNET_CRYPTO_eddsa_key_create_from_file (args[0]);
- if (NULL == pk)
- return;
if (print_public_key)
{
+ struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
+ struct GNUNET_CRYPTO_EddsaPublicKey pub;
char *s;
+ pk = GNUNET_CRYPTO_eddsa_key_create_from_file (args[0]);
+ if (NULL == pk)
+ return;
GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub);
s = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
FPRINTF (stdout,
"%s\n",
s);
GNUNET_free (s);
+ GNUNET_free (pk);
}
if (print_peer_identity)
{
char *str;
+ struct GNUNET_DISK_FileHandle *keyfile;
+ struct GNUNET_CRYPTO_EddsaPrivateKey pk;
+ struct GNUNET_CRYPTO_EddsaPublicKey pub;
- GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub);
- str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
- FPRINTF (stdout,
- "%s\n",
- str);
- GNUNET_free (str);
+ keyfile = GNUNET_DISK_file_open (args[0], GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE);
+ if (NULL == keyfile)
+ return;
+ while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk)))
+ {
+ GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub);
+ str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
+ FPRINTF (stdout, "%s\n", str);
+ GNUNET_free (str);
+ }
}
- GNUNET_free (pk);
+
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32121 - gnunet/src/util,
gnunet <=