test_mbedtls.c 1.2 KB

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