blob: 7fc0cfa0ebc4fbf807f77fc328c1149a6d94ef42 [file] [log] [blame]
Jerry Yu49231312023-01-10 16:57:21 +08001/**
2 * \file aesce.h
3 *
4 * \brief AES-CE for hardware AES acceleration on ARMv8 processors with crypto
5 * engine.
6 *
7 * \warning These functions are only for internal use by other library
8 * functions; you must not call them directly.
9 */
10/*
11 * Copyright The Mbed TLS Contributors
12 * SPDX-License-Identifier: Apache-2.0
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License"); you may
15 * not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
17 *
18 * http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 */
26#ifndef MBEDTLS_AESCE_H
27#define MBEDTLS_AESCE_H
28
29#include "mbedtls/build_info.h"
30
31#include "mbedtls/aes.h"
32
33
Jerry Yub95c7762023-01-10 16:59:51 +080034#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \
35 defined(__aarch64__) && !defined(MBEDTLS_HAVE_ARM64)
Jerry Yu49231312023-01-10 16:57:21 +080036#define MBEDTLS_HAVE_ARM64
37#endif
38
39#if defined(MBEDTLS_HAVE_ARM64)
40
41#ifdef __cplusplus
42extern "C" {
43#endif
Jerry Yub95c7762023-01-10 16:59:51 +080044
45/**
46 * \brief Internal function to detect the crypto engine in CPUs.
47 *
48 * \return 1 if CPU has support for the feature, 0 otherwise
49 */
50int mbedtls_aesce_has_support(void);
51
Jerry Yu3f2fb712023-01-10 17:05:42 +080052
53/**
54 * \brief Internal key expansion for encryption
55 *
56 * \param rk Destination buffer where the round keys are written
57 * \param key Encryption key
58 * \param bits Key size in bits (must be 128, 192 or 256)
59 *
60 * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
61 */
62int mbedtls_aesce_setkey_enc(unsigned char *rk,
63 const unsigned char *key,
64 size_t bits);
65
Jerry Yu49231312023-01-10 16:57:21 +080066#ifdef __cplusplus
67}
68#endif
69
70#endif /* MBEDTLS_HAVE_ARM64 */
71
72#endif /* MBEDTLS_AESCE_H */