Add esp_netif_add_static_neighbor() and esp_netif_remove_static_neighbor(),
gated by CONFIG_LWIP_ND6_SUPPORT_STATIC_ENTRIES. These API's let callers
install/remove permanent IPv6->MAC mappings that bypass Neighbor Discovery
(no NS/NA). The calls run in the TCP/IP context and wrap the underlying lwIP
nd6_add_static_neighbor()/nd6_remove_static_neighbor() functions.
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.
- 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.