summaryrefslogtreecommitdiff
path: root/src/identity/gnunet-identity.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-05-25 21:38:58 +0200
committerjospaeth <spaethj@in.tum.de>2020-05-25 21:38:58 +0200
commita32de45ceffeb69038ecfa7b963f30b7fed83a41 (patch)
tree76a39adcf7163c71e470b7c5bf4357dd5471cf9c /src/identity/gnunet-identity.c
parent19cd0e6d0eca5192a9c8f4f005abd85d531949f1 (diff)
add option to create identity from private keyspaeth/import_identity
Diffstat (limited to 'src/identity/gnunet-identity.c')
-rw-r--r--src/identity/gnunet-identity.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index fd73048c4..cf44afd1f 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -76,6 +76,11 @@ static char *create_ego;
static char *delete_ego;
/**
+ * -P option
+ */
+static char *privkey_ego;
+
+/**
* -s option.
*/
static char *set_ego;
@@ -101,6 +106,11 @@ static struct GNUNET_IDENTITY_Operation *create_op;
static struct GNUNET_IDENTITY_Operation *delete_op;
/**
+ * Private key from command line option, or NULL.
+ */
+struct GNUNET_CRYPTO_EcdsaPrivateKey pk;
+
+/**
* Value to return from #main().
*/
static int global_ret;
@@ -390,11 +400,28 @@ run (void *cls,
&delete_finished,
&delete_op);
if (NULL != create_ego)
- create_op =
- GNUNET_IDENTITY_create (sh,
- create_ego,
- &create_finished,
- &create_op);
+ {
+ if (NULL != privkey_ego)
+ {
+ GNUNET_STRINGS_string_to_data (privkey_ego,
+ strlen (privkey_ego),
+ &pk,
+ sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey));
+ create_op =
+ GNUNET_IDENTITY_create (sh,
+ create_ego,
+ &pk,
+ &create_finished,
+ &create_op);
+ }
+ else
+ create_op =
+ GNUNET_IDENTITY_create (sh,
+ create_ego,
+ NULL,
+ &create_finished,
+ &create_op);
+ }
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
NULL);
test_finished ();
@@ -422,6 +449,11 @@ main (int argc, char *const *argv)
"NAME",
gettext_noop ("delete ego NAME "),
&delete_ego),
+ GNUNET_GETOPT_option_string ('P',
+ "privkey",
+ "PRIVATE_KEY",
+ gettext_noop ("set the private key for the identity to PRIVATE_KEY (use together with -C)"),
+ &privkey_ego),
GNUNET_GETOPT_option_flag ('d',
"display",
gettext_noop ("display all egos"),