diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-01-03 21:06:05 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-01-03 21:06:05 +0000 |
commit | 93e3d6b7a96eed644e9bfd260e45a23f775e334d (patch) | |
tree | 5073a0e263b14f49b4a5d5b1401970fbc015efe6 /src/libcryptobox/keypair.c | |
parent | 955fb068cd72005c7277c5f0f3c2347144dbc6ea (diff) | |
download | rspamd-93e3d6b7a96eed644e9bfd260e45a23f775e334d.tar.gz rspamd-93e3d6b7a96eed644e9bfd260e45a23f775e334d.zip |
[Minor] Add extensions to the keypairs
Diffstat (limited to 'src/libcryptobox/keypair.c')
-rw-r--r-- | src/libcryptobox/keypair.c | 16 |
1 files changed, 16 insertions, 0 deletions
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; } |