Add basic aria and camellia ciphers modes to default provider
[openssl.git] / providers / common / ciphers / cipher_aes_gcm_hw_aesni.inc
1 /*
2  * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
3  *
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
8  */
9
10 /*-
11  * AES-NI support for AES GCM.
12  * This file is included by cipher_gcm_hw.c
13  */
14
15 static int aesni_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key,
16                              size_t keylen)
17 {
18     PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx;
19     AES_KEY *ks = &actx->ks.ks;
20
21     SET_KEY_CTR_FN(ks, aesni_set_encrypt_key, aesni_encrypt,
22                    aesni_ctr32_encrypt_blocks);
23     return 1;
24 }
25
26 static const PROV_GCM_HW aesni_gcm = {
27     aesni_gcm_initkey,
28     gcm_setiv,
29     gcm_aad_update,
30     gcm_cipher_update,
31     gcm_cipher_final,
32     gcm_one_shot
33 };
34
35 const PROV_GCM_HW *PROV_AES_HW_gcm(size_t keybits)
36 {
37     return AESNI_CAPABLE ? &aesni_gcm : &aes_gcm;
38 }
39