2016-11-25 03:15:39 -05:00
|
|
|
/* mbedTLS self-tests as unit tests
|
2016-11-17 03:36:10 -05:00
|
|
|
|
|
|
|
Focus on testing functionality where we use ESP32 hardware
|
|
|
|
accelerated crypto features.
|
|
|
|
|
2016-11-25 03:15:39 -05:00
|
|
|
See also test_hwcrypto.c in esp32 component, which tests hardware crypto without mbedTLS.
|
2016-11-17 03:36:10 -05:00
|
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2016-11-25 03:15:39 -05:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <esp_system.h>
|
2016-11-17 03:36:10 -05:00
|
|
|
#include "mbedtls/sha1.h"
|
|
|
|
#include "mbedtls/sha256.h"
|
|
|
|
#include "mbedtls/sha512.h"
|
|
|
|
#include "mbedtls/aes.h"
|
|
|
|
#include "mbedtls/bignum.h"
|
2016-11-25 03:15:39 -05:00
|
|
|
#include "mbedtls/rsa.h"
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "freertos/semphr.h"
|
2016-11-17 03:36:10 -05:00
|
|
|
#include "unity.h"
|
2016-11-25 03:15:39 -05:00
|
|
|
#include "sdkconfig.h"
|
2017-08-15 02:45:40 -04:00
|
|
|
#include "test_apb_dport_access.h"
|
2022-05-20 06:16:47 -04:00
|
|
|
#include "test_utils.h"
|
2016-11-17 03:36:10 -05:00
|
|
|
|
2022-05-20 06:16:47 -04:00
|
|
|
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)
|
|
|
|
//IDF-5141
|
2016-11-17 03:36:10 -05:00
|
|
|
TEST_CASE("mbedtls AES self-tests", "[aes]")
|
|
|
|
{
|
2017-08-15 02:45:40 -04:00
|
|
|
start_apb_access_loop();
|
2016-11-17 03:36:10 -05:00
|
|
|
TEST_ASSERT_FALSE_MESSAGE(mbedtls_aes_self_test(1), "AES self-tests should pass.");
|
2017-08-15 02:45:40 -04:00
|
|
|
verify_apb_access_loop();
|
2016-11-17 03:36:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("mbedtls MPI self-tests", "[bignum]")
|
|
|
|
{
|
2017-08-15 02:45:40 -04:00
|
|
|
start_apb_access_loop();
|
2016-11-17 03:36:10 -05:00
|
|
|
TEST_ASSERT_FALSE_MESSAGE(mbedtls_mpi_self_test(1), "MPI self-tests should pass.");
|
2017-08-15 02:45:40 -04:00
|
|
|
verify_apb_access_loop();
|
2016-11-17 03:36:10 -05:00
|
|
|
}
|
|
|
|
|
2016-11-25 03:15:39 -05:00
|
|
|
TEST_CASE("mbedtls RSA self-tests", "[bignum]")
|
2016-11-17 03:36:10 -05:00
|
|
|
{
|
2017-08-15 02:45:40 -04:00
|
|
|
start_apb_access_loop();
|
2016-11-25 03:15:39 -05:00
|
|
|
TEST_ASSERT_FALSE_MESSAGE(mbedtls_rsa_self_test(1), "RSA self-tests should pass.");
|
2017-08-15 02:45:40 -04:00
|
|
|
verify_apb_access_loop();
|
2016-11-17 03:36:10 -05:00
|
|
|
}
|
2022-05-20 06:16:47 -04:00
|
|
|
#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)
|