Skip to content

Commit 2c266df

Browse files
committed
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 <balejk@matfyz.cz>
1 parent 95eb1ef commit 2c266df

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/omemo/omemo.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,16 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
11411141
return NULL;
11421142
}
11431143

1144-
if (signal_buffer_len(plaintext_key) != AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH) {
1145-
log_error("[OMEMO][RECV] invalid key length");
1144+
if (payload == NULL) {
11461145
signal_buffer_free(plaintext_key);
1147-
*error = OMEMO_ERR_DECRYPT_FAILED;
1146+
*error = OMEMO_ERR_KEY_TRANSPORT;
11481147
return NULL;
11491148
}
11501149

1151-
if (payload == NULL) {
1150+
if (signal_buffer_len(plaintext_key) != AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH) {
1151+
log_error("[OMEMO][RECV] invalid key length");
11521152
signal_buffer_free(plaintext_key);
1153-
*error = OMEMO_ERR_KEY_TRANSPORT;
1153+
*error = OMEMO_ERR_DECRYPT_FAILED;
11541154
return NULL;
11551155
}
11561156

0 commit comments

Comments
 (0)