Commit Graph

887 Commits

Author SHA1 Message Date
Shreyas Sheth
65228af9ab fix(wifi): Fix incorrect allocation of eb due to rsn ie len mismatch 2026-01-14 12:42:31 +05:30
yinqingzhao
596ff9722b fix(wpa_supplicant): fix race where STA is freed before WPA3 SAE finishes 2026-01-06 10:42:46 +08:00
Kapil Gupta
c001c8715f fix(esp_wifi): Validate dpp auth instance before using it 2026-01-05 18:37:36 +05:30
Ashish Sharma
cf24bf97f6 fix: fixes failing pipeline with internal wifi mbedtls client 2026-01-05 15:04:03 +08:00
Ashish Sharma
a9927b82b7 fix: fixes coverity reported warnings 2025-12-30 09:31:49 +05:30
Ashish Sharma
0e7dea4b6c feat: migrates wpa_supplicant to PSA APIs 2025-12-30 09:31:49 +05:30
Alexey Lapshin
0169306bc2 Merge branch 'feat/wpa_supplicant_rom_md5_tests' into 'master'
fix(esp_rom): use hmac_md5 and hmac_md5_vector from ROM only if CONFIG_LIBC_NEWLIB

See merge request espressif/esp-idf!44226
2025-12-16 21:39:32 +04:00
Mahavir Jain
474ee7b7e7 tests(wpa_supplicant): add hmac/md5 tests covering ROM APIs 2025-12-15 13:40:31 +05:30
Kapil Gupta
b88befde6b fix(esp_wifi): Fix invalid memory accesses in supplicant code 2025-12-10 20:19:56 +05:30
Konstantin Kondrashov
d2a4f52aac feat(esp_event): Update depends_components
Where esp_event is used as depends_components:
- components/esp_event/host_test
- components/esp_event/test_apps
- examples/system/esp_event/default_event_loop
- examples/system/esp_event/user_event_loops
2025-11-26 17:05:10 +02:00
Konstantin Kondrashov
41fddce773 feat(esp_timer): Update depends_components
Where esp_timer is used as depends_components:
- components/esp_timer/test_apps
- examples/system/esp_timer
2025-11-25 19:23:45 +02:00
Chen Yudong
d591aaf1ae ci: rename wifi_two_dut to two_duts 2025-11-12 10:05:07 +08:00
Sarvesh Bodakhe
4c3d6c1292 fix(wifi): Add refactoring and migration guide for USD, Offchan_tx, ROC
1. fix(wifi): Rename old NAN configuration to NAN-Sync
  - Rename CONFIG_ESP_WIFI_NAN_ENABLE to CONFIG_ESP_WIFI_NAN_SYNC_ENABLE to indicate
    the support for Synchronized NAN (Wi-Fi Aware).
  - Because the original flag really controls the synchronized feature set, rename it
    to CONFIG_ESP_WIFI_NAN_SYNC_ENABLE so the NAN-Sync and NAN-USD paths can be
    selected independently without confusion.
2. Document esp_wifi_start requirement and fix USD examples
3. Rename nan_callbacks to nan_sync_callbacks
4. Remove the discovery_flag, clarify docs for sync vs USD flows, and add USD start/stop APIs
5. Require esp_wifi_start() before USD start
6. docs(nan): add NAN-USD application examples
7. add migration guide and hints for NAN-USD proto field
8. Improve allow_broadcast documentation
9. Add attention to the API esp_wifi_remain_on_channel
10. fix(wifi): align NAN API renames and docs for v6.0
  - keep shared APIs under esp_wifi_nan_* while reserving
    sync/usd names for mode-specific entry points
  - clarify synchronized-cluster scope in headers, docs, and migration notes (EN/zh-CN)
  - update examples for renamed helpers and WIFI_NAN_SYNC_CONFIG_DEFAULT()
  - rename `wifi_nan_config_t` to `wifi_nan_sync_config_t`
11. Mark NAN-USD as esp-idf experimental feature
2025-10-20 12:46:55 +05:30
Sarvesh Bodakhe
a5f6bc639b feat(wifi): Add support to set BSSID (A3) in esp_wifi_action_tx_req 2025-10-20 12:46:44 +05:30
Sarvesh Bodakhe
93347494b3 feat(wifi): Add support for Wi-Fi Aware: Unsynchronized Service Discover (USD)
1.  Remove redundant fixes in upstream wpa_supplicant for USD
    - Upstream supplicant has mostly fixed the issues regarding the
      unnecessary resetting pauseStateTimeout.
    - Upstream supplicant still needs one fix to avoid resetting the
      pauseStateTimeout when subscribe message is received from the peer
      which had triggered the pauseStateTimeout previously.

