Reorganize local header files
[openssl.git] / providers / common / ciphers / cipher_gcm.c
index 9a61eabdfc546f95b5b43ce072edf78b87f18b3a..137ad5029c53daf402598172651744351615ac0e 100644 (file)
@@ -9,10 +9,10 @@
 
 /* Dispatch functions for gcm mode */
 
-#include "cipher_locl.h"
+#include "cipher_local.h"
 #include "internal/ciphers/cipher_gcm.h"
 #include "internal/providercommonerr.h"
-#include "internal/rand_int.h"
+#include "crypto/rand.h"
 #include "internal/provider_ctx.h"
 
 static int gcm_tls_init(PROV_GCM_CTX *dat, unsigned char *aad, size_t aad_len);
@@ -344,7 +344,9 @@ static int gcm_cipher_internal(PROV_GCM_CTX *ctx, unsigned char *out,
                 goto err;
         }
     } else {
-        /* Finished when in == NULL */
+        /* The tag must be set before actually decrypting data */
+        if (!ctx->enc && ctx->taglen == UNINITIALISED_SIZET)
+            goto err;
         if (!hw->cipherfinal(ctx, ctx->buf))
             goto err;
         ctx->iv_state = IV_STATE_FINISHED; /* Don't reuse the IV */