diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-05-22 09:44:22 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-05-22 09:44:22 +0200 |
commit | 2fbc0f044f95f2a8ed8a87e980fe0ec4f4ddf650 (patch) | |
tree | 431d13969f0ebebcd5e69cc8e5c73d3bbfe245b0 /src/identity/plugin_rest_identity.c | |
parent | 9a92bbb515bd89d18cfe996890f67a41378307ef (diff) | |
download | gnunet-2fbc0f044f95f2a8ed8a87e980fe0ec4f4ddf650.tar.gz gnunet-2fbc0f044f95f2a8ed8a87e980fe0ec4f4ddf650.zip |
add option to show private key
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r-- | src/identity/plugin_rest_identity.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 97a7bf513..ef01cc578 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -57,6 +57,11 @@ | |||
57 | #define GNUNET_REST_IDENTITY_PARAM_PUBKEY "pubkey" | 57 | #define GNUNET_REST_IDENTITY_PARAM_PUBKEY "pubkey" |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Parameter public key | ||
61 | */ | ||
62 | #define GNUNET_REST_IDENTITY_PARAM_PRIVKEY "privkey" | ||
63 | |||
64 | /** | ||
60 | * Parameter subsystem | 65 | * Parameter subsystem |
61 | */ | 66 | */ |
62 | #define GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM "subsystem" | 67 | #define GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM "subsystem" |
@@ -463,9 +468,11 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle, | |||
463 | struct RequestHandle *handle = cls; | 468 | struct RequestHandle *handle = cls; |
464 | struct EgoEntry *ego_entry; | 469 | struct EgoEntry *ego_entry; |
465 | struct MHD_Response *resp; | 470 | struct MHD_Response *resp; |
471 | struct GNUNET_HashCode key; | ||
466 | json_t *json_root; | 472 | json_t *json_root; |
467 | json_t *json_ego; | 473 | json_t *json_ego; |
468 | char *result_str; | 474 | char *result_str; |
475 | char *privkey_str; | ||
469 | 476 | ||
470 | json_root = json_array (); | 477 | json_root = json_array (); |
471 | // Return ego/egos | 478 | // Return ego/egos |
@@ -476,6 +483,19 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle, | |||
476 | json_object_set_new (json_ego, | 483 | json_object_set_new (json_ego, |
477 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, | 484 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, |
478 | json_string (ego_entry->keystring)); | 485 | json_string (ego_entry->keystring)); |
486 | GNUNET_CRYPTO_hash ("private", strlen ("private"), &key); | ||
487 | if (GNUNET_YES == | ||
488 | GNUNET_CONTAINER_multihashmap_contains ( | ||
489 | handle->rest_handle->url_param_map, &key)) | ||
490 | { | ||
491 | privkey_str = GNUNET_CRYPTO_ecdsa_private_key_to_string ( | ||
492 | GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego)); | ||
493 | json_object_set_new (json_ego, | ||
494 | GNUNET_REST_IDENTITY_PARAM_PRIVKEY, | ||
495 | json_string (privkey_str)); | ||
496 | GNUNET_free (privkey_str); | ||
497 | } | ||
498 | |||
479 | json_object_set_new (json_ego, | 499 | json_object_set_new (json_ego, |
480 | GNUNET_REST_IDENTITY_PARAM_NAME, | 500 | GNUNET_REST_IDENTITY_PARAM_NAME, |
481 | json_string (ego_entry->identifier)); | 501 | json_string (ego_entry->identifier)); |
@@ -504,8 +524,10 @@ void | |||
504 | ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry) | 524 | ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry) |
505 | { | 525 | { |
506 | struct MHD_Response *resp; | 526 | struct MHD_Response *resp; |
527 | struct GNUNET_HashCode key; | ||
507 | json_t *json_ego; | 528 | json_t *json_ego; |
508 | char *result_str; | 529 | char *result_str; |
530 | char *privkey_str; | ||
509 | 531 | ||
510 | json_ego = json_object (); | 532 | json_ego = json_object (); |
511 | json_object_set_new (json_ego, | 533 | json_object_set_new (json_ego, |
@@ -514,6 +536,18 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
514 | json_object_set_new (json_ego, | 536 | json_object_set_new (json_ego, |
515 | GNUNET_REST_IDENTITY_PARAM_NAME, | 537 | GNUNET_REST_IDENTITY_PARAM_NAME, |
516 | json_string (ego_entry->identifier)); | 538 | json_string (ego_entry->identifier)); |
539 | GNUNET_CRYPTO_hash ("private", strlen ("private"), &key); | ||
540 | if (GNUNET_YES == | ||
541 | GNUNET_CONTAINER_multihashmap_contains ( | ||
542 | handle->rest_handle->url_param_map, &key)) | ||
543 | { | ||
544 | privkey_str = GNUNET_CRYPTO_ecdsa_private_key_to_string ( | ||
545 | GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego)); | ||
546 | json_object_set_new (json_ego, | ||
547 | GNUNET_REST_IDENTITY_PARAM_PRIVKEY, | ||
548 | json_string (privkey_str)); | ||
549 | GNUNET_free (privkey_str); | ||
550 | } | ||
517 | 551 | ||
518 | result_str = json_dumps (json_ego, 0); | 552 | result_str = json_dumps (json_ego, 0); |
519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 553 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |