Skip to content

Commit

Permalink
Enable building without mbedtls
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer committed Aug 21, 2020
1 parent 24c520d commit 6571430
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/mgos_file_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include <stdbool.h>
#include <stdint.h>

#ifdef MGOS_HAVE_MBEDTLS
#include "mbedtls/md.h"
#endif

#ifdef __cplusplus
extern "C" {
Expand All @@ -29,11 +31,13 @@ extern "C" {
/* Copy a file */
bool mgos_file_copy(const char *from, const char *to);

#ifdef MGOS_HAVE_MBEDTLS
/* Compute file's digest. *digest must have enough space for the digest type. */
bool mgos_file_digest(const char *fname, mbedtls_md_type_t dt, uint8_t *digest);

/* Copy the file if target does not exist or is different. */
bool mgos_file_copy_if_different(const char *from, const char *to);
#endif // MGOS_HAVE_MBEDTLS

#ifdef __cplusplus
}
Expand Down
8 changes: 8 additions & 0 deletions platforms/esp8266/src/esp_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,11 @@ uint32_t mgos_get_cpu_freq(void) {
uint32_t sys_now(void) {
return mgos_uptime_micros() / 1000;
}

// os_get_random uses hardware RNG, so it's cool.
int mg_ssl_if_mbed_random(void *ctx, unsigned char *buf, size_t len) WEAK;
int mg_ssl_if_mbed_random(void *ctx, unsigned char *buf, size_t len) {
os_get_random(buf, len);
(void) ctx;
return 0;
}
2 changes: 2 additions & 0 deletions src/mgos_file_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ bool mgos_file_copy(const char *from, const char *to) {
return ret;
}

#ifdef MGOS_HAVE_MBEDTLS
bool mgos_file_digest(const char *fname, mbedtls_md_type_t dt,
uint8_t *digest) {
bool res = false;
Expand Down Expand Up @@ -137,3 +138,4 @@ bool mgos_file_copy_if_different(const char *from, const char *to) {
if (!res) res = mgos_file_copy(from, to);
return res;
}
#endif // MGOS_HAVE_MBEDTLS

0 comments on commit 6571430

Please sign in to comment.