s390x assembly pack: allow specifying the tag after aad in aes-ccm
authorPatrick Steuer <patrick.steuer@de.ibm.com>
Tue, 21 May 2019 17:10:28 +0000 (19:10 +0200)
committerPatrick Steuer <patrick.steuer@de.ibm.com>
Wed, 22 May 2019 08:57:50 +0000 (10:57 +0200)
67c81ec311 forgot about s390x

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8971)

crypto/evp/e_aes.c

index 6d8d4370a7bcdd49074c68a0a31a483d7286aacb..c9dbca98d7180ba0ad72f411073da6917931d004 100644 (file)
@@ -2264,9 +2264,6 @@ static int s390x_aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
     if (!cctx->aes.ccm.iv_set)
         return -1;
 
-    if (!enc && !cctx->aes.ccm.tag_set)
-        return -1;
-
     if (out == NULL) {
         /* Update(): Pass message length. */
         if (in == NULL) {
@@ -2285,6 +2282,10 @@ static int s390x_aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
         return len;
     }
 
+    /* The tag must be set before actually decrypting data */
+    if (!enc && !cctx->aes.ccm.tag_set)
+        return -1;
+
     /* Update(): Process message. */
 
     if (!cctx->aes.ccm.len_set) {