When MBEDTLS_PSA_CRYPTO_CLIENT is enabled but MBEDTLS_PSA_CRYPTO_C is
disabled, the PSA functions are missing, but there is code in the pk module
that call PSA functions.
When building such a configuration, let the test code provide stub functions
that just return an error. This way, we can link and run programs in this
configuration. The programs will fail at runtime if they try to invoke a PSA
function, so any testing that involves running PSA functions must still be
guarded by MBEDTLS_PSA_CRYPTO_C, not MBEDTLS_PSA_CRYPTO_CLIENT.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
PK should only dispatch non-opaque operations to PSA when
MBEDTLS_USE_PSA_CRYPTO is enabled. When MBEDTLS_USE_PSA_CRYPTO is disabled
but MBEDTLS_PSA_CRYPTO_CLIENT is enabled, MBEDTLS_PK_OPAQUE should be
available but non-opaque operations should still dispatch to the built-in
legacy code. This commit fixes PK dispatch when CLIENT && !USE.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit also solves related issues in order to have test
components related to CRYPTO_CLIENT passing.
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
In both cases we check that both libmbedcrypto is build without
missing any mbedtls_xxx() function. Only psa_yyy() are allowed
to be missing due to the lack of PSA provider in the builds.
Note: the component testing the default configuration now is
"downgraded" to only building the library because in the upcoming
commits this would become untestable as well.
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This also fixes guards in psa_util that were discovered by the
new component_build_full_psa_crypto_client_without_crypto_provider().
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
In valid_parameters_pkwrite, we first parse a public key then test
with mbedtls_pk_write_xxx functions. So valid_parameters_pkwrite
should depend on both MBEDTLS_PK_WRITE_C and MBEDTLS_PK_PARSE_C.
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
Calling mbedtls_test_fail() attempts to lock the test data mutex.
Unfortunately we were calling this from places where we already held
this mutex, and this mutex is not recursive, so this deadlocks. Split
out mbedtls_test_fail() into mbedtls_test_fail_internal() in order to
address this.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
Do for public keys what
"Fix mbedtls_pk_get_bitlen() for RSA with non-byte-aligned sizes"
did for key pairs.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Add non-regression tests. Update some test functions to not assume that
byte_length == bit_length / 8.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
The added comma is needed so that these tests match the regex exceptions
in analyze_outcomes.py.
Moved the Encryption tests so that they are separate to decryption.
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
Make it clearer where the magic number chosen for entropy_len actually
comes from, and why we chose this value.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
These functions are thread safe, but using them from within multiple
threads at the same time may not have the intended effect, given order
cannot be guaranteed. Also, standardise header comment formatting.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>