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 */
13 * This file uses the low level AES functions (which are deprecated for
14 * non-internal use) in order to implement provider AES ciphers.
16 #include "internal/deprecated.h"
18 #include "cipher_aes_gcm.h"
20 static int generic_aes_gcm_initkey(PROV_GCM_CTX
*ctx
, const unsigned char *key
,
23 PROV_AES_GCM_CTX
*actx
= (PROV_AES_GCM_CTX
*)ctx
;
24 AES_KEY
*ks
= &actx
->ks
.ks
;
28 # ifdef HWAES_ctr32_encrypt_blocks
29 GCM_HW_SET_KEY_CTR_FN(ks
, HWAES_set_encrypt_key
, HWAES_encrypt
,
30 HWAES_ctr32_encrypt_blocks
);
32 GCM_HW_SET_KEY_CTR_FN(ks
, HWAES_set_encrypt_key
, HWAES_encrypt
, NULL
);
33 # endif /* HWAES_ctr32_encrypt_blocks */
35 # endif /* HWAES_CAPABLE */
39 GCM_HW_SET_KEY_CTR_FN(ks
, AES_set_encrypt_key
, AES_encrypt
,
40 bsaes_ctr32_encrypt_blocks
);
42 # endif /* BSAES_CAPABLE */
46 GCM_HW_SET_KEY_CTR_FN(ks
, vpaes_set_encrypt_key
, vpaes_encrypt
, NULL
);
48 # endif /* VPAES_CAPABLE */
52 GCM_HW_SET_KEY_CTR_FN(ks
, AES_set_encrypt_key
, AES_encrypt
,
55 GCM_HW_SET_KEY_CTR_FN(ks
, AES_set_encrypt_key
, AES_encrypt
, NULL
);
56 # endif /* AES_CTR_ASM */
62 static const PROV_GCM_HW aes_gcm
= {
63 generic_aes_gcm_initkey
,
71 #if defined(S390X_aes_128_CAPABLE)
72 # include "cipher_aes_gcm_hw_s390x.inc"
73 #elif defined(AESNI_CAPABLE)
74 # include "cipher_aes_gcm_hw_aesni.inc"
75 #elif defined(SPARC_AES_CAPABLE)
76 # include "cipher_aes_gcm_hw_t4.inc"
77 #elif defined(AES_PMULL_CAPABLE) && defined(AES_GCM_ASM)
78 # include "cipher_aes_gcm_hw_armv8.inc"
80 const PROV_GCM_HW
*PROV_AES_HW_gcm(size_t keybits
)