1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
32
33
41
42
46
47
52
53
62
63
64
/* ... */
#include "os.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include "esp_random.h"
#include "utils/common.h"
#include "mbedtls/platform_util.h"7 includes
int os_get_time(struct os_time *t)
{
struct timeval tv;
int ret = gettimeofday(&tv, NULL);
t->sec = (os_time_t) tv.tv_sec;
t->usec = tv.tv_usec;
return ret;
}{ ... }
unsigned long os_random(void)
{
return esp_random();
}{ ... }
int os_get_random(unsigned char *buf, size_t len)
{
esp_fill_random(buf, len);
return 0;
}{ ... }
void os_sleep(os_time_t sec, os_time_t usec)
{
if (sec) {
sleep(sec);
}{...}
if (usec) {
usleep(usec);
}{...}
}{ ... }
#ifdef CONFIG_CRYPTO_MBEDTLS
void forced_memzero(void *ptr, size_t len)
{
mbedtls_platform_zeroize(ptr, len);
}{ ... }
/* ... */#endif