@@ -64,6 +64,92 @@ component_build_psa_crypto_spm () {
64
64
check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
65
65
}
66
66
67
+ # The goal of this component is to build a configuration where:
68
+ # - test code and libtestdriver1 can make use of calloc/free and
69
+ # - core library (including PSA core) cannot use calloc/free.
70
+ component_test_psa_crypto_without_heap () {
71
+ # Disable PSA features that cannot be accelerated and whose builtin support
72
+ # requires calloc/free.
73
+ scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
74
+ scripts/config.py -f $CRYPTO_CONFIG_H unset-all PSA_WANT_ALG_HKDF*
75
+ scripts/config.py -f $CRYPTO_CONFIG_H unset-all PSA_WANT_ALG_PBKDF2*
76
+ scripts/config.py -f $CRYPTO_CONFIG_H unset-all PSA_WANT_ALG_TLS12*
77
+ # RSA key support requires ASN1 parse/write support for testing, but ASN1
78
+ # is disabled below.
79
+ scripts/config.py -f $CRYPTO_CONFIG_H unset-all PSA_WANT_KEY_TYPE_RSA_*
80
+ scripts/config.py -f $CRYPTO_CONFIG_H unset-all PSA_WANT_ALG_RSA_*
81
+ # DES requires built-in support for key generation (parity check) so it
82
+ # cannot be accelerated
83
+ scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_DES
84
+ # EC-JPAKE use calloc/free in PSA core
85
+ scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_JPAKE
86
+
87
+ # Accelerate all PSA features (which are still enabled in CRYPTO_CONFIG_H).
88
+ PSA_SYM_LIST=$( ./scripts/config.py -f $CRYPTO_CONFIG_H get-all-enabled PSA_WANT)
89
+ loc_accel_list=$( echo $PSA_SYM_LIST | sed ' s/PSA_WANT_//g' )
90
+
91
+ msg " build: libtestdriver1"
92
+ helper_libtestdriver1_adjust_config crypto
93
+ helper_libtestdriver1_make_drivers " $loc_accel_list "
94
+
95
+ msg " build: main library"
96
+ # Enable fully-static key slots in PSA core.
97
+ scripts/config.py set MBEDTLS_PSA_STATIC_KEY_SLOTS
98
+ # Prevent PSA core from creating a copy of input/output buffers
99
+ scripts/config.py set MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS
100
+ # Prevent PSA core from using CTR-DRBG or HMAC-DRBG for random generation.
101
+ scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
102
+ # Set cmalloc/free as null pointer functions. Calling them would crash
103
+ # the program so we can use this as a "sentinel" for being sure no module
104
+ # is making use of these functions in the library.
105
+ scripts/config.py set MBEDTLS_PLATFORM_MEMORY
106
+ scripts/config.py set MBEDTLS_PLATFORM_STD_CALLOC NULL
107
+ scripts/config.py set MBEDTLS_PLATFORM_STD_FREE NULL
108
+
109
+ # Disable all the modules/features that use cmalloc directly
110
+ scripts/config.py unset-all MBEDTLS_ASN1_
111
+ scripts/config.py unset MBEDTLS_BIGNUM_C
112
+ scripts/config.py unset MBEDTLS_CIPHER_C
113
+ scripts/config.py unset MBEDTLS_CMAC_C
114
+ scripts/config.py unset MBEDTLS_DHM_C
115
+ scripts/config.py unset MBEDTLS_ECDSA_C
116
+ scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
117
+ scripts/config.py unset MBEDTLS_ECP_C
118
+ scripts/config.py unset-all MBEDTLS_LMS_
119
+ scripts/config.py unset MBEDTLS_MD_C
120
+ scripts/config.py unset MBEDTLS_OID_C
121
+ scripts/config.py unset-all MBEDTLS_PEM_
122
+ scripts/config.py unset MBEDTLS_PKCS7_C
123
+ scripts/config.py unset-all MBEDTLS_PK_
124
+ scripts/config.py unset MBEDTLS_RSA_C
125
+ scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
126
+ # Disable all modules that depend on the the previous ones
127
+ scripts/config.py unset MBEDTLS_NIST_KW_C
128
+ scripts/config.py unset MBEDTLS_ECDH_C
129
+ scripts/config.py unset MBEDTLS_ECJPAKE_C
130
+ scripts/config.py unset-all MBEDTLS_PKCS1_
131
+ scripts/config.py unset-all MBEDTLS_ENTROPY_
132
+ scripts/config.py unset-all MBEDTLS_SHA
133
+ scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
134
+ scripts/config.py unset MBEDTLS_HKDF_C
135
+ scripts/config.py unset MBEDTLS_PKCS5_C
136
+ scripts/config.py unset MBEDTLS_PKCS12_C
137
+ scripts/config.py unset MBEDTLS_HMAC_DRBG_C
138
+ scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC
139
+ helper_libtestdriver1_make_main " $loc_accel_list " lib
140
+
141
+ msg " build: test suites and helpers"
142
+ # Reset cmalloc/free functions to normal operations so that test code can
143
+ # freely use them.
144
+ scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
145
+ scripts/config.py unset MBEDTLS_PLATFORM_STD_CALLOC
146
+ scripts/config.py unset MBEDTLS_PLATFORM_STD_FREE
147
+ helper_libtestdriver1_make_main " $loc_accel_list " tests
148
+
149
+ msg " run tests"
150
+ make test
151
+ }
152
+
67
153
# Get a list of library-wise undefined symbols and ensure that they only
68
154
# belong to psa_xxx() functions and not to mbedtls_yyy() ones.
69
155
# This function is a common helper used by both:
0 commit comments