This repository was archived by the owner on Apr 24, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 18
18
#include < sstream>
19
19
#include < vector>
20
20
#include " mbed-trace/mbed_trace.h"
21
+ #include " mbedtls/entropy_poll.h"
21
22
22
23
#include " security.h"
23
24
@@ -256,19 +257,29 @@ void blinky() { status_led = !status_led; }
256
257
// Entry point to the program
257
258
int main () {
258
259
259
- #ifndef MBEDTLS_ENTROPY_HARDWARE_ALT
260
+ unsigned int seed;
261
+ size_t len;
262
+
263
+ #ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
264
+ // Used to randomize source port
265
+ mbedtls_hardware_poll (NULL , (unsigned char *) &seed, sizeof seed, &len);
266
+
267
+ #elif defined MBEDTLS_TEST_NULL_ENTROPY
260
268
261
- #ifdef MBEDTLS_TEST_NULL_ENTROPY
262
269
#warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware."
270
+ // Used to randomize source port
271
+ mbedtls_null_entropy_poll ( NULL ,(unsigned char *) &seed, sizeof seed, &len);
263
272
264
273
#else
265
274
266
275
#error "This hardware does not have entropy, endpoint will not register to Connector.\
267
276
You need to enable NULL ENTROPY for your application, but if this configuration change is made then no security is offered by mbed TLS.\
268
277
Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app.json macros to register your endpoint."
269
- #endif
270
278
271
279
#endif
280
+
281
+ srand(seed);
282
+
272
283
status_ticker.attach_us(blinky, 250000);
273
284
274
285
// Keep track of the main thread
Original file line number Diff line number Diff line change @@ -91,7 +91,6 @@ class MbedClient: public M2MInterfaceObserver {
91
91
void *handler=NULL ) {
92
92
// Randomizing listening port for Certificate mode connectivity
93
93
_server_address = server_address;
94
- srand (time (NULL ));
95
94
uint16_t port = rand () % 65535 + 12345 ;
96
95
97
96
// create mDS interface object, this is the base object everything else attaches to
You can’t perform that action at this time.
0 commit comments