mirror of https://github.com/ARMmbed/mbed-os.git
Fix PSA-HAL, TRNG, TLS tests
parent
251a270942
commit
2df2fc7d29
|
@ -23,6 +23,10 @@
|
||||||
#error [NOT_SUPPORTED] this test is supported on GCC only
|
#error [NOT_SUPPORTED] this test is supported on GCC only
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TARGET_FUTURE_SEQUANA_PSA)
|
||||||
|
#error [NOT_SUPPORTED] Disable this Test until FUTURE_SEQUANA_PSA enables Memory protection
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
|
@ -66,6 +66,33 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
|
#if (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
|
||||||
|
#include "entropy.h"
|
||||||
|
#include "entropy_poll.h"
|
||||||
|
#include "crypto.h"
|
||||||
|
#if !defined(MAX)
|
||||||
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Calculating the minimum allowed entropy size in bytes */
|
||||||
|
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \
|
||||||
|
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)
|
||||||
|
|
||||||
|
void inject_entropy_for_psa()
|
||||||
|
{
|
||||||
|
if (psa_crypto_init() == PSA_ERROR_INSUFFICIENT_ENTROPY) {
|
||||||
|
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
|
||||||
|
/* inject some a seed for test*/
|
||||||
|
for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
|
||||||
|
seed[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* don't really care if this succeed this is just to make crypto init pass*/
|
||||||
|
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
|
||||||
|
|
||||||
static int fill_buffer_trng(uint8_t *buffer, trng_t *trng_obj, size_t trng_len)
|
static int fill_buffer_trng(uint8_t *buffer, trng_t *trng_obj, size_t trng_len)
|
||||||
{
|
{
|
||||||
size_t temp_size = 0, output_length = 0;
|
size_t temp_size = 0, output_length = 0;
|
||||||
|
@ -241,7 +268,13 @@ Specification specification(greentea_test_setup, cases, greentea_test_teardown_h
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
#if (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
|
||||||
|
inject_entropy_for_psa();
|
||||||
|
#endif
|
||||||
bool ret = !Harness::run(specification);
|
bool ret = !Harness::run(specification);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,32 @@ Case cases[] = {
|
||||||
#endif /* MBEDTLS_SELF_TEST */
|
#endif /* MBEDTLS_SELF_TEST */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
|
||||||
|
#include "crypto.h"
|
||||||
|
#if !defined(MAX)
|
||||||
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Calculating the minimum allowed entropy size in bytes */
|
||||||
|
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \
|
||||||
|
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)
|
||||||
|
|
||||||
|
void inject_entropy_for_psa()
|
||||||
|
{
|
||||||
|
if (psa_crypto_init() == PSA_ERROR_INSUFFICIENT_ENTROPY) {
|
||||||
|
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
|
||||||
|
/* inject some a seed for test*/
|
||||||
|
for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
|
||||||
|
seed[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* don't really care if this succeed this is just to make crypto init pass*/
|
||||||
|
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
|
||||||
|
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t num_cases)
|
utest::v1::status_t test_setup(const size_t num_cases)
|
||||||
{
|
{
|
||||||
GREENTEA_SETUP(120, "default_auto");
|
GREENTEA_SETUP(120, "default_auto");
|
||||||
|
@ -101,6 +127,11 @@ int main()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
|
||||||
|
inject_entropy_for_psa();
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = (Harness::run(specification) ? 0 : 1);
|
ret = (Harness::run(specification) ? 0 : 1);
|
||||||
#if defined(MBEDTLS_PLATFORM_C)
|
#if defined(MBEDTLS_PLATFORM_C)
|
||||||
mbedtls_platform_teardown(NULL);
|
mbedtls_platform_teardown(NULL);
|
||||||
|
|
Loading…
Reference in New Issue