Skip to content

Commit 1ed0285

Browse files
committed
net: l2: wifi: Refactor certificates processing code into common file
Refactor certificate processing code to eliminate duplication and enable reuse across modules that require enterprise support. Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
1 parent c3bb3bf commit 1ed0285

File tree

7 files changed

+427
-525
lines changed

7 files changed

+427
-525
lines changed

include/zephyr/net/wifi_certs.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef WIFI_CERTS_H__
8+
#define WIFI_CERTS_H__
9+
10+
#include <stdbool.h>
11+
#include <zephyr/kernel.h>
12+
#include <zephyr/net/wifi_mgmt.h>
13+
14+
/**
15+
* Set Wi-Fi Enterprise credentials.
16+
*
17+
* Sets up the required credentials for Enterprise mode in both
18+
* Access Point and Station modes.
19+
*
20+
* Certificates typically used:
21+
* - CA certificate
22+
* - Client certificate
23+
* - Client private key
24+
* - Server certificate and server key (for AP mode)
25+
*
26+
* @param iface Network interface
27+
* @param AP or Station mode
28+
*
29+
* @return 0 if ok, < 0 if error
30+
*/
31+
int wifi_set_enterprise_credentials(struct net_if *iface, bool is_ap);
32+
33+
/**
34+
* Clear Wi-Fi enterprise credentials
35+
*
36+
* @param Wi-Fi enterprise params
37+
*/
38+
void wifi_clear_enterprise_credentials(void);
39+
40+
#endif /* WIFI_CERTS_H__ */

modules/hostap/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ config WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
198198
select MBEDTLS_SERVER_NAME_INDICATION if MBEDTLS_BUILTIN
199199
select MBEDTLS_X509_CRL_PARSE_C
200200
select MBEDTLS_TLS_VERSION_1_2
201+
select WIFI_CERTIFICATE_LIB
201202
depends on !WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE
202203

203204
if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
@@ -302,6 +303,7 @@ config WIFI_NM_HOSTAPD_AP
302303

303304
config WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE
304305
bool "Hostapd crypto enterprise support"
306+
select WIFI_CERTIFICATE_LIB
305307
depends on WIFI_NM_HOSTAPD_AP
306308

307309
if WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE

subsys/net/l2/wifi/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ zephyr_library_include_directories_ifdef(
1313
)
1414

1515
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_MGMT wifi_mgmt.c)
16+
zephyr_library_sources_ifdef(CONFIG_WIFI_CERTIFICATE_LIB wifi_certs.c)
1617
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_SHELL wifi_shell.c)
1718
zephyr_library_sources_ifdef(CONFIG_WIFI_NM wifi_nm.c)
1819
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_UTILS wifi_utils.c)

subsys/net/l2/wifi/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ config WIFI_ENT_IDENTITY_MAX_USERS
126126
help
127127
This option defines the maximum number of identity users allowed connection.
128128

129+
config WIFI_CERTIFICATE_LIB
130+
bool
131+
help
132+
Enable this option to process certificates in enterprise mode.
133+
129134
if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
130135

131136
config WIFI_SHELL_RUNTIME_CERTIFICATES

0 commit comments

Comments
 (0)