From d9879cd7848a147c0b3056336cb982bbc9a1e247 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 6 Feb 2016 14:31:22 +0000 Subject: Fix more issues remaining --- src/libcryptobox/keypair.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/libcryptobox') diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c index e645ef3e0..d8e160af1 100644 --- a/src/libcryptobox/keypair.c +++ b/src/libcryptobox/keypair.c @@ -695,11 +695,13 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) /* TODO: handle errors */ } - kp = rspamd_keypair_new (type, mode); + kp = rspamd_cryptobox_keypair_alloc (type, mode); + kp->type = type; + kp->alg = mode; g_assert (kp != NULL); - target = rspamd_cryptobox_keypair_pk (kp, &len); - str = ucl_object_tolstring (pubkey, &ucl_len); + target = rspamd_cryptobox_keypair_sk (kp, &len); + str = ucl_object_tolstring (privkey, &ucl_len); if (is_hex) { dec_len = rspamd_decode_hex_buf (str, ucl_len, target, len); @@ -714,8 +716,8 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) return NULL; } - target = rspamd_cryptobox_keypair_sk (kp, &len); - str = ucl_object_tolstring (privkey, &ucl_len); + target = rspamd_cryptobox_keypair_pk (kp, &len); + str = ucl_object_tolstring (pubkey, &ucl_len); if (is_hex) { dec_len = rspamd_decode_hex_buf (str, ucl_len, target, len); @@ -730,6 +732,10 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) return NULL; } + rspamd_cryptobox_hash (kp->id, target, len, NULL, 0); + + REF_INIT_RETAIN (kp, rspamd_cryptobox_keypair_dtor); + return kp; } -- cgit v1.2.3