gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20127 - in gnunet/src: include util vpn


From: gnunet
Subject: [GNUnet-SVN] r20127 - in gnunet/src: include util vpn
Date: Tue, 28 Feb 2012 20:08:20 +0100

Author: grothoff
Date: 2012-02-28 20:08:20 +0100 (Tue, 28 Feb 2012)
New Revision: 20127

Modified:
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/util/crypto_rsa.c
   gnunet/src/vpn/test_gnunet_vpn.c
Log:
adding GNUNET_CRYPTO_setup_hostkey to setup a hostkey ahead of time, using this 
function in the VPN testcases to avoid timeouts in cases where creating a 
hostkey just takes too long --- such as on our UltraSprac

Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2012-02-28 18:53:39 UTC (rev 
20126)
+++ gnunet/src/include/gnunet_crypto_lib.h      2012-02-28 19:08:20 UTC (rev 
20127)
@@ -764,6 +764,18 @@
 
 
 /**
+ * Setup a hostkey file for a peer given the name of the
+ * configuration file (!).  This function is used so that
+ * at a later point code can be certain that reading a
+ * hostkey is fast (for example in time-dependent testcases).
+ *
+ * @param cfg_name name of the configuration file to use
+ */
+void
+GNUNET_CRYPTO_setup_hostkey (const char *cfg_name);
+
+
+/**
  * Deterministically (!) create a private key using only the
  * given HashCode as input to the PRNG.
  *

Modified: gnunet/src/util/crypto_rsa.c
===================================================================
--- gnunet/src/util/crypto_rsa.c        2012-02-28 18:53:39 UTC (rev 20126)
+++ gnunet/src/util/crypto_rsa.c        2012-02-28 19:08:20 UTC (rev 20127)
@@ -107,7 +107,9 @@
 }
 
 /**
- * This HostKey implementation uses RSA.
+ * Create a new private key. Caller must free return value.
+ *
+ * @return fresh private key
  */
 struct GNUNET_CRYPTO_RsaPrivateKey *
 GNUNET_CRYPTO_rsa_key_create ()
@@ -132,6 +134,7 @@
 
 /**
  * Free memory occupied by hostkey
+ * @param hostkey pointer to the memory to free
  */
 void
 GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey)
@@ -743,6 +746,34 @@
 
 
 /**
+ * Setup a hostkey file for a peer given the name of the
+ * configuration file (!).  This function is used so that
+ * at a later point code can be certain that reading a
+ * hostkey is fast (for example in time-dependent testcases).
+ *
+ * @param cfg_name name of the configuration file to use
+ */
+void
+GNUNET_CRYPTO_setup_hostkey (const char *cfg_name)
+{
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  struct GNUNET_CRYPTO_RsaPrivateKey *pk;
+  char *fn;
+
+  cfg = GNUNET_CONFIGURATION_create ();
+  (void) GNUNET_CONFIGURATION_load (cfg, cfg_name);
+  if (GNUNET_OK == 
+      GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", &fn))
+  {
+    pk = GNUNET_CRYPTO_rsa_key_create_from_file (fn);
+    if (NULL != pk)
+      GNUNET_CRYPTO_rsa_key_free (pk);
+  }
+  GNUNET_CONFIGURATION_destroy (cfg);
+}
+
+
+/**
  * Encrypt a block with the public key of another host that uses the
  * same cipher.
  *

Modified: gnunet/src/vpn/test_gnunet_vpn.c
===================================================================
--- gnunet/src/vpn/test_gnunet_vpn.c    2012-02-28 18:53:39 UTC (rev 20126)
+++ gnunet/src/vpn/test_gnunet_vpn.c    2012-02-28 19:08:20 UTC (rev 20127)
@@ -515,7 +515,7 @@
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
-
+  
   if (0 != ACCESS ("/dev/net/tun", R_OK))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
@@ -536,6 +536,7 @@
             "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is 
problematic) or permissions (run 'make install' as root) to fix this!\n");
     return 0;
   }
+  GNUNET_CRYPTO_setup_hostkey ("test_gnunet_vpn.conf");
   bin = argv[0];
   if (NULL != strstr (bin, "lt-"))
     bin = strstr (bin, "lt-") + 4;




reply via email to

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