Browse Source

[Minor] Add extensions to the keypairs

tags/3.5
Vsevolod Stakhov 1 year ago
parent
commit
93e3d6b7a9
No account linked to committer's email address
2 changed files with 17 additions and 0 deletions
  1. 16
    0
      src/libcryptobox/keypair.c
  2. 1
    0
      src/libcryptobox/keypair_private.h

+ 16
- 0
src/libcryptobox/keypair.c View File

@@ -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;
}


+ 1
- 0
src/libcryptobox/keypair_private.h View File

@@ -39,6 +39,7 @@ struct rspamd_cryptobox_keypair {
guchar id[rspamd_cryptobox_HASHBYTES];
enum rspamd_cryptobox_keypair_type type;
enum rspamd_cryptobox_mode alg;
ucl_object_t *extensions;
ref_entry_t ref;
};


Loading…
Cancel
Save