diff options
Diffstat (limited to 'src/libcryptobox/keypair.c')
-rw-r--r-- | src/libcryptobox/keypair.c | 16 |
1 files changed, 11 insertions, 5 deletions
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; } |