wpa::rsn
Parsing a network’s security from its RSN / WPA information element.
The blob hands the supplicant a beacon’s RSN element (or the legacy WPA vendor element) and asks what security it describes — which cipher, which key management. Without an answer every network reads as open and no secured AP can be joined. This is that answer: a bounds-checked, allocation-free parser that turns the element’s bytes into the fields the driver expects.
The two elements
Section titled “The two elements”- RSN (element id 48, IEEE 802.11i): WPA2 and WPA3. Suites carry the
00-0F-ACOUI. - WPA (element id 221, vendor-specific with OUI
00-50-F2type 1): the original WPA. Suites carry the00-50-F2OUI.
The value encoding is the reference’s, not the standard’s
Section titled “The value encoding is the reference’s, not the standard’s”The cipher fields come out as esp-idf’s public WIFI_CIPHER_TYPE_*
numbers, and key_mgmt and proto as its internal bitmasks — exactly
what wpa_parse_wpa_ie_wrapper produces, because the blob reads the result
and was built against that wrapper. The mappings below are transcribed from
wpa.c’s cipher_type_map_supp_to_public and defs.h.
Validate, then emit
Section titled “Validate, then emit”Every length is checked before it is read, and the [SecurityInfo] is built
only once the whole element has validated — a truncated or malformed element
returns None and never leaves half-trusted security state behind.
Modules
Section titled “Modules”akm— InternalWPA_KEY_MGMT_*bitmask — whatkey_mgmtholds.cipher— esp-idf publicWIFI_CIPHER_TYPE_*— what the cipher fields hold.proto— InternalWPA_PROTO_*.
Structs
Section titled “Structs”SecurityInfo
Section titled “SecurityInfo”struct SecurityInfo { pub proto: u32, pub pairwise_cipher: u32, pub group_cipher: u32, pub key_mgmt: u32, pub capabilities: u32, pub num_pmkid: usize, pub pmkid_offset: Option<usize>, pub mgmt_group_cipher: u32,}The security an RSN/WPA element describes, in the driver’s value encoding.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
Functions
Section titled “Functions”fn parse(ie: &[u8]) -> Option<SecurityInfo>Parse an RSN (id 48) or WPA (id 221) information element into a
[SecurityInfo]. ie starts at the element id. None if it is neither, or
is malformed or truncated.
References: SecurityInfo