1 /* mbedTLS self-tests as unit tests
2 
3    Focus on testing functionality where we use ESP32 hardware
4    accelerated crypto features.
5 
6    See also test_hwcrypto.c in esp32 component, which tests hardware crypto without mbedTLS.
7 */
8 #include <string.h>
9 #include <stdio.h>
10 #include <stdbool.h>
11 #include <esp_system.h>
12 #include "mbedtls/sha1.h"
13 #include "mbedtls/sha256.h"
14 #include "mbedtls/sha512.h"
15 #include "mbedtls/aes.h"
16 #include "mbedtls/bignum.h"
17 #include "mbedtls/rsa.h"
18 #include "freertos/FreeRTOS.h"
19 #include "freertos/task.h"
20 #include "freertos/semphr.h"
21 #include "unity.h"
22 #include "sdkconfig.h"
23 #include "test_apb_dport_access.h"
24 
25 TEST_CASE("mbedtls AES self-tests", "[aes]")
26 {
27     start_apb_access_loop();
28     TEST_ASSERT_FALSE_MESSAGE(mbedtls_aes_self_test(1), "AES self-tests should pass.");
29     verify_apb_access_loop();
30 }
31 
32 TEST_CASE("mbedtls MPI self-tests", "[bignum]")
33 {
34     start_apb_access_loop();
35     TEST_ASSERT_FALSE_MESSAGE(mbedtls_mpi_self_test(1), "MPI self-tests should pass.");
36     verify_apb_access_loop();
37 }
38 
39 TEST_CASE("mbedtls RSA self-tests", "[bignum]")
40 {
41     start_apb_access_loop();
42     TEST_ASSERT_FALSE_MESSAGE(mbedtls_rsa_self_test(1), "RSA self-tests should pass.");
43     verify_apb_access_loop();
44 }
45