1 /* 2 * Copyright (c) 2018, The OpenThread Authors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the copyright holder nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 // Spans multiple lines to avoid being processed by unifdef 30 #ifndef \ 31 MBEDTLS_CONFIG_H 32 #define MBEDTLS_CONFIG_H 33 34 #include "openthread-core-config.h" 35 36 #include <stdio.h> 37 #include <stdlib.h> 38 39 #include <openthread/config.h> 40 #include <openthread/platform/logging.h> 41 #include <openthread/platform/memory.h> 42 43 #define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf 44 45 #define MBEDTLS_AES_C 46 #define MBEDTLS_AES_ROM_TABLES 47 #define MBEDTLS_ASN1_PARSE_C 48 #define MBEDTLS_ASN1_WRITE_C 49 #define MBEDTLS_BIGNUM_C 50 #define MBEDTLS_CCM_C 51 #define MBEDTLS_CIPHER_C 52 #define MBEDTLS_CMAC_C 53 #define MBEDTLS_CTR_DRBG_C 54 #define MBEDTLS_ECJPAKE_C 55 #define MBEDTLS_ECP_C 56 #define MBEDTLS_ECP_DP_SECP256R1_ENABLED 57 #define MBEDTLS_ECP_NIST_OPTIM 58 #define MBEDTLS_ENTROPY_C 59 #define MBEDTLS_HAVE_ASM 60 #define MBEDTLS_HMAC_DRBG_C 61 #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 62 #define MBEDTLS_MD_C 63 #define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES 64 #define MBEDTLS_NO_PLATFORM_ENTROPY 65 #define MBEDTLS_PK_C 66 #define MBEDTLS_PK_PARSE_C 67 #define MBEDTLS_PLATFORM_C 68 #define MBEDTLS_PLATFORM_MEMORY 69 #define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS 70 #define MBEDTLS_SHA224_C 71 #define MBEDTLS_SHA256_C 72 #define MBEDTLS_SHA256_SMALLER 73 #define MBEDTLS_SSL_CLI_C 74 #define MBEDTLS_SSL_DTLS_ANTI_REPLAY 75 #define MBEDTLS_SSL_DTLS_HELLO_VERIFY 76 #define MBEDTLS_SSL_EXPORT_KEYS 77 #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 78 #define MBEDTLS_SSL_PROTO_TLS1_2 79 #define MBEDTLS_SSL_PROTO_DTLS 80 #define MBEDTLS_SSL_TLS_C 81 82 #if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 83 #define MBEDTLS_SSL_COOKIE_C 84 #define MBEDTLS_SSL_SRV_C 85 #endif 86 87 #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 88 #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 89 #endif 90 91 #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_TLS_ENABLE 92 #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 93 #endif 94 95 #ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 96 #define MBEDTLS_BASE64_C 97 #define MBEDTLS_ECDH_C 98 #define MBEDTLS_ECDSA_C 99 #define MBEDTLS_OID_C 100 #define MBEDTLS_PEM_PARSE_C 101 #define MBEDTLS_X509_USE_C 102 #define MBEDTLS_X509_CRT_PARSE_C 103 #endif 104 105 #if OPENTHREAD_CONFIG_ECDSA_ENABLE 106 #define MBEDTLS_BASE64_C 107 #define MBEDTLS_ECDH_C 108 #define MBEDTLS_ECDSA_C 109 #if OPENTHREAD_CONFIG_DETERMINISTIC_ECDSA_ENABLE 110 #define MBEDTLS_ECDSA_DETERMINISTIC 111 #endif 112 #define MBEDTLS_OID_C 113 #define MBEDTLS_PEM_PARSE_C 114 #define MBEDTLS_PK_WRITE_C 115 #endif 116 117 #define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */ 118 #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */ 119 #define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */ 120 #define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */ 121 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */ 122 #define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */ 123 124 #if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 125 #define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */ 126 #define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */ 127 #else 128 #define MBEDTLS_MEMORY_BUFFER_ALLOC_C 129 #endif 130 131 #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 132 #define MBEDTLS_SSL_MAX_CONTENT_LEN 900 /**< Maxium fragment length in bytes */ 133 #else 134 #define MBEDTLS_SSL_MAX_CONTENT_LEN 768 /**< Maxium fragment length in bytes */ 135 #endif 136 137 #define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN 138 #define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN 139 #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 140 141 // Spans multiple lines to avoid being processed by unifdef 142 #if defined(\ 143 MBEDTLS_USER_CONFIG_FILE) 144 #include MBEDTLS_USER_CONFIG_FILE 145 #endif 146 147 #include "mbedtls/check_config.h" 148 149 #endif /* MBEDTLS_CONFIG_H */ 150