From: Simo Sorce Date: Mon, 8 Jun 2026 15:59:33 +0000 (-0400) Subject: Untangle rats nest of .inc files for AES_GCM X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=87efbd952873ebc99e22edcb2f6feaa48c7683ec;p=thirdparty%2Fopenssl.git Untangle rats nest of .inc files for AES_GCM These files have no reason not to be just regular .c files. Additionally apply formatting fixes which were not done on .inc files Signed-off-by: Simo Sorce Reviewed-by: Dmitry Belyavskiy Reviewed-by: Norbert Pocs Reviewed-by: Shane Lontis MergeDate: Sat Jun 27 09:05:35 2026 (Merged from https://github.com/openssl/openssl/pull/31472) --- diff --git a/providers/fips.module.sources b/providers/fips.module.sources index f9a12d71052..c5844932448 100644 --- a/providers/fips.module.sources +++ b/providers/fips.module.sources @@ -668,8 +668,13 @@ providers/implementations/ciphers/cipher_aes_cts.inc providers/implementations/ciphers/cipher_aes_gcm.c providers/implementations/ciphers/cipher_aes_gcm.h providers/implementations/ciphers/cipher_aes_gcm_hw.c -providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.inc -providers/implementations/ciphers/cipher_aes_gcm_hw_vaes_avx512.inc +providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.c +providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.c +providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.c +providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.c +providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.c +providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.c +providers/implementations/ciphers/cipher_aes_gcm_hw_t4.c providers/implementations/ciphers/cipher_aes_hw.c providers/implementations/ciphers/cipher_aes_hw_aesni.inc providers/implementations/ciphers/cipher_aes_ocb.c diff --git a/providers/implementations/ciphers/build.info b/providers/implementations/ciphers/build.info index dc43b8980c1..b724c0baa99 100644 --- a/providers/implementations/ciphers/build.info +++ b/providers/implementations/ciphers/build.info @@ -106,7 +106,10 @@ SOURCE[$AES_GOAL]=\ cipher_aes.c cipher_aes_hw.c \ cipher_aes_xts.c cipher_aes_xts_hw.c \ cipher_aes_cfb_hw.c \ - cipher_aes_gcm.c cipher_aes_gcm_hw.c \ + cipher_aes_gcm.c cipher_aes_gcm_hw.c cipher_aes_gcm_hw_aesni.c \ + cipher_aes_gcm_hw_armv8.c cipher_aes_gcm_hw_ppc.c \ + cipher_aes_gcm_hw_rv32i.c cipher_aes_gcm_hw_rv64i.c \ + cipher_aes_gcm_hw_s390x.c cipher_aes_gcm_hw_t4.c \ cipher_aes_ccm.c cipher_aes_ccm_hw.c \ cipher_aes_wrp.c \ cipher_aes_cbc_hmac_sha.c \ diff --git a/providers/implementations/ciphers/cipher_aes_gcm.h b/providers/implementations/ciphers/cipher_aes_gcm.h index 33819705dea..2b03c584b97 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm.h +++ b/providers/implementations/ciphers/cipher_aes_gcm.h @@ -45,6 +45,30 @@ typedef struct prov_aes_gcm_ctx_st { } plat; } PROV_AES_GCM_CTX; +int generic_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in, + size_t len, unsigned char *out); + const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits); +#if defined(AESNI_CAPABLE) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_aesni(size_t keybits); +#endif +#if defined(AES_PMULL_CAPABLE) && defined(AES_GCM_ASM) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_armv8(size_t keybits); +#endif +#if defined(PPC_AES_GCM_CAPABLE) && defined(_ARCH_PPC64) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_ppc(size_t keybits); +#endif +#if defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 64 +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_rv64i(size_t keybits); +#endif +#if defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 32 +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_rv32i(size_t keybits); +#endif +#if defined(S390X_aes_128_CAPABLE) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_s390x(size_t keybits); +#endif +#if defined(SPARC_AES_CAPABLE) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_t4(size_t keybits); +#endif #endif /* !defined(OSSL_PROVIDERS_IMPLEMENTATIONS_CIPHERS_CIPHER_AES_GCM_H) */ diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw.c b/providers/implementations/ciphers/cipher_aes_gcm_hw.c index d2b7437cde3..6d41cdb7005 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw.c +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw.c @@ -58,7 +58,7 @@ static int aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, return 1; } -static int generic_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in, +int generic_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in, size_t len, unsigned char *out) { if (ctx->enc) { @@ -132,23 +132,28 @@ static const PROV_GCM_HW aes_gcm = { ossl_gcm_one_shot }; -#if defined(S390X_aes_128_CAPABLE) -#include "cipher_aes_gcm_hw_s390x.inc" -#elif defined(AESNI_CAPABLE) -#include "cipher_aes_gcm_hw_aesni.inc" -#elif defined(SPARC_AES_CAPABLE) -#include "cipher_aes_gcm_hw_t4.inc" +const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) +{ + const PROV_GCM_HW *aes_gcm_hw = NULL; + +#if defined(AESNI_CAPABLE) + aes_gcm_hw = ossl_prov_aes_hw_gcm_aesni(keybits); #elif defined(AES_PMULL_CAPABLE) && defined(AES_GCM_ASM) -#include "cipher_aes_gcm_hw_armv8.inc" + aes_gcm_hw = ossl_prov_aes_hw_gcm_armv8(keybits); #elif defined(PPC_AES_GCM_CAPABLE) && defined(_ARCH_PPC64) -#include "cipher_aes_gcm_hw_ppc.inc" + aes_gcm_hw = ossl_prov_aes_hw_gcm_ppc(keybits); #elif defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 64 -#include "cipher_aes_gcm_hw_rv64i.inc" + aes_gcm_hw = ossl_prov_aes_hw_gcm_rv64i(keybits); #elif defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 32 -#include "cipher_aes_gcm_hw_rv32i.inc" -#else -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) -{ - return &aes_gcm; -} + aes_gcm_hw = ossl_prov_aes_hw_gcm_rv32i(keybits); +#elif defined(S390X_aes_128_CAPABLE) + aes_gcm_hw = ossl_prov_aes_hw_gcm_s390x(keybits); +#elif defined(SPARC_AES_CAPABLE) + aes_gcm_hw = ossl_prov_aes_hw_gcm_t4(keybits); #endif + + if (aes_gcm_hw == NULL) + aes_gcm_hw = &aes_gcm; + + return aes_gcm_hw; +} diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_vaes_avx512.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.c similarity index 71% rename from providers/implementations/ciphers/cipher_aes_gcm_hw_vaes_avx512.inc rename to providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.c index 5406548f3ed..d6f1af75dcf 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_vaes_avx512.inc +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.c @@ -1,6 +1,5 @@ /* - * Copyright 2021-2025 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2021, Intel Corporation. All Rights Reserved. + * Copyright 2001-2026 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,41 +7,63 @@ * https://www.openssl.org/source/license.html */ +/*- + * AES-NI support for AES GCM. + * This file is used by cipher_aes_gcm_hw.c + */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(AESNI_CAPABLE) + +static int aesni_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, + size_t keylen) +{ + PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; + AES_KEY *ks = &actx->ks.ks; + GCM_HW_SET_KEY_CTR_FN(ks, aesni_set_encrypt_key, aesni_encrypt, + aesni_ctr32_encrypt_blocks); + return 1; +} + +static const PROV_GCM_HW aesni_gcm = { + aesni_gcm_initkey, + ossl_gcm_setiv, + ossl_gcm_aad_update, + generic_aes_gcm_cipher_update, + ossl_gcm_cipher_final, + ossl_gcm_one_shot +}; + /*- * AVX512 VAES + VPCLMULDQD support for AES GCM. - * This file is included by cipher_aes_gcm_hw_aesni.inc */ #undef VAES_GCM_ENABLED -#if (defined(__x86_64) || defined(__x86_64__) || \ - defined(_M_AMD64) || defined(_M_X64)) -# define VAES_GCM_ENABLED +#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)) +#define VAES_GCM_ENABLED /* Returns non-zero when AVX512F + VAES + VPCLMULDQD combination is available */ int ossl_vaes_vpclmulqdq_capable(void); -# define OSSL_AES_GCM_UPDATE(direction) \ - void ossl_aes_gcm_ ## direction ## _avx512(const void *ks, \ - void *gcm128ctx, \ - unsigned int *pblocklen, \ - const unsigned char *in, \ - size_t len, \ - unsigned char *out); - -OSSL_AES_GCM_UPDATE(encrypt) -OSSL_AES_GCM_UPDATE(decrypt) +void ossl_aes_gcm_encrypt_avx512(const void *ks, void *gcm128ctx, + unsigned int *pblocklen, const unsigned char *in, size_t len, + unsigned char *out); +void ossl_aes_gcm_decrypt_avx512(const void *ks, void *gcm128ctx, + unsigned int *pblocklen, const unsigned char *in, size_t len, + unsigned char *out); void ossl_aes_gcm_init_avx512(const void *ks, void *gcm128ctx); void ossl_aes_gcm_setiv_avx512(const void *ks, void *gcm128ctx, - const unsigned char *iv, size_t ivlen); + const unsigned char *iv, size_t ivlen); void ossl_aes_gcm_update_aad_avx512(void *gcm128ctx, const unsigned char *aad, - size_t aadlen); + size_t aadlen); void ossl_aes_gcm_finalize_avx512(void *gcm128ctx, unsigned int pblocklen); void ossl_gcm_gmult_avx512(uint64_t Xi[2], const void *gcm128ctx); static int vaes_gcm_setkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) + size_t keylen) { GCM128_CONTEXT *gcmctx = &ctx->gcm; PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; @@ -59,16 +80,16 @@ static int vaes_gcm_setkey(PROV_GCM_CTX *ctx, const unsigned char *key, } static int vaes_gcm_setiv(PROV_GCM_CTX *ctx, const unsigned char *iv, - size_t ivlen) + size_t ivlen) { GCM128_CONTEXT *gcmctx = &ctx->gcm; - gcmctx->Yi.u[0] = 0; /* Current counter */ + gcmctx->Yi.u[0] = 0; /* Current counter */ gcmctx->Yi.u[1] = 0; - gcmctx->Xi.u[0] = 0; /* AAD hash */ + gcmctx->Xi.u[0] = 0; /* AAD hash */ gcmctx->Xi.u[1] = 0; - gcmctx->len.u[0] = 0; /* AAD length */ - gcmctx->len.u[1] = 0; /* Message length */ + gcmctx->len.u[0] = 0; /* AAD length */ + gcmctx->len.u[1] = 0; /* Message length */ gcmctx->ares = 0; gcmctx->mres = 0; @@ -82,8 +103,8 @@ static int vaes_gcm_setiv(PROV_GCM_CTX *ctx, const unsigned char *iv, } static int vaes_gcm_aadupdate(PROV_GCM_CTX *ctx, - const unsigned char *aad, - size_t aad_len) + const unsigned char *aad, + size_t aad_len) { GCM128_CONTEXT *gcmctx = &ctx->gcm; uint64_t alen = gcmctx->len.u[0]; @@ -143,7 +164,7 @@ static int vaes_gcm_aadupdate(PROV_GCM_CTX *ctx, } static int vaes_gcm_cipherupdate(PROV_GCM_CTX *ctx, const unsigned char *in, - size_t len, unsigned char *out) + size_t len, unsigned char *out) { GCM128_CONTEXT *gcmctx = &ctx->gcm; uint64_t mlen = gcmctx->len.u[1]; @@ -182,8 +203,7 @@ static int vaes_gcm_cipherfinal(PROV_GCM_CTX *ctx, unsigned char *tag) if (ctx->enc) { ctx->taglen = GCM_TAG_MAX_SIZE; memcpy(tag, gcmctx->Xi.c, - ctx->taglen <= sizeof(gcmctx->Xi.c) ? ctx->taglen : - sizeof(gcmctx->Xi.c)); + ctx->taglen <= sizeof(gcmctx->Xi.c) ? ctx->taglen : sizeof(gcmctx->Xi.c)); *res = 0; } else { return !CRYPTO_memcmp(gcmctx->Xi.c, tag, ctx->taglen); @@ -202,3 +222,17 @@ static const PROV_GCM_HW vaes_gcm = { }; #endif + +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_aesni(size_t keybits) +{ +#ifdef VAES_GCM_ENABLED + if (ossl_vaes_vpclmulqdq_capable()) + return &vaes_gcm; +#endif + if (AESNI_CAPABLE) + return &aesni_gcm; + + return NULL; +} + +#endif diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.inc deleted file mode 100644 index 92f41b8cd6e..00000000000 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.inc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2001-2022 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/*- - * AES-NI support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c - */ - -static int aesni_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) -{ - PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; - AES_KEY *ks = &actx->ks.ks; - GCM_HW_SET_KEY_CTR_FN(ks, aesni_set_encrypt_key, aesni_encrypt, - aesni_ctr32_encrypt_blocks); - return 1; -} - -static const PROV_GCM_HW aesni_gcm = { - aesni_gcm_initkey, - ossl_gcm_setiv, - ossl_gcm_aad_update, - generic_aes_gcm_cipher_update, - ossl_gcm_cipher_final, - ossl_gcm_one_shot -}; - -#include "cipher_aes_gcm_hw_vaes_avx512.inc" - -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) -{ -#ifdef VAES_GCM_ENABLED - if (ossl_vaes_vpclmulqdq_capable()) - return &vaes_gcm; - else -#endif - if (AESNI_CAPABLE) - return &aesni_gcm; - else - return &aes_gcm; -} diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.c b/providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.c new file mode 100644 index 00000000000..00df7b2c0e4 --- /dev/null +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.c @@ -0,0 +1,113 @@ +/* + * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Crypto extension support for AES GCM. + * This file is used by cipher_aes_gcm_hw.c + */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(AES_PMULL_CAPABLE) && defined(AES_GCM_ASM) + +size_t armv8_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, + const void *key, unsigned char ivec[16], uint64_t *Xi) +{ + AES_KEY *aes_key = (AES_KEY *)key; + size_t align_bytes = len - len % 16; + + switch (aes_key->rounds) { + case 10: + if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { + unroll8_eor3_aes_gcm_enc_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } else { + aes_gcm_enc_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } + break; + case 12: + if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { + unroll8_eor3_aes_gcm_enc_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } else { + aes_gcm_enc_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } + break; + case 14: + if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { + unroll8_eor3_aes_gcm_enc_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } else { + aes_gcm_enc_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } + break; + } + return align_bytes; +} + +size_t armv8_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, + const void *key, unsigned char ivec[16], uint64_t *Xi) +{ + AES_KEY *aes_key = (AES_KEY *)key; + size_t align_bytes = len - len % 16; + + switch (aes_key->rounds) { + case 10: + if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { + unroll8_eor3_aes_gcm_dec_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } else { + aes_gcm_dec_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } + break; + case 12: + if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { + unroll8_eor3_aes_gcm_dec_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } else { + aes_gcm_dec_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } + break; + case 14: + if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { + unroll8_eor3_aes_gcm_dec_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } else { + aes_gcm_dec_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); + } + break; + } + return align_bytes; +} + +static int armv8_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, + size_t keylen) +{ + PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; + AES_KEY *ks = &actx->ks.ks; + + if (AES_UNROLL12_EOR3_CAPABLE) { + GCM_HW_SET_KEY_CTR_FN(ks, aes_v8_set_encrypt_key, aes_v8_encrypt, + aes_v8_ctr32_encrypt_blocks_unroll12_eor3); + } else { + GCM_HW_SET_KEY_CTR_FN(ks, aes_v8_set_encrypt_key, aes_v8_encrypt, + aes_v8_ctr32_encrypt_blocks); + } + return 1; +} + +static const PROV_GCM_HW armv8_aes_gcm = { + armv8_aes_gcm_initkey, + ossl_gcm_setiv, + ossl_gcm_aad_update, + generic_aes_gcm_cipher_update, + ossl_gcm_cipher_final, + ossl_gcm_one_shot +}; + +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_armv8(size_t keybits) +{ + return AES_PMULL_CAPABLE ? &armv8_aes_gcm : NULL; +} + +#endif diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.inc deleted file mode 100644 index 42a305a00d0..00000000000 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_armv8.inc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Crypto extension support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c - */ - -size_t armv8_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], uint64_t *Xi) -{ - AES_KEY *aes_key = (AES_KEY *)key; - size_t align_bytes = len - len % 16; - - switch(aes_key->rounds) { - case 10: - if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { - unroll8_eor3_aes_gcm_enc_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } else { - aes_gcm_enc_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } - break; - case 12: - if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { - unroll8_eor3_aes_gcm_enc_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } else { - aes_gcm_enc_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } - break; - case 14: - if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { - unroll8_eor3_aes_gcm_enc_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } else { - aes_gcm_enc_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } - break; - } - return align_bytes; -} - -size_t armv8_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], uint64_t *Xi) -{ - AES_KEY *aes_key = (AES_KEY *)key; - size_t align_bytes = len - len % 16; - - switch(aes_key->rounds) { - case 10: - if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { - unroll8_eor3_aes_gcm_dec_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } else { - aes_gcm_dec_128_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } - break; - case 12: - if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { - unroll8_eor3_aes_gcm_dec_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } else { - aes_gcm_dec_192_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } - break; - case 14: - if (IS_CPU_SUPPORT_UNROLL8_EOR3()) { - unroll8_eor3_aes_gcm_dec_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } else { - aes_gcm_dec_256_kernel(in, align_bytes * 8, out, (uint64_t *)Xi, ivec, key); - } - break; - } - return align_bytes; -} - -static int armv8_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) -{ - PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; - AES_KEY *ks = &actx->ks.ks; - - if (AES_UNROLL12_EOR3_CAPABLE) { - GCM_HW_SET_KEY_CTR_FN(ks, aes_v8_set_encrypt_key, aes_v8_encrypt, - aes_v8_ctr32_encrypt_blocks_unroll12_eor3); - } else { - GCM_HW_SET_KEY_CTR_FN(ks, aes_v8_set_encrypt_key, aes_v8_encrypt, - aes_v8_ctr32_encrypt_blocks); - } - return 1; -} - - -static const PROV_GCM_HW armv8_aes_gcm = { - armv8_aes_gcm_initkey, - ossl_gcm_setiv, - ossl_gcm_aad_update, - generic_aes_gcm_cipher_update, - ossl_gcm_cipher_final, - ossl_gcm_one_shot -}; - -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) -{ - return AES_PMULL_CAPABLE ? &armv8_aes_gcm : &aes_gcm; -} diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.c similarity index 73% rename from providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.inc rename to providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.c index 4d1238a7443..0b500d64b25 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.inc +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.c @@ -9,23 +9,27 @@ /*- * PPC support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c + * This file is used by cipher_aes_gcm_hw.c */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(PPC_AES_GCM_CAPABLE) && defined(_ARCH_PPC64) static int aes_ppc_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) + size_t keylen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; GCM_HW_SET_KEY_CTR_FN(ks, aes_p8_set_encrypt_key, aes_p8_encrypt, - aes_p8_ctr32_encrypt_blocks); + aes_p8_ctr32_encrypt_blocks); return 1; } static inline uint32_t UTO32(unsigned char *buf) { - return ((uint32_t) buf[0] << 24) | ((uint32_t) buf[1] << 16) | ((uint32_t) buf[2] << 8) | ((uint32_t) buf[3]); + return ((uint32_t)buf[0] << 24) | ((uint32_t)buf[1] << 16) | ((uint32_t)buf[2] << 8) | ((uint32_t)buf[3]); } static inline uint32_t add32TOU(unsigned char buf[4], uint32_t n) @@ -34,15 +38,15 @@ static inline uint32_t add32TOU(unsigned char buf[4], uint32_t n) r = UTO32(buf); r += n; - buf[0] = (unsigned char) (r >> 24) & 0xFF; - buf[1] = (unsigned char) (r >> 16) & 0xFF; - buf[2] = (unsigned char) (r >> 8) & 0xFF; - buf[3] = (unsigned char) r & 0xFF; + buf[0] = (unsigned char)(r >> 24) & 0xFF; + buf[1] = (unsigned char)(r >> 16) & 0xFF; + buf[2] = (unsigned char)(r >> 8) & 0xFF; + buf[3] = (unsigned char)r & 0xFF; return r; } static size_t ppc_aes_gcm_crypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], uint64_t *Xi, int encrypt) + const void *key, unsigned char ivec[16], uint64_t *Xi, int encrypt) { size_t s = 0; size_t ndone = 0; @@ -55,7 +59,7 @@ static size_t ppc_aes_gcm_crypt(const unsigned char *in, unsigned char *out, siz memcpy(ctr_saved, ivec, 12); while (nb) { - blocks_unused = (uint64_t) 0xffffffffU + 1 - (uint64_t) UTO32 (ivec + 12); + blocks_unused = (uint64_t)0xffffffffU + 1 - (uint64_t)UTO32(ivec + 12); if (nb > blocks_unused) { len = blocks_unused * 16; nb -= blocks_unused; @@ -71,7 +75,7 @@ static size_t ppc_aes_gcm_crypt(const unsigned char *in, unsigned char *out, siz : ppc_aes_gcm_decrypt(in, out, len, key, ivec, Xi); /* add counter to ivec */ - add32TOU(ivec + 12, (uint32_t) next_ctr); + add32TOU(ivec + 12, (uint32_t)next_ctr); if (ctr_reset) { ctr_reset = 0; in += len; @@ -85,7 +89,7 @@ static size_t ppc_aes_gcm_crypt(const unsigned char *in, unsigned char *out, siz } static int ppc_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in, - size_t len, unsigned char *out) + size_t len, unsigned char *out) { if (ctx->enc) { if (ctx->ctr != NULL) { @@ -98,14 +102,14 @@ static int ppc_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in, return 0; bulk = ppc_aes_gcm_crypt(in + res, out + res, len - res, - ctx->gcm.key, - ctx->gcm.Yi.c, ctx->gcm.Xi.u, 1); + ctx->gcm.key, + ctx->gcm.Yi.c, ctx->gcm.Xi.u, 1); ctx->gcm.len.u[1] += bulk; bulk += res; } if (CRYPTO_gcm128_encrypt_ctr32(&ctx->gcm, in + bulk, out + bulk, - len - bulk, ctx->ctr)) + len - bulk, ctx->ctr)) return 0; } else { if (CRYPTO_gcm128_encrypt(&ctx->gcm, in, out, len)) @@ -122,14 +126,14 @@ static int ppc_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, const unsigned char *in, return 0; bulk = ppc_aes_gcm_crypt(in + res, out + res, len - res, - ctx->gcm.key, - ctx->gcm.Yi.c, ctx->gcm.Xi.u, 0); + ctx->gcm.key, + ctx->gcm.Yi.c, ctx->gcm.Xi.u, 0); ctx->gcm.len.u[1] += bulk; bulk += res; } if (CRYPTO_gcm128_decrypt_ctr32(&ctx->gcm, in + bulk, out + bulk, - len - bulk, ctx->ctr)) + len - bulk, ctx->ctr)) return 0; } else { if (CRYPTO_gcm128_decrypt(&ctx->gcm, in, out, len)) @@ -148,8 +152,9 @@ static const PROV_GCM_HW aes_ppc_gcm = { ossl_gcm_one_shot }; -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_ppc(size_t keybits) { - return PPC_AES_GCM_CAPABLE ? &aes_ppc_gcm : &aes_gcm; + return PPC_AES_GCM_CAPABLE ? &aes_ppc_gcm : NULL; } +#endif diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.c similarity index 80% rename from providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.inc rename to providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.c index bf3f98df163..a5dee804537 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.inc +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_rv32i.c @@ -9,29 +9,33 @@ /*- * RISC-V 32 ZKND ZKNE support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c + * This file is used by cipher_aes_gcm_hw.c */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 32 static int rv32i_zknd_zkne_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) + size_t keylen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; GCM_HW_SET_KEY_CTR_FN(ks, rv32i_zkne_set_encrypt_key, rv32i_zkne_encrypt, - NULL); + NULL); return 1; } static int rv32i_zbkb_zknd_zkne_gcm_initkey(PROV_GCM_CTX *ctx, - const unsigned char *key, - size_t keylen) + const unsigned char *key, + size_t keylen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; GCM_HW_SET_KEY_CTR_FN(ks, rv32i_zbkb_zkne_set_encrypt_key, rv32i_zkne_encrypt, - NULL); + NULL); return 1; } @@ -53,11 +57,13 @@ static const PROV_GCM_HW rv32i_zbkb_zknd_zkne_gcm = { ossl_gcm_one_shot }; -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_rv32i(size_t keybits) { if (RISCV_HAS_ZBKB_AND_ZKND_AND_ZKNE()) return &rv32i_zbkb_zknd_zkne_gcm; if (RISCV_HAS_ZKND_AND_ZKNE()) return &rv32i_zknd_zkne_gcm; - return &aes_gcm; + return NULL; } + +#endif diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.c similarity index 74% rename from providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.inc rename to providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.c index dae9beae07e..74de38f1756 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.inc +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.c @@ -9,19 +9,23 @@ /*- * RISC-V 64 support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c + * This file is used by cipher_aes_gcm_hw.c */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 64 /*- * RISC-V 64 ZKND and ZKNE support for AES GCM. */ static int rv64i_zknd_zkne_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) + size_t keylen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; GCM_HW_SET_KEY_CTR_FN(ks, rv64i_zkne_set_encrypt_key, rv64i_zkne_encrypt, - NULL); + NULL); return 1; } @@ -38,7 +42,7 @@ static const PROV_GCM_HW rv64i_zknd_zkne_gcm = { * RISC-V RV64 ZVKNED support for AES GCM. */ static int rv64i_zvkned_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) + size_t keylen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; @@ -49,10 +53,10 @@ static int rv64i_zvkned_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, */ if (keylen * 8 == 128 || keylen * 8 == 256) { GCM_HW_SET_KEY_CTR_FN(ks, rv64i_zvkned_set_encrypt_key, - rv64i_zvkned_encrypt, NULL); + rv64i_zvkned_encrypt, NULL); } else { GCM_HW_SET_KEY_CTR_FN(ks, AES_set_encrypt_key, - rv64i_zvkned_encrypt, NULL); + rv64i_zvkned_encrypt, NULL); } return 1; @@ -71,8 +75,9 @@ static const PROV_GCM_HW rv64i_zvkned_gcm = { * RISC-V RV64 ZVKB, ZVKG and ZVKNED support for AES GCM. */ static int rv64i_zvkb_zvkg_zvkned_gcm_initkey(PROV_GCM_CTX *ctx, - const unsigned char *key, - size_t keylen) { + const unsigned char *key, + size_t keylen) +{ PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; @@ -82,12 +87,12 @@ static int rv64i_zvkb_zvkg_zvkned_gcm_initkey(PROV_GCM_CTX *ctx, */ if (keylen * 8 == 128 || keylen * 8 == 256) { GCM_HW_SET_KEY_CTR_FN(ks, rv64i_zvkned_set_encrypt_key, - rv64i_zvkned_encrypt, - rv64i_zvkb_zvkned_ctr32_encrypt_blocks); + rv64i_zvkned_encrypt, + rv64i_zvkb_zvkned_ctr32_encrypt_blocks); } else { GCM_HW_SET_KEY_CTR_FN(ks, AES_set_encrypt_key, - rv64i_zvkned_encrypt, - rv64i_zvkb_zvkned_ctr32_encrypt_blocks); + rv64i_zvkned_encrypt, + rv64i_zvkb_zvkned_ctr32_encrypt_blocks); } return 1; @@ -102,16 +107,19 @@ static const PROV_GCM_HW rv64i_zvkb_zvkg_zvkned_gcm = { ossl_gcm_one_shot }; -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) { +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_rv64i(size_t keybits) +{ if (RISCV_HAS_ZVKNED() && riscv_vlen() >= 128) { - if (RISCV_HAS_ZVKB() && RISCV_HAS_ZVKG()) - return &rv64i_zvkb_zvkg_zvkned_gcm; - return &rv64i_zvkned_gcm; + if (RISCV_HAS_ZVKB() && RISCV_HAS_ZVKG()) + return &rv64i_zvkb_zvkg_zvkned_gcm; + return &rv64i_zvkned_gcm; } if (RISCV_HAS_ZKND_AND_ZKNE()) { - return &rv64i_zknd_zkne_gcm; + return &rv64i_zknd_zkne_gcm; } - return &aes_gcm; + return NULL; } + +#endif diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.c similarity index 87% rename from providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.inc rename to providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.c index a36c48e3ec4..4c154744e05 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.inc +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_s390x.c @@ -9,20 +9,23 @@ /*- * IBM S390X support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c + * This file is used by cipher_aes_gcm_hw.c */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(S390X_aes_128_CAPABLE) /* iv + padding length for iv lengths != 12 */ -#define S390X_gcm_ivpadlen(i) ((((i) + 15) >> 4 << 4) + 16) +#define S390X_gcm_ivpadlen(i) ((((i) + 15) >> 4 << 4) + 16) /* Additional flag or'ed to fc for decryption */ #define S390X_gcm_decrypt_flag(ctx) (((ctx)->enc) ? 0 : S390X_DECRYPT) -#define S390X_gcm_fc(A,C) ((A)->plat.s390x.fc | (A)->plat.s390x.hsflag |\ - S390X_gcm_decrypt_flag((C))) +#define S390X_gcm_fc(A, C) ((A)->plat.s390x.fc | (A)->plat.s390x.hsflag | S390X_gcm_decrypt_flag((C))) static int s390x_aes_gcm_initkey(PROV_GCM_CTX *ctx, - const unsigned char *key, size_t keylen) + const unsigned char *key, size_t keylen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; @@ -33,7 +36,7 @@ static int s390x_aes_gcm_initkey(PROV_GCM_CTX *ctx, } static int s390x_aes_gcm_setiv(PROV_GCM_CTX *ctx, const unsigned char *iv, - size_t ivlen) + size_t ivlen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; S390X_KMA_PARAMS *kma = &actx->plat.s390x.param.kma; @@ -93,8 +96,8 @@ static int s390x_aes_gcm_cipher_final(PROV_GCM_CTX *ctx, unsigned char *tag) kma->tpcl <<= 3; fc = S390X_gcm_fc(actx, ctx) | S390X_KMA_LAAD | S390X_KMA_LPC; s390x_kma(actx->plat.s390x.ares, actx->plat.s390x.areslen, - actx->plat.s390x.mres, actx->plat.s390x.mreslen, out, - fc, kma); + actx->plat.s390x.mres, actx->plat.s390x.mreslen, out, + fc, kma); /* gctx->mres already returned to the caller */ OPENSSL_cleanse(out, actx->plat.s390x.mreslen); @@ -110,10 +113,10 @@ static int s390x_aes_gcm_cipher_final(PROV_GCM_CTX *ctx, unsigned char *tag) } static int s390x_aes_gcm_one_shot(PROV_GCM_CTX *ctx, - unsigned char *aad, size_t aad_len, - const unsigned char *in, size_t in_len, - unsigned char *out, - unsigned char *tag, size_t taglen) + unsigned char *aad, size_t aad_len, + const unsigned char *in, size_t in_len, + unsigned char *out, + unsigned char *tag, size_t taglen) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; S390X_KMA_PARAMS *kma = &actx->plat.s390x.param.kma; @@ -139,7 +142,7 @@ static int s390x_aes_gcm_one_shot(PROV_GCM_CTX *ctx, * big-endian. */ static int s390x_aes_gcm_aad_update(PROV_GCM_CTX *ctx, - const unsigned char *aad, size_t len) + const unsigned char *aad, size_t len) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; S390X_KMA_PARAMS *kma = &actx->plat.s390x.param.kma; @@ -203,8 +206,8 @@ static int s390x_aes_gcm_aad_update(PROV_GCM_CTX *ctx, * success. Code is big-endian. */ static int s390x_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, - const unsigned char *in, size_t len, - unsigned char *out) + const unsigned char *in, size_t len, + unsigned char *out) { PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; S390X_KMA_PARAMS *kma = &actx->plat.s390x.param.kma; @@ -237,7 +240,7 @@ static int s390x_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, /* ctx->mres contains a complete block if offset has wrapped around */ if (!n) { s390x_kma(actx->plat.s390x.ares, actx->plat.s390x.areslen, - actx->plat.s390x.mres, 16, buf.b, fc, kma); + actx->plat.s390x.mres, 16, buf.b, fc, kma); actx->plat.s390x.hsflag = S390X_KMA_HS; fc |= S390X_KMA_HS; actx->plat.s390x.areslen = 0; @@ -261,7 +264,7 @@ static int s390x_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, len &= ~(size_t)0xf; if (len) { s390x_kma(actx->plat.s390x.ares, actx->plat.s390x.areslen, in, len, out, - fc, kma); + fc, kma); in += len; out += len; actx->plat.s390x.hsflag = S390X_KMA_HS; @@ -280,7 +283,7 @@ static int s390x_aes_gcm_cipher_update(PROV_GCM_CTX *ctx, buf.w[2] = kma->j0.w[2]; buf.w[3] = kma->cv.w + 1; s390x_km(buf.b, 16, actx->plat.s390x.kres, - fc & 0x1f, &kma->k); + fc & 0x1f, &kma->k); } n = actx->plat.s390x.mreslen; @@ -302,11 +305,13 @@ static const PROV_GCM_HW s390x_aes_gcm = { s390x_aes_gcm_one_shot }; -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_s390x(size_t keybits) { if ((keybits == 128 && S390X_aes_128_gcm_CAPABLE) - || (keybits == 192 && S390X_aes_192_gcm_CAPABLE) - || (keybits == 256 && S390X_aes_256_gcm_CAPABLE)) + || (keybits == 192 && S390X_aes_192_gcm_CAPABLE) + || (keybits == 256 && S390X_aes_256_gcm_CAPABLE)) return &s390x_aes_gcm; - return &aes_gcm; + return NULL; } + +#endif diff --git a/providers/implementations/ciphers/cipher_aes_gcm_hw_t4.inc b/providers/implementations/ciphers/cipher_aes_gcm_hw_t4.c similarity index 80% rename from providers/implementations/ciphers/cipher_aes_gcm_hw_t4.inc rename to providers/implementations/ciphers/cipher_aes_gcm_hw_t4.c index 2b3a6d1d5ea..4625c66e4de 100644 --- a/providers/implementations/ciphers/cipher_aes_gcm_hw_t4.inc +++ b/providers/implementations/ciphers/cipher_aes_gcm_hw_t4.c @@ -9,17 +9,20 @@ /*- * Fujitsu SPARC64 X support for AES GCM. - * This file is included by cipher_aes_gcm_hw.c + * This file is used by cipher_aes_gcm_hw.c */ +#include "internal/deprecated.h" +#include "cipher_aes_gcm.h" + +#if defined(SPARC_AES_CAPABLE) static int t4_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, - size_t keylen) + size_t keylen) { ctr128_f ctr; PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; AES_KEY *ks = &actx->ks.ks; - switch (keylen) { case 16: ctr = (ctr128_f)aes128_t4_ctr32_encrypt; @@ -46,7 +49,10 @@ static const PROV_GCM_HW t4_aes_gcm = { ossl_gcm_cipher_final, ossl_gcm_one_shot }; -const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) + +const PROV_GCM_HW *ossl_prov_aes_hw_gcm_t4(size_t keybits) { - return SPARC_AES_CAPABLE ? &t4_aes_gcm : &aes_gcm; + return SPARC_AES_CAPABLE ? &t4_aes_gcm : NULL; } + +#endif