2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* Dispatch functions for AES GCM mode */
12 #include "cipher_locl.h"
13 #include "internal/ciphers/cipher_gcm.h"
15 static int generic_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key,
18 PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx;
19 AES_KEY *ks = &actx->ks.ks;
23 # ifdef HWAES_ctr32_encrypt_blocks
24 GCM_HW_SET_KEY_CTR_FN(ks, HWAES_set_encrypt_key, HWAES_encrypt,
25 HWAES_ctr32_encrypt_blocks);
27 GCM_HW_SET_KEY_CTR_FN(ks, HWAES_set_encrypt_key, HWAES_encrypt, NULL);
28 # endif /* HWAES_ctr32_encrypt_blocks */
30 # endif /* HWAES_CAPABLE */
34 GCM_HW_SET_KEY_CTR_FN(ks, AES_set_encrypt_key, AES_encrypt,
35 bsaes_ctr32_encrypt_blocks);
37 # endif /* BSAES_CAPABLE */
41 GCM_HW_SET_KEY_CTR_FN(ks, vpaes_set_encrypt_key, vpaes_encrypt, NULL);
43 # endif /* VPAES_CAPABLE */
47 GCM_HW_SET_KEY_CTR_FN(ks, AES_set_encrypt_key, AES_encrypt,
50 GCM_HW_SET_KEY_CTR_FN(ks, AES_set_encrypt_key, AES_encrypt, NULL);
51 # endif /* AES_CTR_ASM */
57 static const PROV_GCM_HW aes_gcm = {
58 generic_aes_gcm_initkey,
66 #if defined(S390X_aes_128_CAPABLE)
67 # include "cipher_aes_gcm_hw_s390x.inc"
68 #elif defined(AESNI_CAPABLE)
69 # include "cipher_aes_gcm_hw_aesni.inc"
70 #elif defined(SPARC_AES_CAPABLE)
71 # include "cipher_aes_gcm_hw_t4.inc"
73 const PROV_GCM_HW *PROV_AES_HW_gcm(size_t keybits)