Skip to content

Commit e9b5f71

Browse files
committed
Provide an implementation of mbedtls_hardware_poll
1 parent 2813188 commit e9b5f71

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/mgos_mbedtls.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "mongoose.h"
99

10+
#include "mbedtls/entropy_poll.h"
1011
#include "mbedtls/md5.h"
1112
#include "mbedtls/sha1.h"
1213
#include "mbedtls/sha256.h"
@@ -51,6 +52,18 @@ void mg_hash_sha256_v(size_t num_msgs, const uint8_t *msgs[],
5152
mbedtls_sha256_free(&ctx);
5253
}
5354

55+
/* This function is provided by platforms */
56+
extern int mg_ssl_if_mbed_random(void *ctx, unsigned char *buf, size_t len);
57+
58+
/* This feeds the entropy pool (mbedtls_entropy_*). */
59+
int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len,
60+
size_t *olen) {
61+
mg_ssl_if_mbed_random(NULL, output, len);
62+
*olen = len;
63+
(void) data;
64+
return 0;
65+
}
66+
5467
bool mgos_mbedtls_init(void) {
5568
return true;
5669
}

0 commit comments

Comments
 (0)