sha_common.c 679 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #include "sha_common.h"
  8. #include "hpm_l1c_drv.h"
  9. ATTR_PLACE_AT_NONCACHEABLE sdp_hash_ctx_t s_hash_ctx;
  10. static volatile bool flag_sdp_inited = false;
  11. #if defined(MBEDTLS_SHA1_ALT) || defined(MBEDTLS_SHA256_ALT)
  12. /* Implementation that should never be optimized out by the compiler */
  13. void mbedtls_zeroize(void *v, size_t n)
  14. {
  15. volatile unsigned char *p = v;
  16. while (0U != n--)
  17. {
  18. *p++ = 0;
  19. }
  20. }
  21. void hpm_sdp_api_init(void)
  22. {
  23. if (!flag_sdp_inited)
  24. {
  25. flag_sdp_inited = true;
  26. rom_sdp_init();
  27. }
  28. }
  29. #endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT */