|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2018-2019 Damien P. George |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | +#ifndef MICROPY_INCLUDED_MBEDTLS_CONFIG_H |
| 27 | +#define MICROPY_INCLUDED_MBEDTLS_CONFIG_H |
| 28 | + |
| 29 | +// Set mbedtls configuration |
| 30 | +#define MBEDTLS_PLATFORM_MEMORY |
| 31 | +#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 32 | +#define MBEDTLS_DEPRECATED_REMOVED |
| 33 | +#define MBEDTLS_ENTROPY_HARDWARE_ALT |
| 34 | +#define MBEDTLS_AES_ROM_TABLES |
| 35 | +#define MBEDTLS_CIPHER_MODE_CBC |
| 36 | +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED |
| 37 | +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED |
| 38 | +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED |
| 39 | +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED |
| 40 | +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED |
| 41 | +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED |
| 42 | +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED |
| 43 | +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED |
| 44 | +#define MBEDTLS_ECP_DP_BP256R1_ENABLED |
| 45 | +#define MBEDTLS_ECP_DP_BP384R1_ENABLED |
| 46 | +#define MBEDTLS_ECP_DP_BP512R1_ENABLED |
| 47 | +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED |
| 48 | +#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 49 | +#define MBEDTLS_NO_PLATFORM_ENTROPY |
| 50 | +#define MBEDTLS_PKCS1_V15 |
| 51 | +#define MBEDTLS_SHA256_SMALLER |
| 52 | +#define MBEDTLS_SSL_PROTO_TLS1 |
| 53 | +#define MBEDTLS_SSL_PROTO_TLS1_1 |
| 54 | +#define MBEDTLS_SSL_PROTO_TLS1_2 |
| 55 | +#define MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 56 | + |
| 57 | +// Use a smaller output buffer to reduce size of SSL context |
| 58 | +#define MBEDTLS_SSL_MAX_CONTENT_LEN (16384) |
| 59 | +#define MBEDTLS_SSL_IN_CONTENT_LEN (MBEDTLS_SSL_MAX_CONTENT_LEN) |
| 60 | +#define MBEDTLS_SSL_OUT_CONTENT_LEN (4096) |
| 61 | + |
| 62 | +// Enable mbedtls modules |
| 63 | +#define MBEDTLS_AES_C |
| 64 | +#define MBEDTLS_ASN1_PARSE_C |
| 65 | +#define MBEDTLS_BIGNUM_C |
| 66 | +#define MBEDTLS_CIPHER_C |
| 67 | +#define MBEDTLS_CTR_DRBG_C |
| 68 | +// #define MBEDTLS_ECP_C |
| 69 | +#define MBEDTLS_ENTROPY_C |
| 70 | +#define MBEDTLS_ERROR_C |
| 71 | +#define MBEDTLS_MD_C |
| 72 | +#define MBEDTLS_MD5_C |
| 73 | +#define MBEDTLS_OID_C |
| 74 | +#define MBEDTLS_PKCS5_C |
| 75 | +#define MBEDTLS_PK_C |
| 76 | +#define MBEDTLS_PK_PARSE_C |
| 77 | +#define MBEDTLS_PLATFORM_C |
| 78 | +#define MBEDTLS_RSA_C |
| 79 | +#define MBEDTLS_SHA1_C |
| 80 | +#define MBEDTLS_SHA256_C |
| 81 | +#define MBEDTLS_SHA512_C |
| 82 | +#define MBEDTLS_SSL_CLI_C |
| 83 | +#define MBEDTLS_SSL_SRV_C |
| 84 | +#define MBEDTLS_SSL_TLS_C |
| 85 | +#define MBEDTLS_X509_CRT_PARSE_C |
| 86 | +#define MBEDTLS_X509_USE_C |
| 87 | + |
| 88 | +// Memory allocation hooks |
| 89 | +#include <stdlib.h> |
| 90 | +#include <stdio.h> |
| 91 | +void *m_tracked_calloc(size_t nmemb, size_t size); |
| 92 | +void m_tracked_free(void *ptr); |
| 93 | +#define MBEDTLS_PLATFORM_STD_CALLOC m_tracked_calloc |
| 94 | +#define MBEDTLS_PLATFORM_STD_FREE m_tracked_free |
| 95 | +#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf |
| 96 | + |
| 97 | +#include "mbedtls/check_config.h" |
| 98 | + |
| 99 | +#endif /* MICROPY_INCLUDED_MBEDTLS_CONFIG_H */ |
0 commit comments