diff options
Diffstat (limited to 'src/util/gnunet-ecc.c')
-rw-r--r-- | src/util/gnunet-ecc.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index 25852dc67..1a183e854 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -74,6 +74,7 @@ create_keys (const char *fn, const char *prefix) | |||
74 | int rest; | 74 | int rest; |
75 | unsigned char mask; | 75 | unsigned char mask; |
76 | unsigned target_byte; | 76 | unsigned target_byte; |
77 | char *s; | ||
77 | 78 | ||
78 | if (NULL == (f = fopen (fn, "w+"))) | 79 | if (NULL == (f = fopen (fn, "w+"))) |
79 | { | 80 | { |
@@ -87,7 +88,7 @@ create_keys (const char *fn, const char *prefix) | |||
87 | n = len * 5 / 8; | 88 | n = len * 5 / 8; |
88 | rest = len * 5 % 8; | 89 | rest = len * 5 % 8; |
89 | 90 | ||
90 | memset (&vanity[len], '0', KEY_STR_LEN - len); | 91 | memset (&vanity[len], 0, KEY_STR_LEN - len); |
91 | GNUNET_assert (GNUNET_OK == | 92 | GNUNET_assert (GNUNET_OK == |
92 | GNUNET_CRYPTO_eddsa_public_key_from_string (vanity, | 93 | GNUNET_CRYPTO_eddsa_public_key_from_string (vanity, |
93 | KEY_STR_LEN, | 94 | KEY_STR_LEN, |
@@ -105,14 +106,27 @@ create_keys (const char *fn, const char *prefix) | |||
105 | mask = ~ ((int)pow (2, 8 - rest) - 1); | 106 | mask = ~ ((int)pow (2, 8 - rest) - 1); |
106 | target_byte = ((unsigned char *) &target_pub)[n] & mask; | 107 | target_byte = ((unsigned char *) &target_pub)[n] & mask; |
107 | } | 108 | } |
109 | else | ||
110 | { | ||
111 | mask = 0; | ||
112 | } | ||
113 | s = GNUNET_CRYPTO_eddsa_public_key_to_string (&target_pub); | ||
108 | fprintf (stderr, | 114 | fprintf (stderr, |
109 | _("Generating %u keys like %s, please wait"), | 115 | _("Generating %u keys like %s, please wait"), |
110 | make_keys, GNUNET_CRYPTO_eddsa_public_key_to_string (&target_pub)); | 116 | make_keys, |
111 | fprintf (stderr, "\nattempt %s [%d, %X]\n", vanity, n, mask); | 117 | s); |
118 | GNUNET_free (s); | ||
119 | fprintf (stderr, | ||
120 | "\nattempt %s [%d, %X]\n", | ||
121 | vanity, | ||
122 | n, | ||
123 | mask); | ||
112 | } | 124 | } |
113 | else | 125 | else |
114 | { | 126 | { |
115 | fprintf (stderr, _("Generating %u keys, please wait"), make_keys); | 127 | fprintf (stderr, |
128 | _("Generating %u keys, please wait"), | ||
129 | make_keys); | ||
116 | /* Just so old (debian) versions of GCC calm down with the warnings. */ | 130 | /* Just so old (debian) versions of GCC calm down with the warnings. */ |
117 | n = rest = target_byte = mask = 0; | 131 | n = rest = target_byte = mask = 0; |
118 | } | 132 | } |
@@ -165,7 +179,8 @@ create_keys (const char *fn, const char *prefix) | |||
165 | _("\nFinished!\n")); | 179 | _("\nFinished!\n")); |
166 | else | 180 | else |
167 | fprintf (stderr, | 181 | fprintf (stderr, |
168 | _("\nError, %u keys not generated\n"), make_keys); | 182 | _("\nError, %u keys not generated\n"), |
183 | make_keys); | ||
169 | fclose (f); | 184 | fclose (f); |
170 | } | 185 | } |
171 | 186 | ||