From 6c8e9a33783efe1a066a1ca9a4db6a54cad5101d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 20 Feb 2024 16:07:48 +0000 Subject: [PATCH] [Minor] Allow to have only dynamic keys in fuzzy storage --- src/fuzzy_storage.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index efa53b15b..b4d2b802b 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -1628,7 +1628,7 @@ rspamd_fuzzy_decrypt_command(struct fuzzy_session *s, guchar *buf, gsize buflen) struct rspamd_cryptobox_pubkey *rk; struct fuzzy_key *key = NULL; - if (s->ctx->default_key == NULL) { + if (s->ctx->default_key == NULL && s->ctx->dynamic_keys == NULL) { msg_warn("received encrypted request when encryption is not enabled"); return FALSE; } @@ -1661,6 +1661,12 @@ rspamd_fuzzy_decrypt_command(struct fuzzy_session *s, guchar *buf, gsize buflen) key = kh_val(s->ctx->keys, k); } + if (key == NULL) { + /* Cannot find any suitable decryption key */ + msg_debug("cannot find suitable decryption key"); + return FALSE; + } + /* Now process the remote pubkey */ rk = rspamd_pubkey_from_bin(hdr.pubkey, sizeof(hdr.pubkey), RSPAMD_KEYPAIR_KEX, RSPAMD_CRYPTOBOX_MODE_25519); -- 2.39.5