aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_rsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r--src/util/crypto_rsa.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 418fe833b..5e3a7762e 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -107,7 +107,9 @@ adjust (unsigned char *buf, size_t size, size_t target)
107} 107}
108 108
109/** 109/**
110 * This HostKey implementation uses RSA. 110 * Create a new private key. Caller must free return value.
111 *
112 * @return fresh private key
111 */ 113 */
112struct GNUNET_CRYPTO_RsaPrivateKey * 114struct GNUNET_CRYPTO_RsaPrivateKey *
113GNUNET_CRYPTO_rsa_key_create () 115GNUNET_CRYPTO_rsa_key_create ()
@@ -132,6 +134,7 @@ GNUNET_CRYPTO_rsa_key_create ()
132 134
133/** 135/**
134 * Free memory occupied by hostkey 136 * Free memory occupied by hostkey
137 * @param hostkey pointer to the memory to free
135 */ 138 */
136void 139void
137GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) 140GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey)
@@ -743,6 +746,34 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
743 746
744 747
745/** 748/**
749 * Setup a hostkey file for a peer given the name of the
750 * configuration file (!). This function is used so that
751 * at a later point code can be certain that reading a
752 * hostkey is fast (for example in time-dependent testcases).
753 *
754 * @param cfg_name name of the configuration file to use
755 */
756void
757GNUNET_CRYPTO_setup_hostkey (const char *cfg_name)
758{
759 struct GNUNET_CONFIGURATION_Handle *cfg;
760 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
761 char *fn;
762
763 cfg = GNUNET_CONFIGURATION_create ();
764 (void) GNUNET_CONFIGURATION_load (cfg, cfg_name);
765 if (GNUNET_OK ==
766 GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", &fn))
767 {
768 pk = GNUNET_CRYPTO_rsa_key_create_from_file (fn);
769 if (NULL != pk)
770 GNUNET_CRYPTO_rsa_key_free (pk);
771 }
772 GNUNET_CONFIGURATION_destroy (cfg);
773}
774
775
776/**
746 * Encrypt a block with the public key of another host that uses the 777 * Encrypt a block with the public key of another host that uses the
747 * same cipher. 778 * same cipher.
748 * 779 *