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 <balejk@matfyz.cz>
This commit is contained in:
@@ -1141,6 +1141,12 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (payload == NULL) {
|
||||
signal_buffer_free(plaintext_key);
|
||||
*error = OMEMO_ERR_KEY_TRANSPORT;
|
||||
return 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);
|
||||
@@ -1148,12 +1154,6 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (payload == NULL) {
|
||||
signal_buffer_free(plaintext_key);
|
||||
*error = OMEMO_ERR_KEY_TRANSPORT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t plaintext_len = payload_len;
|
||||
plaintext = malloc(plaintext_len + 1);
|
||||
res = aes128gcm_decrypt(plaintext, &plaintext_len, payload, payload_len, iv,
|
||||
|
||||
Reference in New Issue
Block a user