2.  Replace array-based channel list with bitmap for NaN-USD

    Use `wifi_scan_channel_bitmap_t` to represent the channel list for NaN-USD
    publisher and subscriber configurations. This replaces the previous approach
    that used a large array to store allowed channels.

    Also aligns with internal scan bitmap conventions across Wi-Fi stack.

3.  call esp_wifi_nan_stop() after USD exchange or STA stop

    Ensure esp_wifi_nan_stop() is called after publish/subscribe activity
    completes or when WIFI_EVENT_STA_STOP is received. This prevents NAN stop
    errors due to inactive interface. NaN-USD currently uses STA interface
    for Tx/Rx.

4.  Fix task watchdog timer triggered in active USD subscriber:

    As both USD supplicant and offchan TX component gets executed
    in the wifi task, it created a deadlock like scenario where offchan TX
    done callback was never getting executed and supplicant 'nan_de_timer'
    keeps running but failing to send any subscribe frame.

5.  Make sure that device is able to recieve action management frames
    of size more than 1400 bytes.

6.  Update proto field in SSI to match Wi-Fi Aware (NaN) spec format

    The 'proto' field in the 'wifi_nan_wfa_ssi_t' structure previously used an
    enum (wifi_nan_svc_proto_t), resulting in a 32-bit field. According to
    the Wi-Fi NAN Specification (Table 5.7), this field must be a single
    octet (8 bits). This commit updates the type to uint8_t to ensure
    compliance with the specification.

    This mismatch previously triggered warnings but did not cause functional
    errors.

7.  Set `allow_broadcast` to true in USD Remain on channel

    This enables the peer discovery as USD uses NAN-Network Multicast BSSID
    as A3 address in publish frames.

8.  Implement custom channel<->frequency conversion for NAN-USD

    NaN-USD only permits 20 MHz bandwidth channels in the 2.4 GHz and 5 GHz bands
    (as per section 4.5.3 of the Wi-Fi Aware Specification v4.0). To avoid linking
    a large portion of upstream supplicant code for frequency-to-channel and
    channel-to-frequency conversion, implement minimal custom helper functions.

9.  Limit NAN_DE_MAX_SERVICE to 2 for ESP_SUPPLICANT

10. Note: Upstream clamps negative `os_reltime` deltas to zero in `nan_de_srv_time_to_next()`,
    but our ESP_SUPPLICANT port keeps `os_time_t` unsigned, so that guard just provokes a
    compiler warning. We skip it for now because the scheduling loop validates past timestamps
    before computing the diff.

Co-authored-by: Shyamal Khachane <shyamal.khachane@espressif.com>
2025-10-20 12:18:28 +05:30
Sarvesh Bodakhe
b1d1897547 fix(wifi): Make sure that USD APIs do not alter the SSI information
1.  Make sure that wpa_supplicant does not encapsulate user-given SSI info
    with WFA OUI.

2.  USD component shall transfer the SSI given by user as it is, without
    any modification or encapsulation.

3.  Note that this will break the compatibility of ESP USD implementation
    with a device running upstream wpa_supplicant as wpa_supplicant
    encapsulates the SSI information with WfA oui.
    For compatibility with wpa_supplicant, user needs to handle the
    SSI encapsulation/decapsulation.
