|
|
@@ -3,6 +3,7 @@
|
|
|
#include "wm_include.h"
|
|
|
#include "wm_crypto_hard.h"
|
|
|
#include "aes.h"
|
|
|
+#include "wm_osal.h"
|
|
|
|
|
|
#include "luat_base.h"
|
|
|
#include "luat_crypto.h"
|
|
|
@@ -13,15 +14,19 @@
|
|
|
#include "task.h"
|
|
|
|
|
|
int luat_crypto_trng(char* buff, size_t len) {
|
|
|
- // 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);
|
|
|
+ #define TMP_LEN (8)
|
|
|
+ char tmp[TMP_LEN];
|
|
|
+ tls_crypto_random_init(tls_os_get_time(), CRYPTO_RNG_SWITCH_32);
|
|
|
+ vTaskDelay(1);
|
|
|
+ tls_crypto_random_bytes_range(tmp, TMP_LEN, 255);
|
|
|
+ tls_crypto_random_stop();
|
|
|
+
|
|
|
extern int random_get_bytes(void *buf, size_t len);
|
|
|
random_get_bytes(buff, len);
|
|
|
+ for (size_t i = 0; i < len; i++)
|
|
|
+ {
|
|
|
+ buff[i] ^= tmp[i % TMP_LEN];
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|