test_mbedtls.c 1.4 KB

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