From 1458b09e27e581456b30434a68e1070a4c017eb0 Mon Sep 17 00:00:00 2001 From: Karel Balej Date: Wed, 8 Apr 2026 23:06:00 +0200 Subject: [PATCH] fix(omemo): ignore key contents if there is no payload For key transport messages, Monal at least doesn't append the authentication tag to the plaintext key contents as that only makes sense if the key was used to encrypt something. This causes the key length check to fail and show the OMEMO message received but decryption failed. error to the user which is confusing because there is no user-originated message involved. Skip the length check for key transport messages as profanity only uses these to advance the ratchet and makes no use of the decrypted contents. Signed-off-by: Karel Balej --- src/omemo/omemo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 2a12fe778..f47b1f486 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -1141,16 +1141,16 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid, return NULL; } - if (signal_buffer_len(plaintext_key) != AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH) { - log_error("[OMEMO][RECV] invalid key length"); + if (payload == NULL) { signal_buffer_free(plaintext_key); - *error = OMEMO_ERR_DECRYPT_FAILED; + *error = OMEMO_ERR_KEY_TRANSPORT; return NULL; } - if (payload == NULL) { + if (signal_buffer_len(plaintext_key) != AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH) { + log_error("[OMEMO][RECV] invalid key length"); signal_buffer_free(plaintext_key); - *error = OMEMO_ERR_KEY_TRANSPORT; + *error = OMEMO_ERR_DECRYPT_FAILED; return NULL; }