1 #include <zephyr/zephyr.h> 2 #include <zephyr/device.h> 3 #include <zephyr/drivers/entropy.h> 4 #include <mbedtls/entropy.h> 5 #include <entropy_poll.h> 6 mbedtls_hardware_poll(void * data,unsigned char * output,size_t len,size_t * olen)7int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, 8 size_t *olen) 9 { 10 // const struct device *dev; 11 // size_t chunk_size; 12 13 (void)data; 14 15 if (output == NULL) { 16 return -1; 17 } 18 19 if (olen == NULL) { 20 return -1; 21 } 22 23 if (len == 0) { 24 return -1; 25 } 26 27 // dev = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); 28 29 // if (!dev) { 30 // return MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED; 31 // } 32 33 // while (len > 0) { 34 // chunk_size = MIN(MBEDTLS_ENTROPY_MAX_GATHER, len); 35 36 // if (entropy_get_entropy(dev, output, chunk_size) < 0) { 37 // return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; 38 // } 39 40 // *olen += chunk_size; 41 // output += chunk_size; 42 // len -= chunk_size; 43 // } 44 45 /*We don't get real random numbers*/ 46 for (size_t i = 0; i < len; i++) { 47 output[i] = i; 48 } 49 50 *olen = len; 51 52 return 0; 53 }