1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Add support for 12 bytes IV

16 bytes IV should be used. Some clients can't use it so we should also
support decrypting 12 bytes IV.

Fix #1253
This commit is contained in:
Paul Fariello 2020-01-20 13:13:31 +01:00
parent 69bf76761a
commit 8d1202efbd
3 changed files with 4 additions and 4 deletions

View File

@ -340,7 +340,7 @@ out:
}
int
aes128gcm_decrypt(unsigned char *plaintext, size_t *plaintext_len, const unsigned char *const ciphertext, size_t ciphertext_len, const unsigned char *const iv, const unsigned char *const key, const unsigned char *const tag)
aes128gcm_decrypt(unsigned char *plaintext, size_t *plaintext_len, const unsigned char *const ciphertext, size_t ciphertext_len, const unsigned char *const iv, size_t iv_len, const unsigned char *const key, const unsigned char *const tag)
{
gcry_error_t res;
gcry_cipher_hd_t hd;
@ -355,7 +355,7 @@ aes128gcm_decrypt(unsigned char *plaintext, size_t *plaintext_len, const unsigne
goto out;
}
res = gcry_cipher_setiv(hd, iv, AES128_GCM_IV_LENGTH);
res = gcry_cipher_setiv(hd, iv, iv_len);
if (res != GPG_ERR_NO_ERROR) {
goto out;
}

View File

@ -178,5 +178,5 @@ int aes128gcm_encrypt(unsigned char *ciphertext, size_t *ciphertext_len,
int aes128gcm_decrypt(unsigned char *plaintext,
size_t *plaintext_len, const unsigned char *const ciphertext,
size_t ciphertext_len, const unsigned char *const iv,
size_t ciphertext_len, const unsigned char *const iv, size_t iv_len,
const unsigned char *const key, const unsigned char *const tag);

View File

@ -955,7 +955,7 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid,
size_t plaintext_len = payload_len;
plaintext = malloc(plaintext_len + 1);
res = aes128gcm_decrypt(plaintext, &plaintext_len, payload, payload_len, iv,
signal_buffer_data(plaintext_key),
iv_len, signal_buffer_data(plaintext_key),
signal_buffer_data(plaintext_key) + AES128_GCM_KEY_LENGTH);
signal_buffer_free(plaintext_key);
if (res != 0) {