Commit Graph

1618 Commits

Author SHA1 Message Date
Akshat Agrawal
b08e848f46 fix(nan): Transmit NULL packet correctly to avoid NDP termination 2026-07-13 14:51:43 +05:30
Chen Yu Dong
89590855a0 Merge branch 'refactor/esp_wifi_regulatory_esp_pylib' into 'master'
refactor(esp_wifi): migrate regulatory tools to esp-pylib

See merge request espressif/esp-idf!49976
2026-07-12 00:49:48 +08:00
Shreyas Sheth
53e36b0ce4 fix(wpa_supplicant): Fix issues related to pmkid mismatch and eloop for dpp 2026-07-09 17:38:49 +05:30
tarun.kumar
f614b0343c fix(wifi) : Correct blacklist flag
- Fixes state desync where global blacklist was cleared but blacklist bss flag was true causing rejection of correct AP as well.
2026-07-08 15:22:50 +05:30
zhangyanjiao
cf695709f1 fix(wifi): fixed the offchan tx fail when SPIRAM_TRY_ALLOCATE_WIFI_LWIP enabled 2026-07-07 15:31:00 +08:00
Sarvesh Bodakhe
61b705f030 refactor(wifi): astyle-format wifi_netif.c
The ternary continuation in esp_wifi_netif_set_static_neighbor() was not
astyle-formatted; re-indent it so the pre-commit astyle hook passes in CI.
2026-07-01 20:30:47 +05:30
Sarvesh Bodakhe
4639b57485 refactor(nan): drop '##' debug marker from key hexdump tags
The six key-material hexdumps (ND-IGTK/BIGTK/TK/GTK and the peer IGTK/BIGTK)
kept a leftover '##' dev-grep marker on their tag string. Drop it; the
descriptive labels stay and the dumps remain at ESP_LOG_DEBUG.
2026-07-01 20:26:10 +05:30
Sarvesh Bodakhe
21a5c603e8 change(wifi): sync NAN/netif wifi headers + rebuilt libs [d3da506]
- injected esp_wifi_netif.h: add esp_wifi_netif_get_ip6_linklocal_from_mac()
  and esp_wifi_netif_set_static_neighbor() (static ND6 IPv6-pin API).
- esp_wifi_types_generic.h (public + injected): rename the NCS-GTK cipher
  suites CCM_128 -> CCMP_128 / GCM_256 -> GCMP_256 to match Wi-Fi Aware v4.0
  (Table 121, section 9.5.21.1); refresh NAN group-protection docs. Enum
  values (5/6), struct layout and on-air behaviour are unchanged.
- nan_security.c: use the renamed macros and update the advertise log.
- esp_wifi/lib: bump to the rebuilt blobs carrying the renamed MD5-checked
  header (han2 d3da506).
2026-07-01 20:18:37 +05:30
Sarvesh Bodakhe
2cc14d131f fix(nan): restrict GTK Key ID to 1/2 and ignore cleartext group KDEs
- Tighten the own GTK Key ID guard from ">3" (which admitted 0 and 3) to
  the spec range 1..2 (Wi-Fi Aware v4.0 §7.1.3.2).
- When the Encrypted-Key-Data bit is clear, ignore the Key Data instead of
  parsing KDEs from the clear: group KDEs are only ever carried KEK-wrapped
  (§7.1.3.5; 802.11-2020 §12.7.2). Also store the peer IPN/BIPN from the
  IGTK/BIGTK KDEs for the BIP RX replay-counter seed.
2026-07-01 18:12:25 +05:30
Sarvesh Bodakhe
235207bb2a fix(nan): seed peer BIP RX replay counter from the KDE IPN/BIPN
The peer IGTK/BIGTK were installed with an all-zero seq, so the blob's BIP
RX replay counter started at 0 instead of the peer's advertised value. Store
the 6-octet IPN/BIPN from the IGTK/BIGTK KDE (the octets after the 2-byte
Key ID, per 802.11 Fig 12-42/12-47) into the NDL and pass them as the
install seq. The parser side of this lands with the group-KDE guards.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
1c59572c07 change(wifi): update libs [2e77d2e]
Rebuilt libs with NAN group-key (GTK/IGTK/BIGTK) support, matching the
nan_key_type_t and group-protection header updates so the MD5-checked
esp_wifi_driver.h and esp_wifi_types_generic.h verify.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
e952a580db docs(nan): document group-protection fields, CSID ciphers and NIRA
Refresh stale/missing documentation now that the features are implemented:
- group_data_prot / group_mgmt_prot in wifi_nan_discovery_security_params_t
  (esp_wifi_types_generic.h) and wifi_nan_security_params_t (esp_private/
  wifi.h): describe GTKSA / IGTKSA+BIGTKSA instead of "not supported".
