aboutsummaryrefslogtreecommitdiff
path: root/src/identity
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-14 19:18:01 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-14 19:18:12 +0200
commitce2f5491241f0fd46ebfb4563b5d020717898613 (patch)
tree3e52ccb600869d23d78194b041edbefef58c9866 /src/identity
parent2a7c0cbbc0e81baef36446683c7e220eca1760c6 (diff)
downloadgnunet-ce2f5491241f0fd46ebfb4563b5d020717898613.tar.gz
gnunet-ce2f5491241f0fd46ebfb4563b5d020717898613.zip
add option to display private keys
Diffstat (limited to 'src/identity')
-rw-r--r--src/identity/gnunet-identity.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index 4d6b1db3f..41878fc1e 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V. 3 Copyright (C) 2013, 2018, 2019 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -51,6 +51,11 @@ static int list;
51static int monitor; 51static int monitor;
52 52
53/** 53/**
54 * Was "private" specified?
55 */
56static int private_keys;
57
58/**
54 * Was "verbose" specified? 59 * Was "verbose" specified?
55 */ 60 */
56static unsigned int verbose; 61static unsigned int verbose;
@@ -195,7 +200,18 @@ create_finished (void *cls,
195 200
196 GNUNET_CRYPTO_ecdsa_key_get_public (pk, &pub); 201 GNUNET_CRYPTO_ecdsa_key_get_public (pk, &pub);
197 pubs = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub); 202 pubs = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub);
198 fprintf (stdout, "%s\n", pubs); 203 if (private_keys)
204 {
205 char *privs;
206
207 privs = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk);
208 fprintf (stdout, "%s - %s\n", pubs, privs);
209 GNUNET_free (privs);
210 }
211 else
212 {
213 fprintf (stdout, "%s\n", pubs);
214 }
199 GNUNET_free (pubs); 215 GNUNET_free (pubs);
200 } 216 }
201 test_finished (); 217 test_finished ();
@@ -262,6 +278,7 @@ print_ego (void *cls,
262{ 278{
263 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 279 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
264 char *s; 280 char *s;
281 char *privs;
265 282
266 if ((NULL != set_ego) && (NULL != set_subsystem) && (NULL != ego) && 283 if ((NULL != set_ego) && (NULL != set_subsystem) && (NULL != ego) &&
267 (NULL != identifier) && (0 == strcmp (identifier, set_ego))) 284 (NULL != identifier) && (0 == strcmp (identifier, set_ego)))
@@ -291,19 +308,32 @@ print_ego (void *cls,
291 } 308 }
292 if (! (list | monitor)) 309 if (! (list | monitor))
293 return; 310 return;
294 if ( (NULL == ego) || (NULL == identifier) ) 311 if ((NULL == ego) || (NULL == identifier))
295 return; 312 return;
296 if ((NULL != set_ego) && (0 != strcmp (identifier, set_ego))) 313 if ((NULL != set_ego) && (0 != strcmp (identifier, set_ego)))
297 return; 314 return;
298 GNUNET_IDENTITY_ego_get_public_key (ego, &pk); 315 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
299 s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); 316 s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
317 privs = GNUNET_CRYPTO_ecdsa_private_key_to_string (
318 GNUNET_IDENTITY_ego_get_private_key (ego));
300 if ((monitor) || (NULL != identifier)) 319 if ((monitor) || (NULL != identifier))
301 { 320 {
302 if (quiet) 321 if (quiet)
303 fprintf (stdout, "%s\n", s); 322 {
323 if (private_keys)
324 fprintf (stdout, "%s - %s\n", s, privs);
325 else
326 fprintf (stdout, "%s\n", s);
327 }
304 else 328 else
305 fprintf (stdout, "%s - %s\n", identifier, s); 329 {
330 if (private_keys)
331 fprintf (stdout, "%s - %s - %s\n", identifier, s, privs);
332 else
333 fprintf (stdout, "%s - %s\n", identifier, s);
334 }
306 } 335 }
336 GNUNET_free (privs);
307 GNUNET_free (s); 337 GNUNET_free (s);
308} 338}
309 339
@@ -384,6 +414,10 @@ main (int argc, char *const *argv)
384 "monitor", 414 "monitor",
385 gettext_noop ("run in monitor mode egos"), 415 gettext_noop ("run in monitor mode egos"),
386 &monitor), 416 &monitor),
417 GNUNET_GETOPT_option_flag ('p',
418 "private-keys",
419 gettext_noop ("display private keys as well"),
420 &private_keys),
387 GNUNET_GETOPT_option_string ( 421 GNUNET_GETOPT_option_string (
388 's', 422 's',
389 "set", 423 "set",