2025-10-20 12:18:19 +05:30
Andrei Otcheretianski
0ad3af78a6 NAN: Remove excessive debug print about the next timer
As it polutes the log too much.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
2025-10-20 12:18:19 +05:30
Andrei Otcheretianski
a83d66cb88 NAN: Fix A3 for unicast P2P2 USD
According to the Wi-Fi Direct spec draft, address 3 in unicast USD
frames shall be set to the P2P Device Address of the sender (i.e., this
differs from the Wi-Fi Aware specification). Fix it.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
2025-10-20 12:18:19 +05:30
Andrei Otcheretianski
706b211dbf NAN: Fix A3 for multicast P2P2 USD
According to the Wi-Fi Direct spec draft, address 3 in multicast USD
frames shall be set to wildcard BSSID (i.e., this differs from the Wi-Fi
Aware specification). Fix it.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
2025-10-20 12:18:19 +05:30
Shivani Baranwal
105225be91 NAN USD: Use different group address for P2P2
P2P2 uses USD with a different group address than the NAN Network ID
defined in the Wi-Fi Aware specification. Select the group address based
on whether USD is used with P2P2 or something else. This changes
behavior only for the P2P2 cases.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
8489c48dda NAN: Do not expire USD services based on last TX/RX message
This behavior is not described in the Wi-Fi Aware specification, so
remove it and instead, expect services to terminate USD explicitly when
no further Follow-up messages are needed.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
63445ae0f7 NAN: Wait on the channel with publisher is in pauseState
Remain waiting for additional Follow-up messages on a publisher that is
in pauseState for a service that requires further service discovery.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
62e7fa86ab NAN: Limit pauseState to be within service lifetime
If a publish service is configured with an explicit lifetime (ttl), do
not allow pauseState duration to exceed that.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
7ba048a8c5 NAN: Print a debug entry on TX wait time expiration
This can be helpful for understanding NAN DE behavior.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
1c18f52de0 NAN: Make DE aware of maximum driver supported listen time
This can be used to optimize listen operations to be as long as the
driver supports instead of having to use a small enough value to work
with all drivers.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
fd7b14af83 NAN: Do not unpause publisher on fixed Follow-up message timeout
Do not unpause publisher if more than one second has passed from the
last Follow-up message TX or RX. There is no such behavior described in
the Wi-Fi Aware specification and it is possible for a service to need
more time to generate Follow-up messages. Leave it to the service itself
to force timeout, if desired, or terminate pauseState after the 60
second overall timeout.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
aa433f46c9 NAN: Handle A3 copying internally to simplify control interface
There is no need to copy the A3 value for follow-up frames through the
control interface events and commands since it can be handled internally
in the service with sufficient accuracy. More parallel operations with
multiple peers might need per-peer information, but that can be extended
in the future, if that level of complexity is really needed in practice.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
6fe979cad1 NAN: Update A3 for USD to use NAN Network ID or NAN Cluster ID in A3
Wi-Fi Aware spec v4.0 was not clear on all cases and used a bit unclear
definition of A3 use in Table 5 (Address field definiton for NAN SDF
frames in USD). That resulted in the initial implementation using
Wildcard BSSID to comply with the IEEE 802.11 rules on Public Action
frame addressing.

For USD to have chances of working with synchronized NNA devices, A3
needs to be set to the NAN Cluster ID when replying to a frame received
from a synchronized NAN device. While there is no cluster ID for USD,
this can be done by copying the A3 from the received frame. For the
cases where sending out an unsolicited multicast frame, the NAN Network
ID should be used instead of the Wildcard BSSID.

While this behavior is not strictly speaking compliant with the IEEE
802.11 standard, this is the expected behavior for NAN devices, so
update the USD implementation to match.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
cbb2ee7ba7 NAN: Process received NAN SDFs with NAN Network ID in A3 on AP
hostapd did not accept NAN SDFs that used NAN Network ID instead of
Wildcard BSSID in A3. Extend this to process NAN Network ID just like
Wildcard BSSID for these frames to allow the specific group address to
be used.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Shivani Baranwal
bbeb70d81b NAN USD: Add publishChannelList option for Subscriber
Add frequency list to active NAN USD Subscriber to search for a
Publisher on multiple channels. This is the publish channel list used by
the Subscriber to periodically search for a service on these channels.
publishChannelList was already supported in the Publisher and this
commit extends that to the Subscriber.

This is needed for a P2P2 seeker that is an active subscriber looking
for an advertiser on a list of publish channels.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
2025-10-20 12:18:19 +05:30
Shivani Baranwal
59dfc2ec32 P2P2: Allow P2P IE to be added into NAN SDFs
Extend the NAN Subscribe and Publish methods to allow p2p=1 to be
specified to include P2P attributes in a P2P IE to be added into the NAN
Element Container attribute. In addition, use the P2P Device Address for
the NAN SDFs for the P2P cases.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
2025-10-20 12:18:19 +05:30
Shivani Baranwal
8173b5cc87 NAN: Option to offload NAN DE for USD into the driver
Support implementation architecture where the NAN discovery engine is
located in the driver/firmware instead of wpa_supplicant.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
2025-10-20 12:18:19 +05:30
Chien Wong
35e508258d NAN: Reject undefined publish type
The Wi-Fi Aware Specification v4.0 only defines unsolicited
transmissions only, solicited transmissions only and both unsolicited
and solicited transmissions publish. The other possibility is undefined
so we should reject it.

