about summary refs log tree commit diff stats
path: root/src/omemo
diff options
context:
space:
mode:
Diffstat (limited to 'src/omemo')
-rw-r--r--src/omemo/crypto.c5
-rw-r--r--src/omemo/crypto.h5
-rw-r--r--src/omemo/omemo.c5
-rw-r--r--src/omemo/omemo.h3
4 files changed, 9 insertions, 9 deletions
diff --git a/src/omemo/crypto.c b/src/omemo/crypto.c
index a05e160e..a4a2d5fc 100644
--- a/src/omemo/crypto.c
+++ b/src/omemo/crypto.c
@@ -35,7 +35,6 @@
 #include <assert.h>
 #include <signal/signal_protocol.h>
 #include <signal/signal_protocol_types.h>
-#include <gcrypt.h>
 
 #include "log.h"
 #include "omemo/omemo.h"
@@ -377,7 +376,7 @@ out:
     return res;
 }
 
-int
+gcry_error_t
 aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
                      unsigned char key[], unsigned char nonce[], bool encrypt)
 {
@@ -416,7 +415,7 @@ aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
     off_t bytes_read = 0, bytes_available = 0, read_size = 0;
     while (bytes_read < file_size) {
         bytes_available = file_size - bytes_read;
-        if (!bytes_available) {
+        if (!bytes_available || ferror(in) != 0) {
             break;
         }
 
diff --git a/src/omemo/crypto.h b/src/omemo/crypto.h
index c1d508b9..5adbffd8 100644
--- a/src/omemo/crypto.h
+++ b/src/omemo/crypto.h
@@ -35,6 +35,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <signal/signal_protocol_types.h>
+#include <gcrypt.h>
 
 #define AES128_GCM_KEY_LENGTH 16
 #define AES128_GCM_IV_LENGTH  12
@@ -183,8 +184,8 @@ int aes128gcm_decrypt(unsigned char* plaintext,
                       size_t ciphertext_len, const unsigned char* const iv, size_t iv_len,
                       const unsigned char* const key, const unsigned char* const tag);
 
-int aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
-                         unsigned char key[], unsigned char nonce[], bool encrypt);
+gcry_error_t aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
+                                  unsigned char key[], unsigned char nonce[], bool encrypt);
 
 char* aes256gcm_create_secure_fragment(unsigned char* key,
                                        unsigned char* nonce);
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index e19b724e..8b426320 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -1713,7 +1713,7 @@ _bytes_from_hex(const char* hex, size_t hex_size,
     }
 }
 
-int
+gcry_error_t
 omemo_decrypt_file(FILE* in, FILE* out, off_t file_size, const char* fragment)
 {
     char nonce_hex[AESGCM_URL_NONCE_LEN];
@@ -1733,7 +1733,8 @@ omemo_decrypt_file(FILE* in, FILE* out, off_t file_size, const char* fragment)
     _bytes_from_hex(key_hex, AESGCM_URL_KEY_LEN,
                     key, OMEMO_AESGCM_KEY_LENGTH);
 
-    int crypt_res = aes256gcm_crypt_file(in, out, file_size, key, nonce, false);
+    gcry_error_t crypt_res;
+    crypt_res = aes256gcm_crypt_file(in, out, file_size, key, nonce, false);
 
     gcry_free(key);
 
diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h
index a0e89916..d90f11cf 100644
--- a/src/omemo/omemo.h
+++ b/src/omemo/omemo.h
@@ -101,6 +101,5 @@ char* omemo_on_message_send(ProfWin* win, const char* const message, gboolean re
 char* omemo_on_message_recv(const char* const from, uint32_t sid, const unsigned char* const iv, size_t iv_len, GList* keys, const unsigned char* const payload, size_t payload_len, gboolean muc, gboolean* trusted);
 
 char* omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res);
-int omemo_decrypt_file(FILE* in, FILE* out, off_t file_size, const char* fragment);
-void omemo_free(void* a);
+gcry_error_t omemo_decrypt_file(FILE* in, FILE* out, off_t file_size, const char* fragment); void omemo_free(void* a);
 int omemo_parse_aesgcm_url(const char* aesgcm_url, char** https_url, char** fragment);