1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_EXTERNAL_MBEDTLS_CONFIG_H_
18 #define CHRE_EXTERNAL_MBEDTLS_CONFIG_H_
19 
20 #include <limits.h>
21 #include "mbedtls_memory.h"
22 
23 /**
24  * System support
25  */
26 #define MBEDTLS_HAVE_ASM
27 #define MBEDTLS_PLATFORM_C
28 #define MBEDTLS_PLATFORM_MEMORY
29 #define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
30 #define MBEDTLS_DEPRECATED_WARNING
31 #define MBEDTLS_NO_PLATFORM_ENTROPY
32 
33 /**
34  * Feature support
35  */
36 #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
37 #define MBEDTLS_ECP_NIST_OPTIM
38 #define MBEDTLS_PK_PARSE_EC_EXTENDED
39 
40 /**
41  * MbedTLS modules
42  */
43 #define MBEDTLS_ASN1_PARSE_C
44 #define MBEDTLS_ASN1_WRITE_C
45 #define MBEDTLS_BIGNUM_C
46 #define MBEDTLS_ECDSA_C
47 #define MBEDTLS_ECP_C
48 #define MBEDTLS_MD_C
49 #define MBEDTLS_OID_C
50 #define MBEDTLS_PK_C
51 #define MBEDTLS_PK_PARSE_C
52 #define MBEDTLS_SHA224_C
53 #define MBEDTLS_SHA256_C
54 
55 /**
56  * Platform specific defines
57  */
58 #define MBEDTLS_PLATFORM_CALLOC_MACRO mbedtlsMemoryCalloc
59 #define MBEDTLS_PLATFORM_FREE_MACRO mbedtlsMemoryFree
60 #define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
61 #define MBEDTLS_PLATFORM_FPRINTF_MACRO(fp, fmt, ...) \
62   ({                                                 \
63     static_assert(fp == stderr);                     \
64     LOGE(fmt, ##__VA_ARGS__);                        \
65     -1;                                              \
66   })
67 
68 #endif  // CHRE_EXTERNAL_MBEDTLS_CONFIG_H_
69