about summary refs log tree commit diff stats
path: root/src/omemo/crypto.c
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-03-06 21:27:25 +0220
committerPaul Fariello <paul@fariello.eu>2019-04-10 16:31:45 +0200
commitda0376a6a9b83756efffed6fb24fafd72f0fc36e (patch)
tree0d9dc515158b9b5798ec357a489b89bcabfe24c9 /src/omemo/crypto.c
parentb0c52f84ab419918d4dd0ab1fd3f9755b3687c93 (diff)
downloadprofani-tty-da0376a6a9b83756efffed6fb24fafd72f0fc36e.tar.gz
Check received gcm tag
Diffstat (limited to 'src/omemo/crypto.c')
-rw-r--r--src/omemo/crypto.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/omemo/crypto.c b/src/omemo/crypto.c
index d959020b..9d64a701 100644
--- a/src/omemo/crypto.c
+++ b/src/omemo/crypto.c
@@ -295,7 +295,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)
+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)
 {
     gcry_error_t res;
     gcry_cipher_hd_t hd;
@@ -319,10 +319,11 @@ aes128gcm_decrypt(unsigned char *plaintext, size_t *plaintext_len, const unsigne
     if (res != GPG_ERR_NO_ERROR) {
         goto out;
     }
-    //res = gcry_cipher_checktag(hd, ciphertext + ciphertext_len - AES128_GCM_TAG_LENGTH, AES128_GCM_TAG_LENGTH);
-    //if (res != GPG_ERR_NO_ERROR) {
-    //    goto out;
-    //}
+
+    res = gcry_cipher_checktag(hd, tag, AES128_GCM_TAG_LENGTH);
+    if (res != GPG_ERR_NO_ERROR) {
+        goto out;
+    }
 
 out:
     gcry_cipher_close(hd);