1/*
2 * Copyright 2023 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 * Crypto extension support for AES modes ecb, cbc, ofb, cfb, ctr.
12 * This file is included by cipher_aes_hw.c
13 */
14
15static int cipher_hw_aes_arm_initkey(PROV_CIPHER_CTX *dat,
16                                                       const unsigned char *key,
17                                                       size_t keylen)
18{
19    int ret = cipher_hw_aes_initkey(dat, key, keylen);
20    if (AES_UNROLL12_EOR3_CAPABLE && dat->mode == EVP_CIPH_CTR_MODE)
21        dat->stream.ctr = (ctr128_f)HWAES_ctr32_encrypt_blocks_unroll12_eor3;
22
23    return ret;
24}
25
26#define PROV_CIPHER_HW_declare(mode)                                           \
27static const PROV_CIPHER_HW aes_arm_##mode = {                                 \
28    cipher_hw_aes_arm_initkey,                                                 \
29    ossl_cipher_hw_generic_##mode,                                             \
30    cipher_hw_aes_copyctx                                                      \
31};
32#define PROV_CIPHER_HW_select(mode)                                            \
33if (ARMv8_HWAES_CAPABLE)                                                         \
34    return &aes_arm_##mode;
35