Skip to content

Commit

Permalink
modules: mbedtls: Add a mbedtls_ms_time implementation
Browse files Browse the repository at this point in the history
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 <markus.swarowsky@nordicsemi.no>
  • Loading branch information
mswarowsky committed Dec 12, 2023
1 parent fc97d29 commit 62f19de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/mbedtls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
1 change: 1 addition & 0 deletions modules/mbedtls/configs/config-tls-generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions modules/mbedtls/zephyr_time.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <mbedtls/platform_time.h>
#include <zephyr/kernel.h>

mbedtls_ms_time_t mbedtls_ms_time(void)
{
return (mbedtls_ms_time_t)k_uptime_get();
}

0 comments on commit 62f19de

Please sign in to comment.