aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcryptobox/keypair.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-01-04 12:46:56 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-01-04 12:46:56 +0000
commit27d878daa1f97dd40afc69d5bcb1ae23eb6c3b29 (patch)
tree28093bb2dd6006dd4a0d2fa8c1e797ce9c7aae3c /src/libcryptobox/keypair.c
parentff3f5692fa1fc1ac105cee876bffaf9b4e2a0c99 (diff)
downloadrspamd-27d878daa1f97dd40afc69d5bcb1ae23eb6c3b29.tar.gz
rspamd-27d878daa1f97dd40afc69d5bcb1ae23eb6c3b29.zip
[Minor] Allow different dump types for the keypairs
Diffstat (limited to 'src/libcryptobox/keypair.c')
-rw-r--r--src/libcryptobox/keypair.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c
index 98e2322d3..b97cd699e 100644
--- a/src/libcryptobox/keypair.c
+++ b/src/libcryptobox/keypair.c
@@ -787,7 +787,7 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj)
ucl_object_t *
rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp,
- gboolean is_hex)
+ enum rspamd_keypair_dump_flags flags)
{
ucl_object_t *ucl_out, *elt;
gint how = 0;
@@ -796,7 +796,7 @@ rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp,
g_assert (kp != NULL);
- if (is_hex) {
+ if (flags & RSPAMD_KEYPAIR_DUMP_HEX) {
how |= RSPAMD_KEYPAIR_HEX;
encoding = "hex";
}
@@ -817,13 +817,15 @@ rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp,
"pubkey", 0, false);
g_string_free (keypair_out, TRUE);
- /* privkey part */
- keypair_out = rspamd_keypair_print (kp,
- RSPAMD_KEYPAIR_PRIVKEY|how);
- ucl_object_insert_key (elt,
- ucl_object_fromlstring (keypair_out->str, keypair_out->len),
+ if (!(flags & RSPAMD_KEYPAIR_DUMP_NO_SECRET)) {
+ /* privkey part */
+ keypair_out = rspamd_keypair_print(kp,
+ RSPAMD_KEYPAIR_PRIVKEY | how);
+ ucl_object_insert_key(elt,
+ ucl_object_fromlstring(keypair_out->str, keypair_out->len),
"privkey", 0, false);
- g_string_free (keypair_out, TRUE);
+ g_string_free(keypair_out, TRUE);
+ }
keypair_out = rspamd_keypair_print (kp,
RSPAMD_KEYPAIR_ID|how);