From 62f19de5dff4273c1a6b101440b6c9ef25f7a362 Mon Sep 17 00:00:00 2001 From: Markus Swarowsky Date: Mon, 11 Dec 2023 17:27:32 +0100 Subject: [PATCH] modules: mbedtls: Add a mbedtls_ms_time implementation MbedTLS 3.5.0 requires a implementation of mbedtls_ms_time giving a time in ms for TLS 1.3 Therefor adding an alternative implementation using zephyrs k_uptime_get Signed-off-by: Markus Swarowsky --- modules/mbedtls/CMakeLists.txt | 1 + modules/mbedtls/configs/config-tls-generic.h | 1 + modules/mbedtls/zephyr_time.c | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 modules/mbedtls/zephyr_time.c diff --git a/modules/mbedtls/CMakeLists.txt b/modules/mbedtls/CMakeLists.txt index 2bab7fe1038d9b4..a3b81f1d5092f0d 100644 --- a/modules/mbedtls/CMakeLists.txt +++ b/modules/mbedtls/CMakeLists.txt @@ -180,6 +180,7 @@ zephyr_interface_library_named(mbedTLS) ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls13_keys.c ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls13_server.c ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls.c + zephyr_time.c ) zephyr_library_sources(${mbedtls_source}) diff --git a/modules/mbedtls/configs/config-tls-generic.h b/modules/mbedtls/configs/config-tls-generic.h index 61278858ef2b544..59d98f650675e9d 100644 --- a/modules/mbedtls/configs/config-tls-generic.h +++ b/modules/mbedtls/configs/config-tls-generic.h @@ -37,6 +37,7 @@ #if defined(CONFIG_MBEDTLS_HAVE_TIME_DATE) #define MBEDTLS_HAVE_TIME #define MBEDTLS_HAVE_TIME_DATE +#define MBEDTLS_PLATFORM_MS_TIME_ALT #endif #if defined(CONFIG_MBEDTLS_TEST) diff --git a/modules/mbedtls/zephyr_time.c b/modules/mbedtls/zephyr_time.c new file mode 100644 index 000000000000000..152bd9d06dae0da --- /dev/null +++ b/modules/mbedtls/zephyr_time.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +mbedtls_ms_time_t mbedtls_ms_time(void) +{ + return (mbedtls_ms_time_t)k_uptime_get(); +}