]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Avoid another copy of key schedule pointer in PROV_GCM_CTX
authorTomas Mraz <tomas@openssl.org>
Fri, 13 Oct 2023 14:22:59 +0000 (16:22 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 16 Oct 2023 10:12:36 +0000 (12:12 +0200)
This copy would need an update on dupctx but
rather than doing it just remove the copy.

This fixes failures of evp_test on Windows with
new CPUs.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22384)

providers/implementations/ciphers/cipher_aes_gcm_hw_vaes_avx512.inc
providers/implementations/ciphers/cipher_sm4_gcm_hw.c
providers/implementations/include/prov/ciphercommon_gcm.h

index ef18677979a6f99428843960d0ce261d373bf9e0..c892c0754e8d52dda620ac274e3d5a6827225290 100644 (file)
@@ -48,7 +48,6 @@ static int vaes_gcm_setkey(PROV_GCM_CTX *ctx, const unsigned char *key,
     PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx;
     AES_KEY *ks = &actx->ks.ks;
 
-    ctx->ks = ks;
     aesni_set_encrypt_key(key, keylen * 8, ks);
     memset(gcmctx, 0, sizeof(*gcmctx));
     gcmctx->key = ks;
@@ -77,7 +76,7 @@ static int vaes_gcm_setiv(PROV_GCM_CTX *ctx, const unsigned char *iv,
     if (ivlen > (U64(1) << 61))
         return 0;
 
-    ossl_aes_gcm_setiv_avx512(ctx->ks, gcmctx, iv, ivlen);
+    ossl_aes_gcm_setiv_avx512(gcmctx->key, gcmctx, iv, ivlen);
 
     return 1;
 }
@@ -162,9 +161,9 @@ static int vaes_gcm_cipherupdate(PROV_GCM_CTX *ctx, const unsigned char *in,
     }
 
     if (ctx->enc)
-        ossl_aes_gcm_encrypt_avx512(ctx->ks, gcmctx, &gcmctx->mres, in, len, out);
+        ossl_aes_gcm_encrypt_avx512(gcmctx->key, gcmctx, &gcmctx->mres, in, len, out);
     else
-        ossl_aes_gcm_decrypt_avx512(ctx->ks, gcmctx, &gcmctx->mres, in, len, out);
+        ossl_aes_gcm_decrypt_avx512(gcmctx->key, gcmctx, &gcmctx->mres, in, len, out);
 
     return 1;
 }
index 432e3589ed86dbf88fbd34242bb92c5970306761..630d8a3218e8fef3ee9affe777ae92bd54c80ef2 100644 (file)
@@ -15,7 +15,6 @@
 #include "crypto/sm4_platform.h"
 
 # define SM4_GCM_HW_SET_KEY_CTR_FN(ks, fn_set_enc_key, fn_block, fn_ctr)       \
-    ctx->ks = ks;                                                              \
     fn_set_enc_key(key, ks);                                                   \
     CRYPTO_gcm128_init(&ctx->gcm, ks, (block128_f)fn_block);                   \
     ctx->ctr = (ctr128_f)fn_ctr;                                               \
index 3aacf91c8b5d05fa22c96e8ef269e553eca449cb..ee0b23b92785da99e6bbdfc27ceb3581316ddbeb 100644 (file)
@@ -79,7 +79,6 @@ typedef struct prov_gcm_ctx_st {
     const PROV_GCM_HW *hw;  /* hardware specific methods */
     GCM128_CONTEXT gcm;
     ctr128_f ctr;
-    const void *ks;
 } PROV_GCM_CTX;
 
 PROV_CIPHER_FUNC(int, GCM_setkey, (PROV_GCM_CTX *ctx, const unsigned char *key,
@@ -126,7 +125,6 @@ int ossl_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in,
                            size_t len, unsigned char *out);
 
 # define GCM_HW_SET_KEY_CTR_FN(ks, fn_set_enc_key, fn_block, fn_ctr)            \
-    ctx->ks = ks;                                                              \
     fn_set_enc_key(key, keylen * 8, ks);                                       \
     CRYPTO_gcm128_init(&ctx->gcm, ks, (block128_f)fn_block);                   \
     ctx->ctr = (ctr128_f)fn_ctr;                                               \