diff --git a/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/main.cpp b/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/main.cpp index c01fa150e2..67ba75e0fd 100644 --- a/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/main.cpp +++ b/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/main.cpp @@ -15,7 +15,26 @@ * limitations under the License. */ -#if ((!defined(FEATURE_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C))) +#if ((!defined(FEATURE_EXPERIMENTAL_API)) || (!defined(FEATURE_PSA)) || (!defined(TARGET_MBED_PSA_SRV))) +/* +* Currenlty in Mbed OS, PSA is marked as experimental and only few targets +* enable experimental feature by default (ARM_MUSCA_B1, ARM_MUSCA_S1 and +* CYTFM_064B0S2_4343W). Therefore, if this error is reported for a PSA target, +* then it may be possible that experimental feature is not enabled that +* target. In that case use the option +* "--app-config TESTS/configs/experimental.json" while invoking "mbed test". +*/ + +/* +* These PSA tests are only supported for PSA targets (Arm-v7M) in emulation +* mode. For Arm-v8M PSA targets, crypto regression tests provided by TF-M are +* used. Refer to https://github.com/ARMmbed/mbed-os-tf-m-regression-tests +* for more information. +*/ +#error [NOT_SUPPORTED] Only PSA targets (Arm-v7M) in emulation mode are supported. +#else +#include "mbedtls/config.h" +#if (!defined(MBEDTLS_PSA_CRYPTO_C)) #error [NOT_SUPPORTED] Mbed Crypto is OFF - skipping. #else @@ -94,7 +113,7 @@ void test_crypto_asymmetric_encrypt_decrypt(void) unsigned char encrypted[64]; unsigned char decrypted[sizeof(input)]; - psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_ENCRYPT); + psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT); psa_set_key_algorithm(&attributes, alg); psa_set_key_type(&attributes, key_type); psa_set_key_bits(&attributes, key_bits); @@ -469,4 +488,5 @@ int main(void) { return !Harness::run(specification); } -#endif // ((!defined(TARGET_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C))) +#endif // (!defined(MBEDTLS_PSA_CRYPTO_C)) +#endif // ((!defined(FEATURE_EXPERIMENTAL_API)) || (!defined(FEATURE_PSA)))