From e1ac779fd320e6e851546f55ce2051a8ced4f75f Mon Sep 17 00:00:00 2001 From: robert-hh Date: Tue, 30 Jan 2024 10:44:25 +0100 Subject: [PATCH] samd/mbedtls: Adapt for mbdetls v3.5.1. Signed-off-by: robert-hh --- .../{mbedtls_config.h => mbedtls_config_port.h} | 2 ++ ports/samd/mbedtls/mbedtls_port.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) rename ports/samd/mbedtls/{mbedtls_config.h => mbedtls_config_port.h} (96%) diff --git a/ports/samd/mbedtls/mbedtls_config.h b/ports/samd/mbedtls/mbedtls_config_port.h similarity index 96% rename from ports/samd/mbedtls/mbedtls_config.h rename to ports/samd/mbedtls/mbedtls_config_port.h index 0ce474de27..18cedbae10 100644 --- a/ports/samd/mbedtls/mbedtls_config.h +++ b/ports/samd/mbedtls/mbedtls_config_port.h @@ -30,6 +30,8 @@ #include extern time_t samd_rtctime_seconds(time_t *timer); #define MBEDTLS_PLATFORM_TIME_MACRO samd_rtctime_seconds +#define MBEDTLS_PLATFORM_MS_TIME_ALT mbedtls_ms_time + // Set MicroPython-specific options. #define MICROPY_MBEDTLS_CONFIG_BARE_METAL (1) diff --git a/ports/samd/mbedtls/mbedtls_port.c b/ports/samd/mbedtls/mbedtls_port.c index ed9e1e70a5..da6059ca6b 100644 --- a/ports/samd/mbedtls/mbedtls_port.c +++ b/ports/samd/mbedtls/mbedtls_port.c @@ -26,13 +26,14 @@ #ifdef MICROPY_SSL_MBEDTLS -#include "mbedtls_config.h" +#include "mbedtls_config_port.h" #include uint32_t trng_random_u32(void); #if defined(MBEDTLS_HAVE_TIME) || defined(MBEDTLS_HAVE_TIME_DATE) #include #include "py/runtime.h" #include "shared/timeutils/timeutils.h" +#include "mbedtls/platform_time.h" extern void rtc_gettime(timeutils_struct_time_t *tm); #endif @@ -53,6 +54,13 @@ time_t samd_rtctime_seconds(time_t *timer) { rtc_gettime(&tm); return timeutils_seconds_since_epoch(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } + +mbedtls_ms_time_t mbedtls_ms_time(void) { + time_t *tv = NULL; + mbedtls_ms_time_t current_ms; + current_ms = samd_rtctime_seconds(tv) * 1000; + return current_ms; +} #endif #if defined(MBEDTLS_HAVE_TIME_DATE)