luat_crypto_air101.c 447 B

12345678910111213141516171819202122
  1. #include "string.h"
  2. #include "wm_include.h"
  3. #include "wm_crypto_hard.h"
  4. #include "aes.h"
  5. #include "luat_base.h"
  6. #include "luat_crypto.h"
  7. #define LUAT_LOG_TAG "crypto"
  8. #include "luat_log.h"
  9. static char trng_init = 0;
  10. int luat_crypto_trng(char* buff, size_t len) {
  11. if (trng_init == 0) {
  12. trng_init = 1;
  13. tls_crypto_random_init(0, CRYPTO_RNG_SWITCH_32);
  14. }
  15. tls_crypto_random_bytes_range(buff, len, 256);
  16. return 0;
  17. }