summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/Makefile.am1
-rw-r--r--doc/man/gnunet-rsa.134
-rw-r--r--src/util/Makefile.am14
-rw-r--r--src/util/gnunet-rsa.c92
4 files changed, 140 insertions, 1 deletions
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 6d98ffa5b..5b6f08ab5 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -8,6 +8,7 @@ man_MANS = \
gnunet-peerinfo.1 \
gnunet-pseudonym.1 \
gnunet-publish.1 \
+ gnunet-rsa.1 \
gnunet-search.1 \
gnunet-statistics.1 \
gnunet-transport.1 \
diff --git a/doc/man/gnunet-rsa.1 b/doc/man/gnunet-rsa.1
new file mode 100644
index 000000000..3d9aae8af
--- /dev/null
+++ b/doc/man/gnunet-rsa.1
@@ -0,0 +1,34 @@
+.TH GNUNET\-RSA 1 "Jan 4, 2012" "GNUnet"
+
+.SH NAME
+gnunet\-rsa \- manipulate GNUnet RSA key files
+
+.SH SYNOPSIS
+.B gnunet\-rsa
+.RI [ options ] FILENAME
+.br
+
+.SH DESCRIPTION
+\fBgnunet\-rsa\fP can be used to create an RSA private key and to print the corresponding public key. You must specify a filename containing an RSA private key in GNUnet format as an argument. If the file does not exist, gnunet\-rsa will create a key. This may then take a while. If the option \-p is given, the corresponding public key will be printed to the console.
+
+.SH OPTIONS
+.B
+.IP "\-p, \-\-print"
+Print the corresponding public key (to stdout).
+.B
+.IP "\-c FILENAME, \-\-config=FILENAME"
+Use the configuration file FILENAME.
+.B
+.IP "\-h, \-\-help"
+Print short help on options.
+.B
+.IP "\-L LOGLEVEL, \-\-loglevel=LOGLEVEL"
+Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR.
+.B
+.IP "\-v, \-\-version"
+Print GNUnet version number.
+
+
+.SH BUGS
+Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org>
+
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index cded34d17..2bda4e748 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -37,6 +37,7 @@ noinst_PROGRAMS = \
gnunet-config-diff \
test_common_logging_dummy
+
gnunet_config_diff_SOURCES = \
gnunet-config-diff.c
gnunet_config_diff_LDADD = \
@@ -114,7 +115,9 @@ libgnunetutil_la_LDFLAGS = \
bin_PROGRAMS = \
gnunet-service-resolver \
- gnunet-resolver
+ gnunet-resolver \
+ gnunet-rsa
+
gnunet_service_resolver_SOURCES = \
gnunet-service-resolver.c
@@ -133,6 +136,15 @@ gnunet_resolver_LDADD = \
gnunet_resolver_DEPENDENCIES = \
libgnunetutil.la
+
+gnunet_rsa_SOURCES = \
+ gnunet-rsa.c
+gnunet_rsa_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+gnunet_resolver_DEPENDENCIES = \
+ libgnunetutil.la
+
plugin_LTLIBRARIES = \
libgnunet_plugin_test.la
diff --git a/src/util/gnunet-rsa.c b/src/util/gnunet-rsa.c
new file mode 100644
index 000000000..ba0d16a74
--- /dev/null
+++ b/src/util/gnunet-rsa.c
@@ -0,0 +1,92 @@
+/*
+ This file is part of GNUnet.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file util/gnunet-rsa.c
+ * @brief tool to manipulate RSA key files
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_rsa_service.h"
+
+
+/**
+ * Flag for reverse lookup.
+ */
+static int print;
+
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct GNUNET_CRYPTO_RsaPrivateKey *pk;
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
+ char *s;
+
+ if (argc == 0)
+ {
+ fprintf (stderr, _("No hostkey file specified on command line\n"));
+ return;
+ }
+ pk = GNUNET_CRYPTO_rsa_key_create_from_file (argv[0]);
+ if (print)
+ {
+ 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);
+ }
+ GNUNET_CRYPTO_rsa_key_free (pk);
+}
+
+
+/**
+ * The main function to obtain statistics in GNUnet.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+ static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ { 'p', "print", NULL,
+ gettext_noop ("print the public key in ASCII format"),
+ 0, &GNUNET_GETOPT_set_one, &print },
+ GNUNET_GETOPT_OPTION_END
+ };
+ return (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc, argv, "gnunet-rsa [OPTIONS] keyfile",
+ gettext_noop ("Manipulate GNUnet private RSA key files"),
+ options, &run, NULL)) ? 0 : 1;
+}
+
+/* end of gnunet-rsa.c */