diff options
Diffstat (limited to 'src/util/gnunet-rsa.c')
-rw-r--r-- | src/util/gnunet-rsa.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util/gnunet-rsa.c b/src/util/gnunet-rsa.c index bfd854e65..f3cd83a8b 100644 --- a/src/util/gnunet-rsa.c +++ b/src/util/gnunet-rsa.c | |||
@@ -37,6 +37,11 @@ static int print_public_key; | |||
37 | */ | 37 | */ |
38 | static int print_peer_identity; | 38 | static int print_peer_identity; |
39 | 39 | ||
40 | /** | ||
41 | * Flag for printing short hash of public key. | ||
42 | */ | ||
43 | static int print_short_identity; | ||
44 | |||
40 | 45 | ||
41 | /** | 46 | /** |
42 | * Main function that will be run by the scheduler. | 47 | * Main function that will be run by the scheduler. |
@@ -78,6 +83,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
78 | GNUNET_CRYPTO_hash_to_enc (&pid.hashPubKey, &enc); | 83 | GNUNET_CRYPTO_hash_to_enc (&pid.hashPubKey, &enc); |
79 | fprintf (stdout, "%s\n", enc.encoding); | 84 | fprintf (stdout, "%s\n", enc.encoding); |
80 | } | 85 | } |
86 | if (print_short_identity) | ||
87 | { | ||
88 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded enc; | ||
89 | struct GNUNET_CRYPTO_ShortHashCode sh; | ||
90 | |||
91 | GNUNET_CRYPTO_rsa_key_get_public (pk, &pub); | ||
92 | GNUNET_CRYPTO_short_hash (&pub, sizeof (pub), &sh); | ||
93 | GNUNET_CRYPTO_short_hash_to_enc (&sh, &enc); | ||
94 | fprintf (stdout, "%s\n", enc.short_encoding); | ||
95 | } | ||
81 | GNUNET_CRYPTO_rsa_key_free (pk); | 96 | GNUNET_CRYPTO_rsa_key_free (pk); |
82 | } | 97 | } |
83 | 98 | ||
@@ -99,6 +114,9 @@ main (int argc, char *const *argv) | |||
99 | { 'P', "print-peer-identity", NULL, | 114 | { 'P', "print-peer-identity", NULL, |
100 | gettext_noop ("print the hash of the public key in ASCII format"), | 115 | gettext_noop ("print the hash of the public key in ASCII format"), |
101 | 0, &GNUNET_GETOPT_set_one, &print_peer_identity }, | 116 | 0, &GNUNET_GETOPT_set_one, &print_peer_identity }, |
117 | { 's', "print-short-identity", NULL, | ||
118 | gettext_noop ("print the short hash of the public key in ASCII format"), | ||
119 | 0, &GNUNET_GETOPT_set_one, &print_short_identity }, | ||
102 | GNUNET_GETOPT_OPTION_END | 120 | GNUNET_GETOPT_OPTION_END |
103 | }; | 121 | }; |
104 | return (GNUNET_OK == | 122 | return (GNUNET_OK == |