- CSID enum: document NCS-GTK-CCM-128 (set internally via group_data_prot,
  not user-selectable) and NCS-PK-PASN-128 (NAN Pairing, via the Wi-Fi
  Aware component).
- Drop "dummy" from the esp_nan_construct_nira() doc (it builds a real
  NIRA) and a stale "IGTK/BIGTK are placeholders" comment.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
ebb9539d17 refactor(nan): use shared nan_key_type_t from esp_wifi_driver.h
The NAN key-type selectors are defined by the blob in esp_wifi_driver.h
(nan_key_type_t), which nan_i.h already includes. Add the group-integrity
key types NAN_KEY_ND_IGTK (3) and NAN_KEY_ND_BIGTK (4) there to match the
blob, and drop the duplicate host definitions from nan_i.h so a single
shared enum is used. Resolves the review request to declare these in
nan_key_type_t and avoids redefining the typedef.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
8b2b386825 refactor(nan): declare NAN key types as nan_key_type_t enum
Move the NAN_KEY_ND_TK/ND_GTK/NM_TK/ND_IGTK/ND_BIGTK selectors from #defines
into a nan_key_type_t enum, and finalize their doc wording (drop the
"provisional" note now that the IGTK/BIGTK values are verified against the
blob ABI). They are still passed to esp_wifi_set_nan_key_internal() as the
int key_flag argument, so no call-site or ABI change. Also tidy the
surrounding doc comments.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
5275d5ef08 refactor(nan): put RSN KDE OUI in one array, drop dead OUI byte macros
Replace the three NAN_KDE_OUI_RSN_* byte writes in nan_kde_put_hdr() with a
single nan_kde_rsn_oui[] array, and remove the now-unused NAN_KDE_OUI_RSN_*
byte macros and the never-used NAN_KDE_OUI_WFA_* byte macros. The combined
NAN_KDE_OUI_RSN / NAN_KDE_OUI_WFA (used by the KDE parser) are kept.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
dc3ada69b5 refactor(nan): drop commented-out debug logging
Remove the dead commented-out ESP_LOGI debug prints flagged in review: the
"Sent Publish to Peer" line in nan_app.c, and the SCIA-construct,
CSIA-construct and CSIA-len-getter blocks in nan_security.c.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
553d969c4f fix(nan): pass no event payload to NAN netif bring-up action
The NAN-started handler brought the netif up via esp_netif_action_connected()
using the NAN-started event's base/event_id/data. Feeding a "connected"
action from a "started" event and handing it an unrelated event payload is
fragile: it would misbehave if the action handler ever interpreted data
(which is not a wifi_event_sta_connected_t here).

esp_netif_up() is private to the esp_netif component, so keep the public
esp_netif_action_connected() but pass NULL base, 0 event_id, NULL data. This
is safe because the NAN netif is not a DHCP client: the handler only calls
esp_netif_up() and never reads the event args.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
0baa39835e fix(nan): restore SCIA length getter debug log
The MR had turned the active ESP_LOGD("GET SCIA LEN") into a commented-out
ESP_LOGI. Restore the original ESP_LOGD so the log stays live at DEBUG and
no dead commented code is left behind.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
d0e2943621 fix(nan): source group_mgmt_prot from start config, not blob read-back
esp_nan_action_start() read group_mgmt_prot back from the blob via
esp_wifi_get_config() and defaulted to true when the read failed, which
force-enabled device-global IGTK/BIGTK (BIP beacons, forced GTKSA) on a
path where the user's intent is unknown. group_mgmt_prot is a pure
pass-through user flag, so capture it directly into s_nan_ctx from the
config in esp_wifi_nan_sync_start() (next to use_nvs_for_caching) and drop
the read-back and its ambiguous default. Behaviour now follows the user's
config exactly (default false via WIFI_NAN_SYNC_CONFIG_DEFAULT).
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
a870826c5a fix(nan): set group_mgmt_prot in WIFI_NAN_SYNC_CONFIG_DEFAULT
The default initializer explicitly sets every other bool field but omitted
the new group_mgmt_prot, leaving the intended default ambiguous. Set it to
false so the macro stays exhaustive; both example apps use it.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
e74b5f7bda fix(nan): clear group keys on NAN stop and peer NDP teardown
Fix group-key lifecycle gaps on the secured NDP path:

- On NAN stop, reset the device-global IGTK/BIGTK state via new
  nan_security_reset_own_group_keys() so the next start regenerates fresh
  keys. Previously the one-shot nan_ensure_own_igtk/bigtk kept own_*_set,
  so restart re-installed the stale key with IPN/BIPN=0, resetting the
  blob's monotonic replay counter (and reusing keys if the NMI changed).