Signed-off-by: Chien Wong <m@xv97.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
6a1c9a5f26 NAN: Unsynchronized service discovery (USD)
Add NAN discovery engine and wpa_supplicant interface to use it for the
subset of NAN functionality that is needed for USD.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:19 +05:30
Jouni Malinen
e1791e769c NAN: Protocol definitions
Add NAN protocol definitions that are needed for USD based on Wi-Fi
Aware specification v4.0.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-10-20 12:18:18 +05:30
Kapil Gupta
092338b78d fix(esp_wifi): Add validation before accessing RSNXE 2025-10-09 09:32:56 +05:30
Kapil Gupta
a75a3710c4 fix(esp_wifi): Add some fixes in roaming app 2025-09-30 14:18:29 +08:00
tarun.kumar
324337369d feat(wifi) : Add FT with SAE feature 2025-09-29 18:40:47 +05:30
Kapil Gupta
e8f75f97b0 Merge branch 'feat/roaming_app_blacklist' into 'master'
fix(esp_wifi): Add blacklist logic in roaming app

Closes WIFIBUG-1219, WIFIBUG-1208, WIFIBUG-1109, WIFIBUG-1203, and WIFIBUG-1428

See merge request espressif/esp-idf!40802
2025-09-28 21:44:31 +05:30
tarun.kumar
fdda62267e fix(wifi) : Resetting current bssid for every roaming connection intiated
- Bssid reset after btm or legacy roam
     - Making few changes in CMake for wpa_supplicant and esp_wifi
2025-09-28 11:53:01 +08:00
Kapil Gupta
0f3034586b fix(esp_wifi): Address some review comments and issues 2025-09-28 11:53:01 +08:00
Kapil Gupta
7d18b82575 feat(roaming): ignore WPA2-only APs on transition disable
This commit introduces a new feature to the roaming logic. If the
currently connected AP has the 'transition disable' bit set in its
RSN IE, the roaming logic will now ignore any scanned APs that only
support WPA2-PSK. This prevents a security downgrade when roaming in a
mixed WPA2/WPA3 environment.

A new Kconfig option, CONFIG_ESP_WIFI_IGNORE_WPA2_ONLY_ON_TRANSITION_DISABLE,
has been added to control this feature. It is disabled by default.
2025-09-28 11:53:01 +08:00
Shreyas Sheth
1753f5ee63 fix(esp_wifi): Resolve some comments for wpa3_compatible_mode support 2025-09-28 09:10:42 +05:30
Shreyas Sheth
3eca66cc0d fix(esp_wifi): Resolve comments for wpa3_compatible_mode 2025-09-28 09:10:30 +05:30
Shreyas Sheth
a7f32f5a2a feat(esp_wifi): Add compile flag for wpa3 compatible mode 2025-09-28 09:10:29 +05:30
Shreyas Sheth
1b33c9daae fix(esp_wifi): Resolve comments for wpa3 compatible mode 2025-09-28 09:10:29 +05:30
Shreyas Sheth
fbfa3aa0e0 feat(esp_wifi): Add support of wpa3 compatible more for ap and sta 2025-09-28 09:10:29 +05:30
Sai Pratyusha Magam
e8a19841f4 RSNO: Generate IGTK if any of the RSN variants has PMF enabled
With RSN overriding enabled, AP can be configured to set MFPC to 0 and
MFPR to 0 in the RSNE and MFPC to 1 and MFPR to 1 in the RSNOE and
RSNO2E. IGTK generation, configuration to the driver, and inclusion of
the IGTK KDE in 4-way handshake should also take into account the
management frame protection settings in the override variants.

Signed-off-by: Sai Pratyusha Magam <quic_smagam@quicinc.com>
2025-09-28 09:10:29 +05:30
Jouni Malinen
c3d6a1ce73 Avoid undefined behavior in RSNXE capability bit checker
Integer promotion converts u8 rsnxe[i] to an int which is not
sufficiently large to be able to handle the maximum shift left of 24
bits here. Type cast rsnxe[i] to u32 explicitly to get rid of the sign
bit and avoid this undefined behavior from the shift operation.

Credit to OSS-Fuzz: https://issues.oss-fuzz.com/issues/376786400
Fixes: d675d3b15b40 ("Add helper functions for parsing RSNXE capabilities")
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-09-28 09:10:29 +05:30
Jouni Malinen
22a15585fd RSNO: Omit RSNXE in (Re)Association Response frame like in Beacon frame
When rsn_override_omit_rsnxe=1 is used to omit the RSNXE from Beacon and
Probe Response frames, it should also be omitted from (Re)Association
Response frames since there is a general expectation on the RSNXE being
used consistently between these frames. This is unlikely to have much of
a difference for most use cases in practice, but this could impact FILS
association if the non-AP STA were to confirm that the unprotected and
protected version of the RSNXE from the AP were identical.

Fixes: 8b2ddfdbb688 ("RSNO: Allow RSNXE to be omitted")
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2025-09-28 09:10:29 +05:30