summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTodd Short <tshort@akamai.com>2022-07-20 10:54:24 -0400
committerTomas Mraz <tomas@openssl.org>2022-11-23 18:21:42 +0100
commit6843c1e4a711668c8ebc6201cf8ca1ec18d00a04 (patch)
treed462777cd58de81392fa704dfe6fab3655bff51c /include
parenta66a11623102622c43c26a846a891b20a653fcec (diff)
Use separate function to get GCM functions
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18835) (cherry picked from commit 92c9086e5c2b63606cd28a7f13f09b9ff35a0de3)
Diffstat (limited to 'include')
-rw-r--r--include/crypto/aes_platform.h6
-rw-r--r--include/crypto/modes.h13
2 files changed, 13 insertions, 6 deletions
diff --git a/include/crypto/aes_platform.h b/include/crypto/aes_platform.h
index e10c076d87..3e26463f7d 100644
--- a/include/crypto/aes_platform.h
+++ b/include/crypto/aes_platform.h
@@ -92,7 +92,7 @@ size_t ppc_aes_gcm_decrypt_wrap(const unsigned char *in, unsigned char *out,
# define AES_gcm_encrypt ppc_aes_gcm_encrypt_wrap
# define AES_gcm_decrypt ppc_aes_gcm_decrypt_wrap
# define AES_GCM_ASM(gctx) ((gctx)->ctr==aes_p8_ctr32_encrypt_blocks && \
- (gctx)->gcm.ghash==gcm_ghash_p8)
+ (gctx)->gcm.funcs.ghash==gcm_ghash_p8)
void gcm_ghash_p8(u64 Xi[2],const u128 Htable[16],const u8 *inp, size_t len);
# endif /* PPC */
@@ -124,7 +124,7 @@ void gcm_ghash_p8(u64 Xi[2],const u128 Htable[16],const u8 *inp, size_t len);
# define AES_gcm_encrypt armv8_aes_gcm_encrypt
# define AES_gcm_decrypt armv8_aes_gcm_decrypt
# define AES_GCM_ASM(gctx) ((gctx)->ctr==aes_v8_ctr32_encrypt_blocks && \
- (gctx)->gcm.ghash==gcm_ghash_v8)
+ (gctx)->gcm.funcs.ghash==gcm_ghash_v8)
size_t aes_gcm_enc_128_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
uint64_t *Xi, unsigned char ivec[16], const void *key);
size_t aes_gcm_enc_192_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
@@ -258,7 +258,7 @@ void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *in, size_t len);
# define AES_gcm_encrypt aesni_gcm_encrypt
# define AES_gcm_decrypt aesni_gcm_decrypt
# define AES_GCM_ASM(ctx) (ctx->ctr == aesni_ctr32_encrypt_blocks && \
- ctx->gcm.ghash == gcm_ghash_avx)
+ ctx->gcm.funcs.ghash == gcm_ghash_avx)
# endif
diff --git a/include/crypto/modes.h b/include/crypto/modes.h
index b1179c6357..d5c5c193c7 100644
--- a/include/crypto/modes.h
+++ b/include/crypto/modes.h
@@ -107,6 +107,15 @@ _asm mov eax, val _asm bswap eax}
u64 hi, lo;
} u128;
+typedef void (*gcm_init_fn)(u128 Htable[16], const u64 H[2]);
+typedef void (*gcm_ghash_fn)(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len);
+typedef void (*gcm_gmult_fn)(u64 Xi[2], const u128 Htable[16]);
+struct gcm_funcs_st {
+ gcm_init_fn ginit;
+ gcm_ghash_fn ghash;
+ gcm_gmult_fn gmult;
+};
+
struct gcm128_context {
/* Following 6 names follow names in GCM specification */
union {
@@ -120,9 +129,7 @@ struct gcm128_context {
* used in some assembler modules, i.e. don't change the order!
*/
u128 Htable[16];
- void (*gmult) (u64 Xi[2], const u128 Htable[16]);
- void (*ghash) (u64 Xi[2], const u128 Htable[16], const u8 *inp,
- size_t len);
+ struct gcm_funcs_st funcs;
unsigned int mres, ares;
block128_f block;
void *key;