-.TH GNUNET\-ECC 1 "Mar 15, 2012" "GNUnet"
+.TH GNUNET\-ECC 1 "Jun 5, 2017" "GNUnet"
.SH NAME
gnunet\-ecc \- manipulate GNUnet ECC key files
.IP "\-p, \-\-print-public-key"
Print the corresponding public key to stdout. This is the value used for PKEY records in GNS.
.B
+.IP "\-p, \-\-print-hex"
+Print the corresponding public key to stdout in HEX format. Useful for comparing to Ed25519 keys in X.509 tools.
+.B
.IP "\-P, \-\-print-peer-identity"
Print the corresponding peer identity (hash of the public key) to stdout. This hash is used for the name of peers.
.B
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org>
-
*/
static int print_public_key;
+/**
+ * Flag for printing public key in hex.
+ */
+static int print_public_key_hex;
+
/**
* Flag for printing the output of random example operations.
*/
const void *buf,
size_t size)
{
- size_t i;
-
printf ("%s: ", msg);
- for (i = 0; i < size; i++)
+ for (size_t i = 0; i < size; i++)
{
- printf ("%02hhx", ((const char *)buf)[i]);
+ printf ("%02hhx", ((const uint8_t *)buf)[i]);
}
printf ("\n");
}
create_keys (args[0], args[1]);
return;
}
- if (print_public_key)
+ if (print_public_key || print_public_key_hex)
{
char *str;
struct GNUNET_DISK_FileHandle *keyfile;
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);
+ if (print_public_key_hex)
+ {
+ print_hex ("HEX:", &pub, sizeof (pub));
+ }
+ else
+ {
+ str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
+ FPRINTF (stdout, "%s\n", str);
+ GNUNET_free (str);
+ }
}
GNUNET_DISK_file_close (keyfile);
}
main (int argc,
char *const *argv)
{
- list_keys_count = UINT32_MAX;
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('i',
- "iterate",
- gettext_noop ("list keys included in a file (for testing)"),
- &list_keys),
+ "iterate",
+ gettext_noop ("list keys included in a file (for testing)"),
+ &list_keys),
GNUNET_GETOPT_option_uint ('e',
- "end=",
- "COUNT",
- gettext_noop ("number of keys to list included in a file (for testing)"),
- &list_keys_count),
+ "end=",
+ "COUNT",
+ gettext_noop ("number of keys to list included in a file (for testing)"),
+ &list_keys_count),
GNUNET_GETOPT_option_uint ('g',
- "generate-keys",
- "COUNT",
- gettext_noop ("create COUNT public-private key pairs (for testing)"),
- &make_keys),
+ "generate-keys",
+ "COUNT",
+ gettext_noop ("create COUNT public-private key pairs (for testing)"),
+ &make_keys),
GNUNET_GETOPT_option_flag ('p',
- "print-public-key",
- gettext_noop ("print the public key in ASCII format"),
- &print_public_key),
+ "print-public-key",
+ gettext_noop ("print the public key in ASCII format"),
+ &print_public_key),
+ GNUNET_GETOPT_option_flag ('x',
+ "print-hex",
+ gettext_noop ("print the public key in HEX format"),
+ &print_public_key_hex),
GNUNET_GETOPT_option_flag ('E',
- "examples",
- gettext_noop ("print examples of ECC operations (used for compatibility testing)"),
- &print_examples_flag),
+ "examples",
+ gettext_noop ("print examples of ECC operations (used for compatibility testing)"),
+ &print_examples_flag),
GNUNET_GETOPT_OPTION_END
};
int ret;
+ list_keys_count = UINT32_MAX;
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))