Skip to content

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.

  • RSN (element id 48, IEEE 802.11i): WPA2 and WPA3. Suites carry the 00-0F-AC OUI.
  • WPA (element id 221, vendor-specific with OUI 00-50-F2 type 1): the original WPA. Suites carry the 00-50-F2 OUI.

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.

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.

  • akm — Internal WPA_KEY_MGMT_* bitmask — what key_mgmt holds.
  • cipher — esp-idf public WIFI_CIPHER_TYPE_* — what the cipher fields hold.
  • proto — Internal WPA_PROTO_*.
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

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