-change vpn wire data format
[oweals/gnunet.git] / src / include / gnunet_crypto_lib.h
index 879b1cae20deadecf0e1de5b8dd4ca8381c2367e..b73d26d1e860422982690244577bed51cf81c21b 100644 (file)
@@ -859,15 +859,6 @@ GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts,
                    size_t xts_len, const void *skm, size_t skm_len, ...);
 
 
-/**
- * Create a new private key. Caller must free return value.
- *
- * @return fresh private key
- */
-struct GNUNET_CRYPTO_RsaPrivateKey *
-GNUNET_CRYPTO_rsa_key_create (void);
-
-
 /**
  * Convert a public key to a string.
  *
@@ -895,12 +886,12 @@ GNUNET_CRYPTO_rsa_public_key_from_string (const char *enc,
 /**
  * Encode the private key in a format suitable for
  * storing it into a file.
- * @returns encoding of the private key.
- *    The first 4 bytes give the size of the array, as usual.
+ * @return encoding of the private key
  */
 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *
 GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey);
 
+
 /**
  * Decode the private key from the data-format back
  * to the "normal", internal format.
@@ -911,6 +902,7 @@ GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey)
 struct GNUNET_CRYPTO_RsaPrivateKey *
 GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len);
 
+
 /**
  * Create a new private key by reading it from a file.  If the
  * files does not exist, create a new key and write it to the
@@ -924,11 +916,56 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len);
  * @param filename name of file to use for storage
  * @return new private key, NULL on error (for example,
  *   permission denied)
+ * @deprecated use 'GNUNET_CRYPTO_rsa_key_create_start' instead
  */
 struct GNUNET_CRYPTO_RsaPrivateKey *
 GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename);
 
 
+/**
+ * Handle to cancel private key generation.
+ */
+struct GNUNET_CRYPTO_RsaKeyGenerationContext;
+
+
+/**
+ * Function called upon completion of 'GNUNET_CRYPTO_rsa_key_create_async'.
+ *
+ * @param cls closure
+ * @param pk NULL on error, otherwise the private key (which must be free'd by the callee)
+ * @param emsg NULL on success, otherwise an error message
+ */
+typedef void (*GNUNET_CRYPTO_RsaKeyCallback)(void *cls,
+                                            struct GNUNET_CRYPTO_RsaPrivateKey *pk,
+                                            const char *emsg);
+
+
+/**
+ * Create a new private key by reading it from a file.  If the files
+ * does not exist, create a new key and write it to the file.  If the
+ * contents of the file are invalid the old file is deleted and a
+ * fresh key is created.
+ *
+ * @param filename name of file to use for storage
+ * @param cont function to call when done (or on errors)
+ * @param cont_cls closure for 'cont'
+ * @return handle to abort operation, NULL on fatal errors (cont will not be called if NULL is returned)
+ */
+struct GNUNET_CRYPTO_RsaKeyGenerationContext *
+GNUNET_CRYPTO_rsa_key_create_start (const char *filename,
+                                   GNUNET_CRYPTO_RsaKeyCallback cont,
+                                   void *cont_cls);
+
+
+/**
+ * Abort RSA key generation.
+ *
+ * @param gc key generation context to abort
+ */
+void
+GNUNET_CRYPTO_rsa_key_create_stop (struct GNUNET_CRYPTO_RsaKeyGenerationContext *gc);
+
+
 /**
  * Setup a hostkey file for a peer given the name of the
  * configuration file (!).  This function is used so that