- On peer teardown (nan_app_clear_one_peer_tks), remove the peer RX
  IGTK/BIGTK from the blob (they were installed against the peer NMI at
  NDP confirm) and scrub ndl->igtk/bigtk + flags. Previously only the GTK
  was removed, leaving stale BIP keys installed and key bytes in memory.

- Copy the GTK Key RSC into the descriptor only when a GTK KDE is present,
  matching the comment and avoiding stale RSC on an IGTK/BIGTK-only path.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
c2c825299a fix(nan): scrub group keys from stack, demote key hexdumps to DEBUG
Harden group-key material handling on the secured NDP path:

- Zero the stack buffers that hold plaintext/decrypted group keys before
  they leave scope: pad in nan_kek_wrap_key_data, plain in
  nan_append_own_group_kdes (single-exit cleanup), and the decrypted plain
  in esp_nan_parse_ndp_key_desc. Mirrors the existing forced_memzero(pmk)
  scrubs so GTK/IGTK/BIGTK bytes do not persist on the stack.

- Demote the ND-TK / GTK / IGTK / BIGTK ESP_LOG_BUFFER_HEXDUMP calls (own
  keys in nan_security.c, pairwise and peer keys in nan_app.c) from
  ESP_LOG_INFO to ESP_LOG_DEBUG so raw key bytes are not printed at the
  default log level.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
65d822f202 fix(nan): detect ND-TK install failure at NDP confirm
The ND-TK (pairwise data key) install return value was overwritten by the
subsequent NM-TK install before being checked, so an ND-TK failure went
undetected: the NDP was marked accepted and NDP_CONFIRM posted while
unicast data frames had no encryption key installed. Check ND-TK first
and tear down on failure, then install and check NM-TK separately.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
22a9321fea fix(nan): free NDL slot and deny peer when get_mac fails on NDP resp
The NDP indication handler recorded an NDL slot, then on esp_wifi_get_mac
failure unlocked and returned without releasing the slot or answering the
peer: the slot leaked (counting against the NDL limit) and the peer waited
indefinitely. On failure now reset the NDL and send a deny response,
mirroring the existing allocation-failure cleanup path.

Also drop the redundant pre-branch get_mac/IPv6-derive: its result was
only used on the auto-response path, which recomputes it, so on the
indication path it was dead work and a second leak site.
2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
0577b5b1aa fix(wifi): sync wifi-remote injected header for NAN group_mgmt_prot 2026-07-01 18:12:24 +05:30
Sarvesh Bodakhe
08e98f6f30 feat(nan): pin datapath IPv6 neighbor via esp_netif static entry
- Add esp_wifi_netif_set_static_neighbor() that to add/remove IPv6
  static entry using netif API to skip Neighbor Discovery Protocol
- Move the fe80::/64 + EUI-64 derivation to esp_wifi_netif.c
2026-07-01 18:11:52 +05:30
Sarvesh Bodakhe
932a9e33d8 feat(wifi): add NAN group data and management frame protection
Add Wi-Fi Aware group-key support to secured NDPs so group-addressed
traffic can be protected, for interop with iOS/macOS peers:

- GTK (NCS-GTK-CCM-128) protects group-addressed data.
- IGTK/BIGTK (BIP) protect group management traffic - multicast SDFs,
  Beacons.

Capabilities are advertised in the CSIA IE: group_data_prot maps to GTKSA,
group_mgmt_prot to IGTKSA/BIGTKSA. The CSIA cannot encode IGTK/BIGTK
without GTK (WiFi Aware spec 9.5.21.2, Table 122), so enabling group_mgmt_prot
forces group_data_prot on for every secured service.

Expose per-service group_data_prot and device-global group_mgmt_prot.
2026-07-01 13:35:15 +05:30
Chen Yudong
b8a23f8a0e refactor(esp_wifi): migrate regulatory tools to esp-pylib
Replace ad-hoc print/raise patterns in reg_parse.py and reg2fw.py with
esp_pylib.logger log.warn/log.die and install_exception_reporting().

Signed-off-by: Chen Yudong <chenyudong@espressif.com>
2026-07-01 09:28:11 +08:00
akshat
f4708595e6 bugfix(wifi): Clear Sta TX queue to prevent key 2 send failure
Also, Ensure correct return values for key 2 and key 4.
2026-06-30 14:56:15 +05:30
Nachiket Kukade
17ff376098 bugfix(nan): Fix hard/soft reset cases in NAN Pairing verification
- Update pairing complete API to record for peer
- Terminate NAN Datapaths using publish_id after receiving PASN M1
2026-06-30 12:58:44 +05:30
Sajia
c18887b05c feat(nan): Add support for NAN Pairing Verification
- Add nira attr and verification for pasn auth frames
- Refine key clearing and pairing complete logic for pasn verify
- Add NIRA own-service resolution, cached NIK checks, and dynamic
  pairing IE construction for bootstrap vs verify paths.
