struct rspamd_rcl_struct_parser *pd = ud;
struct rspamd_cryptobox_keypair **target, *kp;
-
target = (struct rspamd_cryptobox_keypair **)(((gchar *)pd->user_struct) +
pd->offset);
if (obj->type == UCL_OBJECT) {
return TRUE;
}
+gboolean
+rspamd_rcl_parse_struct_pubkey (rspamd_mempool_t *pool,
+ const ucl_object_t *obj,
+ gpointer ud,
+ struct rspamd_rcl_section *section,
+ GError **err)
+{
+ struct rspamd_rcl_struct_parser *pd = ud;
+ struct rspamd_cryptobox_pubkey **target, *pk;
+ gsize len;
+ const gchar *str;
+
+ target = (struct rspamd_cryptobox_pubkey **)(((gchar *)pd->user_struct) +
+ pd->offset);
+ if (obj->type == UCL_STRING) {
+ str = ucl_object_tolstring (obj, &len);
+ pk = rspamd_pubkey_from_base32 (str, len, RSPAMD_KEYPAIR_KEX,
+ RSPAMD_CRYPTOBOX_MODE_25519);
+
+ if (pk != NULL) {
+ *target = pk;
+ }
+ else {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "cannot load the pubkey specified: %s",
+ ucl_object_key (obj));
+ return FALSE;
+ }
+ }
+ else {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "no sane pubkey found in the element: %s",
+ ucl_object_key (obj));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
rspamd_rcl_insert_string_list_item (gpointer *target, rspamd_mempool_t *pool,
const gchar *src, gboolean is_hash)
struct rspamd_rcl_section *section,
GError **err);
+/**
+ * Parse a pubkey field of a structure
+ * @param cfg config pointer
+ * @param obj object to parse
+ * @param ud struct_parser structure (flags mean the exact structure used)
+ * @param section the current section
+ * @param err error pointer
+ * @return TRUE if a value has been successfully parsed
+ */
+gboolean rspamd_rcl_parse_struct_pubkey (rspamd_mempool_t *pool,
+ const ucl_object_t *obj,
+ gpointer ud,
+ struct rspamd_rcl_section *section,
+ GError **err);
+
/**
* Parse a inet addr field of a structure
* @param cfg config pointer