Skip to content

Commit 49163f0

Browse files
committed
Move Mbed TLS self tests to a separate configuration
We potentially save flash space by not enabling Mbed TLS self-tests by default. A new test config file, TESTS/configs/mbedtls.json, is provided to enable self tests. This newly created JSON file also enables timing in Mbed TLS so timing gets tested.
1 parent d6f825e commit 49163f0

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

TESTS/configs/mbedtls.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"macros": [
3+
"MBEDTLS_SELF_TEST",
4+
"MBEDTLS_TIMING_C",
5+
"MBEDTLS_TIMING_ALT"
6+
]
7+
}

connectivity/mbedtls/include/mbedtls/config-no-entropy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#define MBEDTLS_PK_RSA_ALT_SUPPORT
4949
#define MBEDTLS_PKCS1_V15
5050
#define MBEDTLS_PKCS1_V21
51-
#define MBEDTLS_SELF_TEST
51+
//#define MBEDTLS_SELF_TEST
5252
#define MBEDTLS_VERSION_FEATURES
5353
#define MBEDTLS_X509_CHECK_KEY_USAGE
5454
#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE

connectivity/mbedtls/include/mbedtls/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@
13961396
*
13971397
* Enable the checkup functions (*_self_test).
13981398
*/
1399-
#define MBEDTLS_SELF_TEST
1399+
//#define MBEDTLS_SELF_TEST
14001400

14011401
/**
14021402
* \def MBEDTLS_SHA256_SMALLER

connectivity/mbedtls/tests/TESTS/mbedtls/selftest/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ using namespace utest::v1;
3131
#include MBEDTLS_CONFIG_FILE
3232
#endif
3333

34+
#if !defined(MBEDTLS_SELF_TEST)
35+
#error [NOT_SUPPORTED] MBEDTLS_SELF_TEST undefined
36+
#endif
37+
3438
#include "mbedtls/sha256.h"
3539
#include "mbedtls/sha512.h"
3640
#include "mbedtls/entropy.h"

connectivity/mbedtls/tools/importer/adjust-config.sh

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ conf unset MBEDTLS_SSL_TRUNCATED_HMAC
117117

118118
conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO
119119

120+
# potentially save flash space by not enabling self-tests by default
121+
conf unset MBEDTLS_SELF_TEST
122+
120123
# The default size of MBEDTLS_MPI_MAX_SIZE is 1024 bytes.
121124
# In some cases, this value is set to stack buffers.
122125
# Reduce the maximal MBEDTLS_MPI_MAX_SIZE to 512 bytes,

connectivity/mbedtls/tools/importer/adjust-no-entropy-config.sh

+3
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ add_code() {
3737

3838
conf set MBEDTLS_CMAC_C
3939
conf unset MBEDTLS_CIPHER_MODE_XTS
40+
41+
# potentially save flash space by not enabling self-tests by default
42+
conf unset MBEDTLS_SELF_TEST

0 commit comments

Comments
 (0)