Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbedTLSConfig_mbedOS_SW_TRNG.h Source File

mbedTLSConfig_mbedOS_SW_TRNG.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2018-2019 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #ifndef PAL_MBEDTLS_USER_CONFIG_H
00020 #define PAL_MBEDTLS_USER_CONFIG_H
00021 
00022 
00023 /*! All of the following definitions are mandatory requirements for correct 
00024 *   functionality of PAL TLS and Crypto components.
00025 *   Please do not disable them.
00026 */
00027 
00028 /* Platform has time function to provide time for certificates verifications */
00029 #ifndef MBEDTLS_HAVE_TIME
00030     #define MBEDTLS_HAVE_TIME
00031 #endif //MBEDTLS_HAVE_TIME
00032 
00033 #ifndef MBEDTLS_HAVE_TIME_DATE
00034     #define MBEDTLS_HAVE_TIME_DATE
00035 #endif //MBEDTLS_HAVE_TIME_DATE
00036 
00037 #ifndef MBEDTLS_PLATFORM_TIME_ALT
00038     #define MBEDTLS_PLATFORM_TIME_ALT
00039 #endif //MBEDTLS_PLATFORM_TIME_ALT
00040 
00041 /* System support */
00042 #ifndef MBEDTLS_HAVE_ASM
00043     #define MBEDTLS_HAVE_ASM
00044 #endif //MBEDTLS_HAVE_ASM
00045 
00046 /* mbed TLS feature support */
00047 #ifndef MBEDTLS_ECP_DP_SECP256R1_ENABLED
00048     #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
00049 #endif //MBEDTLS_ECP_DP_SECP256R1_ENABLED
00050 
00051 #ifndef MBEDTLS_ECP_NIST_OPTIM
00052     #define MBEDTLS_ECP_NIST_OPTIM
00053 #endif //MBEDTLS_ECP_NIST_OPTIM
00054 
00055 #ifndef MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
00056     #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
00057 #endif //MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
00058 
00059 #ifndef MBEDTLS_SSL_PROTO_TLS1_2
00060     #define MBEDTLS_SSL_PROTO_TLS1_2
00061 #endif //MBEDTLS_SSL_PROTO_TLS1_2
00062 
00063 #ifndef MBEDTLS_SSL_PROTO_DTLS
00064     #define MBEDTLS_SSL_PROTO_DTLS
00065 #endif //MBEDTLS_SSL_PROTO_DTLS
00066 
00067 #ifndef MBEDTLS_SSL_DTLS_ANTI_REPLAY
00068     #define MBEDTLS_SSL_DTLS_ANTI_REPLAY
00069 #endif //MBEDTLS_SSL_DTLS_ANTI_REPLAY
00070 
00071 #ifndef MBEDTLS_SSL_DTLS_HELLO_VERIFY
00072     #define MBEDTLS_SSL_DTLS_HELLO_VERIFY
00073 #endif //MBEDTLS_SSL_DTLS_HELLO_VERIFY
00074 
00075 #ifndef MBEDTLS_SSL_EXPORT_KEYS
00076     #define MBEDTLS_SSL_EXPORT_KEYS
00077 #endif //MBEDTLS_SSL_EXPORT_KEYS
00078 
00079 /* mbed TLS modules */
00080 #ifndef MBEDTLS_AES_C
00081     #define MBEDTLS_AES_C
00082 #endif //MBEDTLS_AES_C
00083 
00084 /* Disable some of the speed optimizations on AES code to save
00085  * ~6200 bytes of ROM. According to comments on the mbedtls PR 394,
00086  * the speed on Cortex M4 is not even reduced by this. */
00087 #ifndef MBEDTLS_AES_FEWER_TABLES
00088     #define MBEDTLS_AES_FEWER_TABLES
00089 #endif // MBEDTLS_AES_FEWER_TABLES
00090 
00091 #ifndef MBEDTLS_ASN1_PARSE_C
00092     #define MBEDTLS_ASN1_PARSE_C
00093 #endif //MBEDTLS_ASN1_PARSE_C
00094 
00095 #ifndef MBEDTLS_ASN1_WRITE_C
00096     #define MBEDTLS_ASN1_WRITE_C
00097 #endif //MBEDTLS_ASN1_WRITE_C
00098 
00099 #ifndef MBEDTLS_BIGNUM_C
00100     #define MBEDTLS_BIGNUM_C
00101 #endif //MBEDTLS_BIGNUM_C
00102 
00103 #ifndef MBEDTLS_CIPHER_C
00104     #define MBEDTLS_CIPHER_C
00105 #endif //MBEDTLS_CIPHER_C
00106 
00107 #ifndef MBEDTLS_CTR_DRBG_C
00108     #define MBEDTLS_CTR_DRBG_C
00109 #endif //MBEDTLS_CTR_DRBG_C
00110 
00111 #ifndef MBEDTLS_ECP_C
00112     #define MBEDTLS_ECP_C
00113 #endif //MBEDTLS_ECP_C
00114 
00115 #ifndef MBEDTLS_ENTROPY_NV_SEED
00116     #define MBEDTLS_ENTROPY_NV_SEED
00117 #endif //MBEDTLS_ENTROPY_NV_SEED
00118 
00119 #ifndef MBEDTLS_NO_PLATFORM_ENTROPY
00120     #define MBEDTLS_NO_PLATFORM_ENTROPY
00121 #endif //MBEDTLS_NO_PLATFORM_ENTROPY
00122 
00123 #ifndef MBEDTLS_ENTROPY_C
00124     #define MBEDTLS_ENTROPY_C
00125 #endif //MBEDTLS_ENTROPY_C
00126 
00127 #ifndef MBEDTLS_MD_C
00128     #define MBEDTLS_MD_C
00129 #endif //MBEDTLS_MD_C
00130 
00131 #ifndef MBEDTLS_OID_C
00132     #define MBEDTLS_OID_C
00133 #endif //MBEDTLS_OID_C
00134 
00135 #ifndef MBEDTLS_PK_C
00136     #define MBEDTLS_PK_C
00137 #endif //MBEDTLS_PK_C
00138 
00139 #ifndef MBEDTLS_PK_PARSE_C
00140     #define MBEDTLS_PK_PARSE_C
00141 #endif //MBEDTLS_PK_PARSE_C
00142 
00143 #ifndef MBEDTLS_SHA256_C
00144     #define MBEDTLS_SHA256_C
00145 #endif //MBEDTLS_SHA256_C
00146 
00147 // Disable the speed optimizations of SHA256, makes binary size smaller
00148 // on Cortex-M by 1800B with ARMCC5 and 1384B with GCC 6.3.
00149 #ifndef MBEDTLS_SHA256_SMALLER
00150     #define MBEDTLS_SHA256_SMALLER
00151 #endif // MBEDTLS_SHA256_SMALLER
00152 
00153 #ifndef MBEDTLS_SSL_COOKIE_C
00154     #define MBEDTLS_SSL_COOKIE_C
00155 #endif //MBEDTLS_SSL_COOKIE_C
00156 
00157 #ifndef MBEDTLS_SSL_CLI_C
00158     #define MBEDTLS_SSL_CLI_C
00159 #endif //MBEDTLS_SSL_CLI_C
00160 
00161 #ifndef MBEDTLS_SSL_TLS_C
00162     #define MBEDTLS_SSL_TLS_C
00163 #endif //MBEDTLS_SSL_TLS_C
00164 // XXX mbedclient needs these: mbedtls_x509_crt_free, mbedtls_x509_crt_init, mbedtls_x509_crt_parse
00165 #ifndef MBEDTLS_X509_USE_C
00166     #define MBEDTLS_X509_USE_C
00167 #endif //MBEDTLS_X509_USE_C
00168 
00169 #ifndef MBEDTLS_X509_CRT_PARSE_C
00170     #define MBEDTLS_X509_CRT_PARSE_C
00171 #endif //MBEDTLS_X509_CRT_PARSE_C
00172 // a bit wrong way to get mbedtls_ssl_conf_psk:
00173 #ifndef MBEDTLS_CMAC_C
00174     #define MBEDTLS_CMAC_C
00175 #endif //MBEDTLS_CMAC_C
00176 
00177 #ifndef MBEDTLS_ECDH_C
00178     #define MBEDTLS_ECDH_C
00179 #endif //MBEDTLS_ECDH_C
00180 
00181 #ifndef MBEDTLS_ECDSA_C
00182     #define MBEDTLS_ECDSA_C
00183 #endif //MBEDTLS_ECDSA_C
00184 
00185 #ifndef MBEDTLS_GCM_C
00186     #define MBEDTLS_GCM_C
00187 #endif //MBEDTLS_GCM_C
00188 
00189 #ifndef MBEDTLS_X509_CRT_PARSE_C
00190     #define MBEDTLS_X509_CRT_PARSE_C
00191 #endif //MBEDTLS_X509_CRT_PARSE_C
00192 
00193 #ifndef MBEDTLS_X509_CSR_PARSE_C
00194     #define MBEDTLS_X509_CSR_PARSE_C
00195 #endif //MBEDTLS_X509_CSR_PARSE_C
00196 
00197 #ifndef MBEDTLS_X509_CREATE_C
00198     #define MBEDTLS_X509_CREATE_C
00199 #endif //MBEDTLS_X509_CREATE_C
00200 
00201 #ifndef MBEDTLS_X509_CSR_WRITE_C
00202     #define MBEDTLS_X509_CSR_WRITE_C
00203 #endif //MBEDTLS_X509_CSR_WRITE_C
00204 
00205 #ifndef MBEDTLS_CTR_DRBG_MAX_REQUEST
00206     #define MBEDTLS_CTR_DRBG_MAX_REQUEST 2048
00207 #endif //MBEDTLS_CTR_DRBG_MAX_REQUEST
00208 
00209 // Needed by update
00210 #ifndef MBEDTLS_CIPHER_MODE_CTR
00211     #define MBEDTLS_CIPHER_MODE_CTR
00212 #endif //MBEDTLS_CIPHER_MODE_CTR
00213 
00214 // Save ROM and a few bytes of RAM by specifying our own ciphersuite list
00215 #ifndef MBEDTLS_SSL_CIPHERSUITES
00216     #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, \
00217                                      MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, \
00218                                      MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, \
00219                                      MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8, \
00220                                      MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8
00221 #endif //MBEDTLS_SSL_CIPHERSUITES
00222 
00223 /*! All of the following definitions are optimizations (reduce mbedTLS memory usage and size),
00224 *   changing them is on the user responsibility since they can enlarge
00225 *   the binary footprint and the memory usage
00226 */
00227 
00228 // define to save 8KB RAM at the expense of ROM
00229 #ifndef MBEDTLS_AES_ROM_TABLES
00230     #define MBEDTLS_AES_ROM_TABLES
00231 #endif //MBEDTLS_AES_ROM_TABLES
00232 
00233 // Reduce IO buffer to save RAM, default is 16KB
00234 #ifndef MBEDTLS_SSL_MAX_CONTENT_LEN
00235     #define MBEDTLS_SSL_MAX_CONTENT_LEN 4096
00236 #endif //MBEDTLS_SSL_MAX_CONTENT_LEN
00237 
00238 // needed for Base64 encoding Opaque data for
00239 // registration payload, adds 500 bytes to flash.
00240 #ifndef MBEDTLS_BASE64_C
00241     #define MBEDTLS_BASE64_C
00242 #endif // MBEDTLS_BASE64_C
00243 
00244 // Needed by provisioning
00245 #undef MBEDTLS_PEM_WRITE_C
00246 
00247 // Remove RSA, save 20KB at total
00248 #undef MBEDTLS_RSA_C
00249 
00250 #undef MBEDTLS_PK_RSA_ALT_SUPPORT
00251 
00252 #undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
00253 
00254 #undef MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
00255 
00256 #undef MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
00257 
00258 //#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
00259    
00260 // Remove error messages, save 10KB of ROM
00261 #undef MBEDTLS_ERROR_C
00262 
00263 // Remove selftesting and save 11KB of ROM
00264 #undef MBEDTLS_SELF_TEST
00265 
00266 #undef MBEDTLS_CERTS_C
00267 
00268 // Reduces ROM size by 30 kB
00269 #undef MBEDTLS_ERROR_STRERROR_DUMMY
00270 
00271 #undef MBEDTLS_VERSION_FEATURES
00272 
00273 #undef MBEDTLS_DEBUG_C
00274 
00275 // needed for parsing the certificates
00276 #undef MBEDTLS_PEM_PARSE_C
00277 
00278 #undef MBEDTLS_SHA512_C
00279 
00280 #undef MBEDTLS_SSL_SRV_C
00281 
00282 #undef MBEDTLS_ECP_DP_SECP192R1_ENABLED
00283 #undef MBEDTLS_ECP_DP_SECP224R1_ENABLED
00284 #undef MBEDTLS_ECP_DP_SECP384R1_ENABLED
00285 #undef MBEDTLS_ECP_DP_SECP521R1_ENABLED
00286 #undef MBEDTLS_ECP_DP_SECP192K1_ENABLED
00287 #undef MBEDTLS_ECP_DP_SECP224K1_ENABLED
00288 #undef MBEDTLS_ECP_DP_SECP256K1_ENABLED
00289 #undef MBEDTLS_ECP_DP_BP256R1_ENABLED
00290 #undef MBEDTLS_ECP_DP_BP384R1_ENABLED
00291 #undef MBEDTLS_ECP_DP_BP512R1_ENABLED
00292 #undef MBEDTLS_ECP_DP_CURVE25519_ENABLED
00293 
00294 #define MBEDTLS_PLATFORM_TIME_ALT
00295 
00296 /**
00297  * \def MBEDTLS_SSL_RENEGOTIATION
00298  *
00299  * Enable support for TLS renegotiation.
00300  *
00301  * The two main uses of renegotiation are (1) refresh keys on long-lived
00302  * connections and (2) client authentication after the initial handshake.
00303  * If you don't need renegotiation, it's probably better to disable it, since
00304  * it has been associated with security issues in the past and is easy to
00305  * misuse/misunderstand.
00306  *
00307  * Comment this to disable support for renegotiation.
00308  *
00309  * \note   Even if this option is disabled, both client and server are aware
00310  *         of the Renegotiation Indication Extension (RFC 5746) used to
00311  *         prevent the SSL renegotiation attack (see RFC 5746 Sect. 1).
00312  *         (See \c mbedtls_ssl_conf_legacy_renegotiation for the
00313  *          configuration of this extension).
00314  *
00315  * \note   This feature is required by Device Management Client for Client-side
00316  *         certificate expiration verification. Disabling it will also require
00317  *         setting PAL_USE_SECURE_TIME to 0.
00318  *
00319  */
00320 #define MBEDTLS_SSL_RENEGOTIATION
00321 
00322 #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
00323 
00324 // Reduces size particularly in case PSA crypto is used
00325 #undef MBEDTLS_CHACHA20_C
00326 #undef MBEDTLS_CHACHAPOLY_C
00327 #undef MBEDTLS_POLY1305_C
00328 
00329 #include "mbedtls/check_config.h"
00330 
00331 #endif /* PAL_MBEDTLS_USER_CONFIG_H */