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 CCM.
12 * This file is included by cipher_aes_ccm_hw.c
13 */
14
15static int ccm_aesni_initkey(PROV_CCM_CTX *ctx, const unsigned char *key,
16 size_t keylen)
17{
18 PROV_AES_CCM_CTX *actx = (PROV_AES_CCM_CTX *)ctx;
19
20 AES_HW_CCM_SET_KEY_FN(aesni_set_encrypt_key, aesni_encrypt,
21 aesni_ccm64_encrypt_blocks,
22 aesni_ccm64_decrypt_blocks);
23 return 1;
24}
25
26static const PROV_CCM_HW aesni_ccm = {
27 ccm_aesni_initkey,
28 ccm_generic_setiv,
29 ccm_generic_setaad,
30 ccm_generic_auth_encrypt,
31 ccm_generic_auth_decrypt,
32 ccm_generic_gettag
33};
34
35const PROV_CCM_HW *PROV_AES_HW_ccm(size_t keybits)
36{
37 return AESNI_CAPABLE ? &aesni_ccm : &aes_ccm;
38}
39