1 #include <string.h>
2 #include "pico/platform.h"
3 #include "pico/rand.h"
4 
5 /* Function to feed mbedtls entropy. */
mbedtls_hardware_poll(void * data __unused,unsigned char * output,size_t len,size_t * olen)6 int mbedtls_hardware_poll(void *data __unused, unsigned char *output, size_t len, size_t *olen) {
7     *olen = 0;
8     while(*olen < len) {
9         uint64_t rand_data = get_rand_64();
10         size_t to_copy = MIN(len, sizeof(rand_data));
11         memcpy(output + *olen, &rand_data, to_copy);
12         *olen += to_copy;
13     }
14     return 0;
15 }
16