浏览代码

fix: 随机数不随机-_-, 改成mbedtls/port里隐藏函数, 测试了1000个数据,没有重复

refer: https://gitee.com/openLuat/LuatOS/issues/I5UEGY
Wendal Chen 3 年之前
父节点
当前提交
78f27cf470
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      app/port/luat_crypto_air101.c

+ 9 - 4
app/port/luat_crypto_air101.c

@@ -13,10 +13,15 @@
 #include "task.h"
 
 int luat_crypto_trng(char* buff, size_t len) {
-    tls_crypto_random_init(0, CRYPTO_RNG_SWITCH_32);
-    vTaskDelay(1);
-    tls_crypto_random_bytes_range(buff, len, 256);
-    tls_crypto_random_stop();
+    // tls_crypto_random_init(0, CRYPTO_RNG_SWITCH_32);
+    // vTaskDelay(5);
+    // tls_crypto_random_bytes_range(buff, len, 256);
+    // tls_crypto_random_bytes_range(buff, len, 256);
+    // tls_crypto_random_bytes_range(buff, len, 256);
+    // tls_crypto_random_stop();
+    // tls_crypto_trng(buff, len);
+    extern int random_get_bytes(void *buf, size_t len);
+	random_get_bytes(buff, len);
     return 0;
 }