diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2017-06-23 20:39:27 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2017-06-23 20:39:27 +0200 |
commit | 2d81d6d8217b9aa08139bd66d14c597705568920 (patch) | |
tree | 197017d2b8498a79700ef6e00160b80ae749222e /src/util | |
parent | ad5b64d8ef992d7281501297b547095569d8f0fb (diff) | |
parent | d7547ab18052726a69ee088876389a18798e03a8 (diff) | |
download | gnunet-2d81d6d8217b9aa08139bd66d14c597705568920.tar.gz gnunet-2d81d6d8217b9aa08139bd66d14c597705568920.zip |
Merge remote-tracking branch 'origin/master' into credentials
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/crypto_hash.c | 4 | ||||
-rw-r--r-- | src/util/gnunet-ecc.c | 66 | ||||
-rw-r--r-- | src/util/service.c | 3 |
3 files changed, 43 insertions, 30 deletions
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index 49dbacd0b..20c7ca7ff 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -440,8 +440,8 @@ GNUNET_CRYPTO_hash_context_start () | |||
440 | */ | 440 | */ |
441 | void | 441 | void |
442 | GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, | 442 | GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, |
443 | const void *buf, | 443 | const void *buf, |
444 | size_t size) | 444 | size_t size) |
445 | { | 445 | { |
446 | gcry_md_write (hc->hd, buf, size); | 446 | gcry_md_write (hc->hd, buf, size); |
447 | } | 447 | } |
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index 2a712f4eb..42ecc2101 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -49,6 +49,11 @@ static unsigned int list_keys_count; | |||
49 | static int print_public_key; | 49 | static int print_public_key; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Flag for printing public key in hex. | ||
53 | */ | ||
54 | static int print_public_key_hex; | ||
55 | |||
56 | /** | ||
52 | * Flag for printing the output of random example operations. | 57 | * Flag for printing the output of random example operations. |
53 | */ | 58 | */ |
54 | static int print_examples_flag; | 59 | static int print_examples_flag; |
@@ -195,12 +200,10 @@ print_hex (const char *msg, | |||
195 | const void *buf, | 200 | const void *buf, |
196 | size_t size) | 201 | size_t size) |
197 | { | 202 | { |
198 | size_t i; | ||
199 | |||
200 | printf ("%s: ", msg); | 203 | printf ("%s: ", msg); |
201 | for (i = 0; i < size; i++) | 204 | for (size_t i = 0; i < size; i++) |
202 | { | 205 | { |
203 | printf ("%02hhx", ((const char *)buf)[i]); | 206 | printf ("%02hhx", ((const uint8_t *)buf)[i]); |
204 | } | 207 | } |
205 | printf ("\n"); | 208 | printf ("\n"); |
206 | } | 209 | } |
@@ -374,7 +377,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
374 | create_keys (args[0], args[1]); | 377 | create_keys (args[0], args[1]); |
375 | return; | 378 | return; |
376 | } | 379 | } |
377 | if (print_public_key) | 380 | if (print_public_key || print_public_key_hex) |
378 | { | 381 | { |
379 | char *str; | 382 | char *str; |
380 | struct GNUNET_DISK_FileHandle *keyfile; | 383 | struct GNUNET_DISK_FileHandle *keyfile; |
@@ -388,9 +391,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
388 | while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk))) | 391 | while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk))) |
389 | { | 392 | { |
390 | GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub); | 393 | GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub); |
391 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); | 394 | if (print_public_key_hex) |
392 | FPRINTF (stdout, "%s\n", str); | 395 | { |
393 | GNUNET_free (str); | 396 | print_hex ("HEX:", &pub, sizeof (pub)); |
397 | } | ||
398 | else | ||
399 | { | ||
400 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); | ||
401 | FPRINTF (stdout, "%s\n", str); | ||
402 | GNUNET_free (str); | ||
403 | } | ||
394 | } | 404 | } |
395 | GNUNET_DISK_file_close (keyfile); | 405 | GNUNET_DISK_file_close (keyfile); |
396 | } | 406 | } |
@@ -409,34 +419,38 @@ int | |||
409 | main (int argc, | 419 | main (int argc, |
410 | char *const *argv) | 420 | char *const *argv) |
411 | { | 421 | { |
412 | list_keys_count = UINT32_MAX; | ||
413 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 422 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
414 | GNUNET_GETOPT_option_flag ('i', | 423 | GNUNET_GETOPT_option_flag ('i', |
415 | "iterate", | 424 | "iterate", |
416 | gettext_noop ("list keys included in a file (for testing)"), | 425 | gettext_noop ("list keys included in a file (for testing)"), |
417 | &list_keys), | 426 | &list_keys), |
418 | GNUNET_GETOPT_option_uint ('e', | 427 | GNUNET_GETOPT_option_uint ('e', |
419 | "end=", | 428 | "end=", |
420 | "COUNT", | 429 | "COUNT", |
421 | gettext_noop ("number of keys to list included in a file (for testing)"), | 430 | gettext_noop ("number of keys to list included in a file (for testing)"), |
422 | &list_keys_count), | 431 | &list_keys_count), |
423 | GNUNET_GETOPT_option_uint ('g', | 432 | GNUNET_GETOPT_option_uint ('g', |
424 | "generate-keys", | 433 | "generate-keys", |
425 | "COUNT", | 434 | "COUNT", |
426 | gettext_noop ("create COUNT public-private key pairs (for testing)"), | 435 | gettext_noop ("create COUNT public-private key pairs (for testing)"), |
427 | &make_keys), | 436 | &make_keys), |
428 | GNUNET_GETOPT_option_flag ('p', | 437 | GNUNET_GETOPT_option_flag ('p', |
429 | "print-public-key", | 438 | "print-public-key", |
430 | gettext_noop ("print the public key in ASCII format"), | 439 | gettext_noop ("print the public key in ASCII format"), |
431 | &print_public_key), | 440 | &print_public_key), |
441 | GNUNET_GETOPT_option_flag ('x', | ||
442 | "print-hex", | ||
443 | gettext_noop ("print the public key in HEX format"), | ||
444 | &print_public_key_hex), | ||
432 | GNUNET_GETOPT_option_flag ('E', | 445 | GNUNET_GETOPT_option_flag ('E', |
433 | "examples", | 446 | "examples", |
434 | gettext_noop ("print examples of ECC operations (used for compatibility testing)"), | 447 | gettext_noop ("print examples of ECC operations (used for compatibility testing)"), |
435 | &print_examples_flag), | 448 | &print_examples_flag), |
436 | GNUNET_GETOPT_OPTION_END | 449 | GNUNET_GETOPT_OPTION_END |
437 | }; | 450 | }; |
438 | int ret; | 451 | int ret; |
439 | 452 | ||
453 | list_keys_count = UINT32_MAX; | ||
440 | if (GNUNET_OK != | 454 | if (GNUNET_OK != |
441 | GNUNET_STRINGS_get_utf8_args (argc, argv, | 455 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
442 | &argc, &argv)) | 456 | &argc, &argv)) |
diff --git a/src/util/service.c b/src/util/service.c index f63737e56..fcdf45a51 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -1283,15 +1283,14 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1283 | slc->sh = sh; | 1283 | slc->sh = sh; |
1284 | slc->listen_socket = open_listen_socket (addrs[i], | 1284 | slc->listen_socket = open_listen_socket (addrs[i], |
1285 | addrlens[i]); | 1285 | addrlens[i]); |
1286 | GNUNET_free (addrs[i]); | ||
1286 | if (NULL == slc->listen_socket) | 1287 | if (NULL == slc->listen_socket) |
1287 | { | 1288 | { |
1288 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | 1289 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
1289 | "bind"); | 1290 | "bind"); |
1290 | GNUNET_free (addrs[i++]); | ||
1291 | GNUNET_free (slc); | 1291 | GNUNET_free (slc); |
1292 | continue; | 1292 | continue; |
1293 | } | 1293 | } |
1294 | GNUNET_free (addrs[i++]); | ||
1295 | GNUNET_CONTAINER_DLL_insert (sh->slc_head, | 1294 | GNUNET_CONTAINER_DLL_insert (sh->slc_head, |
1296 | sh->slc_tail, | 1295 | sh->slc_tail, |
1297 | slc); | 1296 | slc); |