Skip to content

Commit c950a6a

Browse files
committed
zephyr: changes needed for Zephyr 4.3 default TLS support
Follow-up to #7731 ("Changes needed for default TLS support in zephyr kernel"). Zephyr 4.3's TLS socket integration uses three additional wolfSSL features that were not needed by the 3.7 integration, plus an extension to the native_sim time-source gates introduced in #7731. native_sim timer gates (src/internal.c, wolfcrypt/src/wc_port.c): Extend the !CONFIG_BOARD_NATIVE_POSIX gate in LowResTimer() and the CONFIG_BOARD_NATIVE_POSIX RTC path in z_time() to also cover CONFIG_BOARD_NATIVE_SIM. Zephyr 4.3 renamed the simulator board from native_posix to native_sim; without this, k_cpu_idle() on native_sim advances simulated time during DTLS retransmit loops and the RTC path falls through to uptime-since-boot. Behavior on native_posix is unchanged. New Kconfig options (zephyr/Kconfig, zephyr/user_settings.h): CONFIG_WOLFSSL_SESSION_EXPORT -> HAVE_EXT_CACHE Required by consumers that serialize TLS session state across connections via wolfSSL_i2d_SSL_SESSION / wolfSSL_d2i_SSL_SESSION. CONFIG_WOLFSSL_KEEP_PEER_CERT -> KEEP_PEER_CERT Retain the peer certificate after handshake so the application layer can inspect it via wolfSSL_get_peer_certificate. CONFIG_WOLFSSL_ALWAYS_VERIFY_CB -> WOLFSSL_ALWAYS_VERIFY_CB Invoke an application-set verify callback on successful chain validation in addition to validation failures. All three are default-off; customers opt in the same way they do for the existing CONFIG_WOLFSSL_DTLS / ALPN / PSK feature options. .wolfssl_known_macro_extras: register HAVE_EXT_CACHE.
1 parent fa9f24f commit c950a6a

5 files changed

Lines changed: 36 additions & 4 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ HAVE_ECC512
279279
HAVE_ECC_CDH_CAST
280280
HAVE_ECC_SM2
281281
HAVE_ESP_CLK
282+
HAVE_EXT_CACHE
282283
HAVE_FIPS_VERSION_PORT
283284
HAVE_FUZZER
284285
HAVE_INTEL_MULX

src/internal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10602,7 +10602,8 @@ ProtocolVersion MakeDTLSv1_3(void)
1060210602
word32 LowResTimer(void)
1060310603
{
1060410604
int64_t t;
10605-
#if defined(CONFIG_ARCH_POSIX) && !defined(CONFIG_BOARD_NATIVE_POSIX)
10605+
#if defined(CONFIG_ARCH_POSIX) && !defined(CONFIG_BOARD_NATIVE_POSIX) \
10606+
&& !defined(CONFIG_BOARD_NATIVE_SIM)
1060610607
k_cpu_idle();
1060710608
#endif
1060810609
t = k_uptime_get(); /* returns current uptime in milliseconds */

wolfcrypt/src/wc_port.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Threading/Mutex options:
215215
#endif
216216

217217
#if defined(WOLFSSL_ZEPHYR)
218-
#if defined(CONFIG_BOARD_NATIVE_POSIX)
218+
#if defined(CONFIG_BOARD_NATIVE_POSIX) || defined(CONFIG_BOARD_NATIVE_SIM)
219219
#include "native_rtc.h"
220220
#define CONFIG_RTC
221221
#endif
@@ -4088,7 +4088,7 @@ time_t z_time(time_t * timer)
40884088
#if defined(CONFIG_RTC) && \
40894089
(defined(CONFIG_PICOLIBC) || defined(CONFIG_NEWLIB_LIBC))
40904090

4091-
#if defined(CONFIG_BOARD_NATIVE_POSIX)
4091+
#if defined(CONFIG_BOARD_NATIVE_POSIX) || defined(CONFIG_BOARD_NATIVE_SIM)
40924092

40934093
/* When using native sim, get time from simulator rtc */
40944094
uint32_t nsec = 0;
@@ -4120,7 +4120,7 @@ time_t z_time(time_t * timer)
41204120
return epochTime;
41214121
}
41224122
}
4123-
#endif /* defined(CONFIG_BOARD_NATIVE_POSIX) */
4123+
#endif /* CONFIG_BOARD_NATIVE_POSIX || CONFIG_BOARD_NATIVE_SIM */
41244124
#endif
41254125

41264126
/* Fallback to uptime since boot. This works for relative times, but

zephyr/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ config WOLFSSL_MAX_FRAGMENT_LEN
9898
Sets the maximum fragment length wolfSSL will use, values 1-6 correspond to enum values
9999
WOLFSSL_MFL_* in ssl.h
100100

101+
config WOLFSSL_SESSION_EXPORT
102+
bool "wolfSSL session export support"
103+
help
104+
Enable external session cache (HAVE_EXT_CACHE)
105+
106+
config WOLFSSL_KEEP_PEER_CERT
107+
bool "wolfSSL keep peer certificate support"
108+
help
109+
Retain peer certificate after handshake (KEEP_PEER_CERT)
110+
111+
config WOLFSSL_ALWAYS_VERIFY_CB
112+
bool "wolfSSL always invoke verify callback"
113+
help
114+
Invoke verify callback on success as well as failure (WOLFSSL_ALWAYS_VERIFY_CB)
115+
101116
config WOLFCRYPT_ARMASM
102117
bool "wolfCrypt ARM Assembly support"
103118
depends on WOLFSSL_BUILTIN

zephyr/user_settings.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ extern "C" {
133133
#define NO_SESSION_CACHE /* disable session resumption */
134134
#endif
135135

136+
/* Session export (external session cache) */
137+
#if defined(CONFIG_WOLFSSL_SESSION_EXPORT)
138+
#define HAVE_EXT_CACHE
139+
#endif
140+
141+
/* Keep peer certificate after handshake */
142+
#if defined(CONFIG_WOLFSSL_KEEP_PEER_CERT)
143+
#define KEEP_PEER_CERT
144+
#endif
145+
146+
/* Always invoke verify callback (on success as well as failure) */
147+
#if defined(CONFIG_WOLFSSL_ALWAYS_VERIFY_CB)
148+
#define WOLFSSL_ALWAYS_VERIFY_CB
149+
#endif
150+
136151
/* DTLS */
137152
#if defined(CONFIG_WOLFSSL_DTLS)
138153
#define WOLFSSL_DTLS

0 commit comments

Comments
 (0)