hardware_alt.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. * not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. * This file is part of mbed TLS (https://tls.mbed.org)
  18. */
  19. #if !defined(MBEDTLS_CONFIG_FILE)
  20. #include "mbedtls/config.h"
  21. #else
  22. #include MBEDTLS_CONFIG_FILE
  23. #endif
  24. #include "mbedtls/platform.h"
  25. #include "wm_osal.h"
  26. #include "wm_crypto_hard.h"
  27. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  28. int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t *olen )
  29. {
  30. #if 0
  31. tls_crypto_random_init(tls_os_get_time(), CRYPTO_RNG_SWITCH_32);
  32. tls_os_time_delay(0);
  33. tls_crypto_random_bytes(output, len);
  34. tls_crypto_random_stop();
  35. #else
  36. {
  37. extern int random_get_bytes(void *buf, size_t len);
  38. random_get_bytes(output, len);
  39. }
  40. #endif
  41. *olen = len;
  42. return 0;
  43. }
  44. #endif
  45. mbedtls_time_t mbedtls_time( mbedtls_time_t* timer )
  46. {
  47. return (mbedtls_time_t)tls_os_get_time();
  48. }