wlan_common/ie/rsn/
fake_rsnes.rs

1// Copyright 2020 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::ie::rsn::akm::AKM_PSK;
6use crate::ie::rsn::cipher::{CIPHER_CCMP_128, CIPHER_TKIP};
7use crate::ie::rsn::rsne::Rsne;
8use fidl_fuchsia_wlan_common as fidl_common;
9
10pub fn fake_wpa2_a_rsne() -> Rsne {
11    Rsne {
12        group_data_cipher_suite: Some(CIPHER_CCMP_128),
13        pairwise_cipher_suites: vec![CIPHER_CCMP_128, CIPHER_TKIP],
14        akm_suites: vec![AKM_PSK],
15        ..Default::default()
16    }
17}
18
19static EMPTY_SECURITY_SUPPORT: fidl_common::SecuritySupport = fidl_common::SecuritySupport {
20    mfp: fidl_common::MfpFeature { supported: false },
21    sae: fidl_common::SaeFeature { driver_handler_supported: false, sme_handler_supported: true },
22};
23
24pub fn fake_wpa2_s_rsne() -> Rsne {
25    fake_wpa2_a_rsne()
26        .derive_wpa2_s_rsne(&EMPTY_SECURITY_SUPPORT)
27        .expect("Unable to derive supplicant RSNE")
28}
29
30pub fn fake_wpa3_a_rsne() -> Rsne {
31    Rsne::wpa3_rsne()
32}
33
34pub fn fake_wpa3_s_rsne() -> Rsne {
35    let mut security_support = EMPTY_SECURITY_SUPPORT;
36    security_support.mfp.supported = true;
37    fake_wpa3_a_rsne()
38        .derive_wpa3_s_rsne(&security_support)
39        .expect("Unable to derive supplicant RSNE")
40}