From 93e3d6b7a96eed644e9bfd260e45a23f775e334d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 3 Jan 2023 21:06:05 +0000 Subject: [Minor] Add extensions to the keypairs --- src/libcryptobox/keypair.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libcryptobox/keypair.c') diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c index ce9a9200d..da26fcff7 100644 --- a/src/libcryptobox/keypair.c +++ b/src/libcryptobox/keypair.c @@ -212,6 +212,11 @@ rspamd_cryptobox_keypair_dtor (struct rspamd_cryptobox_keypair *kp) sk = rspamd_cryptobox_keypair_sk (kp, &len); g_assert (sk != NULL && len > 0); rspamd_explicit_memzero (sk, len); + + if (kp->extensions) { + ucl_object_unref (kp->extensions); + } + /* Not g_free as kp is aligned using posix_memalign */ free (kp); } @@ -763,6 +768,12 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) rspamd_cryptobox_hash (kp->id, target, len, NULL, 0); + elt = ucl_object_lookup (obj, "extensions"); + if (elt && ucl_object_type (elt) == UCL_OBJECT) { + /* Use copy to avoid issues with the refcounts */ + kp->extensions = ucl_object_copy (elt); + } + return kp; } @@ -829,6 +840,11 @@ rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp, "kex" : "sign"), "type", 0, false); + if (kp->extensions) { + ucl_object_insert_key (elt, ucl_object_copy (kp->extensions), + "extensions", 0, false); + } + return ucl_out; } -- cgit v1.2.3