- Replace NAN bootstrap events by private callbacks
2026-06-30 12:58:41 +05:30
yinqingzhao
9bb9bbc781 fix(wifi): fix tx issues introduced by keeping alive optimization 2026-06-29 16:18:38 +08:00
Jiang Jiang Jian
d9b3b6984a Merge branch 'bugfix/fix_smartconfig_stop_assert_issue' into 'master'
fix(wifi): added start check when calling smartconfig stop

Closes WIFI-7432

See merge request espressif/esp-idf!49993
2026-06-26 14:04:33 +08:00
Akshat Agrawal
7b477596a7 fix(nan): Move the required variables under the NAN_SYNC block 2026-06-25 09:15:21 +05:30
zhangyanjiao
3d1bff8b42 fix(wifi): added start check when calling smartconfig stop 2026-06-25 09:53:29 +08:00
Jiang Jiang Jian
87a6c90160 Merge branch 'bugfix/pub_ndp_setup_timeout' into 'master'
fix(nan): Cluster merging and NIK NVS persistence, including pairing and NDP fixes

Closes WIFIBUG-1932, WIFIBUG-1931, WIFIBUG-1927, WIFIBUG-1942, WIFIBUG-1948, WIFIBUG-1955, WIFIBUG-1986, and WIFIBUG-1975

See merge request espressif/esp-idf!49185
2026-06-24 20:57:22 +08:00
Jiang Jiang Jian
16da34ad67 Merge branch 'feat/ftm_esp32s31_calib_values' into 'master'
feat(ftm): Update ftm calibration values esp32s31

See merge request espressif/esp-idf!49221
2026-06-24 16:28:29 +08:00
Akshat Agrawal
7a9acae345 Remove hardcoded GSP subattributes 2026-06-24 10:34:04 +05:30
Akshat Agrawal
b7b54b3650 Fix unwanted encryption of NAFs 2026-06-23 22:12:44 +05:30
Nachiket Kukade
d36416980c feat(nan): Add aes_wrap/unwrap crypto callbacks
- Use crypto callbacks instead of calling internal API's
- Clean up of unused code, flags. Re-arrange functions
2026-06-23 22:08:06 +05:30
Akshat Agrawal
c4b1e06057 Address review comments VNC 2026-06-23 22:08:06 +05:30
Akshat Agrawal
2c134933ec Address review comments and fix build errors 2026-06-23 22:08:06 +05:30
Akshat Agrawal
601faef85b fix(nan): Add service hash to NVS to maintain pairing states after reset 2026-06-23 22:08:06 +05:30
Akshat Agrawal
afd5a13e71 Change the NIRA verification logic 2026-06-23 22:08:06 +05:30
Akshat Agrawal
e64f0d7b1d fix(nan): Disable/Enable Pairing setup bit based on NIK stored in NVS
- Only send pairing followup only if nik caching is enabled
2026-06-23 22:08:06 +05:30
Nachiket Kukade
7d6d7ead9a feat(nan): persist NIK/NPK credentials in NVS
Replace nik/nik_valid in wifi_nan_sync_config_t with reset_current_nvs_creds
and use_nvs_for_caching. On NAN start, load the saved own NIK and peer
credentials from NVS (or erase them when reset is requested); generate and
persist a fresh own NIK only when none is valid and caching is enabled.

PASN reuses the SAE module (PWE/crypto and the comeback-token mechanism),
so define CONFIG_SAE whenever SoftAP-SAE or PASN is enabled. This fixes the
undefined references to check_comeback_token()/auth_build_token_req() when
SOFTAP config is disabled.
2026-06-23 22:08:06 +05:30
Nachiket Kukade
11ac60fcbb refactor(nan): consolidate NIRA construction into esp_nan_construct_nira 2026-06-23 22:08:06 +05:30
Akshat Agrawal
713fee2929 Add pairing followup timeout and post CONFIRM Failure 2026-06-23 22:08:06 +05:30
Nachiket Kukade
b45178e798 fix(nan): Move Pairing API's to private header 2026-06-23 22:08:06 +05:30
Nachiket Kukade
0d9225db5a fix(nan): address esp_ai_reviewer review comments 2026-06-23 22:08:06 +05:30