ucl_object_insert_key (elt, ip_elt, "ips", 0, false);
}
- ucl_object_insert_key (elt, rspamd_keypair_to_ucl (fuzzy_key->key, FALSE),
+ ucl_object_insert_key (elt, rspamd_keypair_to_ucl (fuzzy_key->key, RSPAMD_KEYPAIR_DUMP_NO_SECRET),
"keypair", 0, false);
ucl_object_insert_key (keys_obj, elt, keyname, 0, true);
}
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;
g_assert (kp != NULL);
- if (is_hex) {
+ if (flags & RSPAMD_KEYPAIR_DUMP_HEX) {
how |= RSPAMD_KEYPAIR_HEX;
encoding = "hex";
}
"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);
*/
struct rspamd_cryptobox_keypair *rspamd_keypair_from_ucl (const ucl_object_t *obj);
+
+enum rspamd_keypair_dump_flags {
+ RSPAMD_KEYPAIR_DUMP_DEFAULT = 0,
+ RSPAMD_KEYPAIR_DUMP_HEX = 1u << 0u,
+ RSPAMD_KEYPAIR_DUMP_NO_SECRET = 1u << 1u,
+};
+
/**
* Converts keypair to ucl object
* @param kp
* @return
*/
ucl_object_t *rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp,
- gboolean is_hex);
+ enum rspamd_keypair_dump_flags flags);
/**
hex = lua_toboolean (L, 2);
}
- obj = rspamd_keypair_to_ucl (kp, hex);
+ obj = rspamd_keypair_to_ucl (kp, hex ? RSPAMD_KEYPAIR_DUMP_HEX : RSPAMD_KEYPAIR_DUMP_DEFAULT);
ret = ucl_object_push_lua (L, obj, true);
ucl_object_unref (obj);