From: Vsevolod Stakhov Date: Wed, 28 Jan 2015 22:25:43 +0000 (+0000) Subject: Add keypair generation routine. X-Git-Tag: 0.9.0~817^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aa110b0b4b6173cd58366eeeea338b6dcf668475;p=rspamd.git Add keypair generation routine. --- diff --git a/src/libutil/http.c b/src/libutil/http.c index 81771987d..23db6b3a3 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -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) diff --git a/src/libutil/http.h b/src/libutil/http.h index fdb12bf35..d88424626 100644 --- a/src/libutil/http.h +++ b/src/libutil/http.h @@ -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