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 8c1e1dd
Show file tree
Hide file tree
Showing 7 changed files with 19 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-mini-tls1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
/* System support */
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HAVE_TIME
#define MBEDTLS_PLATFORM_MS_TIME_ALT

/* mbed TLS feature support */
#define MBEDTLS_CIPHER_MODE_CBC
Expand Down
1 change: 1 addition & 0 deletions modules/mbedtls/configs/config-no-entropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
/* System support */
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HAVE_TIME
#define MBEDTLS_PLATFORM_MS_TIME_ALT

/* mbed TLS feature support */
#define MBEDTLS_CIPHER_MODE_CBC
Expand Down
1 change: 1 addition & 0 deletions modules/mbedtls/configs/config-suite-b.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
/* System support */
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HAVE_TIME
#define MBEDTLS_PLATFORM_MS_TIME_ALT

/* mbed TLS feature support */
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
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();
}
1 change: 1 addition & 0 deletions tests/subsys/jwt/src/tls_config/user-tls-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
#define MBEDTLS_HAVE_TIME
#define MBEDTLS_HAVE_TIME_DATE
#define MBEDTLS_PLATFORM_TIME_ALT
#define MBEDTLS_PLATFORM_MS_TIME_ALT

0 comments on commit 8c1e1dd

Please sign in to comment.