gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20515 - in gnunet: doc/man src/util


From: gnunet
Subject: [GNUnet-SVN] r20515 - in gnunet: doc/man src/util
Date: Thu, 15 Mar 2012 11:59:49 +0100

Author: grothoff
Date: 2012-03-15 11:59:49 +0100 (Thu, 15 Mar 2012)
New Revision: 20515

Modified:
   gnunet/doc/man/gnunet-rsa.1
   gnunet/src/util/gnunet-rsa.c
Log:
add -P option for printing peer identities with gnunet-rsa

Modified: gnunet/doc/man/gnunet-rsa.1
===================================================================
--- gnunet/doc/man/gnunet-rsa.1 2012-03-15 10:54:34 UTC (rev 20514)
+++ gnunet/doc/man/gnunet-rsa.1 2012-03-15 10:59:49 UTC (rev 20515)
@@ -1,4 +1,4 @@
-.TH GNUNET\-RSA 1 "Jan 4, 2012" "GNUnet"
+.TH GNUNET\-RSA 1 "Mar 15, 2012" "GNUnet"
 
 .SH NAME
 gnunet\-rsa \- manipulate GNUnet RSA key files
@@ -13,9 +13,12 @@
 
 .SH OPTIONS
 .B
-.IP "\-p, \-\-print"
-Print the corresponding public key (to stdout).
+.IP "\-p, \-\-print-public-key"
+Print the corresponding public key to stdout.
 .B
+.IP "\-P, \-\-print-peer-identity"
+Print the corresponding peer identity (hash of the public key) to stdout.
+.B
 .IP "\-c FILENAME,  \-\-config=FILENAME"
 Use the configuration file FILENAME.
 .B

Modified: gnunet/src/util/gnunet-rsa.c
===================================================================
--- gnunet/src/util/gnunet-rsa.c        2012-03-15 10:54:34 UTC (rev 20514)
+++ gnunet/src/util/gnunet-rsa.c        2012-03-15 10:59:49 UTC (rev 20515)
@@ -28,11 +28,16 @@
 
 
 /**
- * Flag for reverse lookup.
+ * Flag for printing public key.
  */
-static int print;
+static int print_public_key;
 
+/**
+ * Flag for printing hash of public key.
+ */
+static int print_peer_identity;
 
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -47,7 +52,7 @@
 {
   struct GNUNET_CRYPTO_RsaPrivateKey *pk;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
-  char *s;
+  struct GNUNET_PeerIdentity pid;
 
   if (NULL == args[0])
   {
@@ -55,13 +60,24 @@
     return;
   }
   pk = GNUNET_CRYPTO_rsa_key_create_from_file (args[0]);
-  if (print)
+  if (print_public_key)
   {
+    char *s;
+
     GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
     s = GNUNET_CRYPTO_rsa_public_key_to_string (&pub);
     fprintf (stdout, "%s\n", s);
     GNUNET_free (s);
   }
+  if (print_peer_identity)
+  {
+    struct GNUNET_CRYPTO_HashAsciiEncoded enc;
+
+    GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
+    GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
+    GNUNET_CRYPTO_hash_to_enc (&pid.hashPubKey, &enc);
+    fprintf (stdout, "%s\n", enc.encoding);
+  }
   GNUNET_CRYPTO_rsa_key_free (pk);
 }
 
@@ -77,9 +93,12 @@
 main (int argc, char *const *argv)
 {
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-    { 'p', "print", NULL,
+    { 'p', "print-public-key", NULL,
       gettext_noop ("print the public key in ASCII format"),
-      0, &GNUNET_GETOPT_set_one, &print },
+      0, &GNUNET_GETOPT_set_one, &print_public_key },
+    { 'P', "print-peer-identity", NULL,
+      gettext_noop ("print the hash of the public key in ASCII format"),
+      0, &GNUNET_GETOPT_set_one, &print_peer_identity },
     GNUNET_GETOPT_OPTION_END
   };
   return (GNUNET_OK ==




reply via email to

[Prev in Thread] Current Thread [Next in Thread]