]> source.dussan.org Git - rspamd.git/commitdiff
Add keypair generation routine.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 28 Jan 2015 22:25:43 +0000 (22:25 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 28 Jan 2015 22:25:43 +0000 (22:25 +0000)
src/libutil/http.c
src/libutil/http.h

index 81771987dd7af52946543fe800f1238b46b4dba8..23db6b3a3db4859c2ae8b5b7cdbbaeb3daf2ef41 100644 (file)
@@ -1612,6 +1612,20 @@ rspamd_http_connection_make_key (gchar *key, gsize keylen)
        return FALSE;
 }
 
+gpointer
+rspamd_http_connection_gen_key (void)
+{
+       struct rspamd_http_keypair *kp;
+
+       kp = g_slice_alloc (sizeof (*kp));
+       REF_INIT_RETAIN (kp, rspamd_http_keypair_dtor);
+
+       crypto_box_keypair (kp->pk, kp->sk);
+       blake2b (kp->id, kp->pk, NULL, sizeof (kp->id), sizeof (kp->pk), 0);
+
+       return (gpointer)kp;
+}
+
 void
 rspamd_http_connection_set_key (struct rspamd_http_connection *conn,
                gpointer key)
index fdb12bf355d1608734d5d8eff17b1bc81ee625d5..d88424626caba6fe5ca981bef18ed751a6ea239b 100644 (file)
@@ -155,6 +155,12 @@ struct rspamd_http_connection * rspamd_http_connection_new (
  */
 gpointer rspamd_http_connection_make_key (gchar *key, gsize keylen);
 
+/**
+ * Generate the encryption keypair
+ * @return opaque pointer pr NULL in case of error
+ */
+gpointer rspamd_http_connection_gen_key (void);
+
 /**
  * Set key pointed by an opaque pointer
  * @param conn connection structure