Skip to content

Commit

Permalink
Added defaults for RSNElement.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostie314159 committed Aug 4, 2024
1 parent 2a64c2b commit 1e69fa9
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/crypto/michael.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub fn michael(key: u64, bytes: &[u8]) -> u64 {
// NOTE: This implementation is partially adapted from https://github.com/torvalds/linux/blob/master/net/mac80211/michael.c
let (mut l, mut r) = (((key >> 32) as u32).to_be(), (key as u32).to_be());


let blocks = bytes.len() / 4;
let left = bytes.len() % 4;

Expand Down
101 changes: 101 additions & 0 deletions src/elements/rsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,107 @@ pub struct RSNElement<
pub group_management_cipher_suite: Option<IEEE80211CipherSuiteSelector>,
pub _phantom: PhantomData<&'a ()>,
}
impl<'a, PairwiseCipherSuiteList, AKMList, PMKIDList>
RSNElement<'a, PairwiseCipherSuiteList, AKMList, PMKIDList>
{
/// An [RSNElement] equivalent to WPA-Personal.
pub const WPA_PERSONAL: RSNElement<
'static,
[IEEE80211CipherSuiteSelector; 1],
[IEEE80211AKMType; 1],
[IEEE80211PMKID; 0],
> = RSNElement {
group_data_cipher_suite: Some(IEEE80211CipherSuiteSelector::Tkip),
pairwise_cipher_suite_list: Some([IEEE80211CipherSuiteSelector::Tkip]),
akm_list: Some([IEEE80211AKMType::Psk]),
rsn_capbilities: None,
pmkid_list: None,
group_management_cipher_suite: None,
_phantom: PhantomData,
};
/// An [RSNElement] equivalent to WPA/WPA2-Personal.
pub const WPA_WPA2_PERSONAL: RSNElement<
'static,
[IEEE80211CipherSuiteSelector; 2],
[IEEE80211AKMType; 1],
[IEEE80211PMKID; 0],
> = RSNElement {
group_data_cipher_suite: Some(IEEE80211CipherSuiteSelector::Tkip),
pairwise_cipher_suite_list: Some([
IEEE80211CipherSuiteSelector::Tkip,
IEEE80211CipherSuiteSelector::Ccmp128,
]),
akm_list: Some([IEEE80211AKMType::Psk]),
rsn_capbilities: None,
pmkid_list: None,
group_management_cipher_suite: None,
_phantom: PhantomData,
};
/// An [RSNElement] equivalent to WPA2-Personal.
pub const WPA2_PERSONAL: RSNElement<
'static,
[IEEE80211CipherSuiteSelector; 1],
[IEEE80211AKMType; 1],
[IEEE80211PMKID; 0],
> = RSNElement {
group_data_cipher_suite: Some(IEEE80211CipherSuiteSelector::Ccmp128),
pairwise_cipher_suite_list: Some([IEEE80211CipherSuiteSelector::Ccmp128]),
akm_list: Some([IEEE80211AKMType::Psk]),
rsn_capbilities: None,
pmkid_list: None,
group_management_cipher_suite: None,
_phantom: PhantomData,
};
/// An [RSNElement] equivalent to WPA2/WPA3-Personal.
pub const WPA2_WPA3_PERSONAL: RSNElement<
'static,
[IEEE80211CipherSuiteSelector; 1],
[IEEE80211AKMType; 2],
[IEEE80211PMKID; 0],
> = RSNElement {
group_data_cipher_suite: Some(IEEE80211CipherSuiteSelector::Ccmp128),
pairwise_cipher_suite_list: Some([IEEE80211CipherSuiteSelector::Ccmp128]),
akm_list: Some([IEEE80211AKMType::Psk, IEEE80211AKMType::Sae]),
rsn_capbilities: None,
pmkid_list: None,
group_management_cipher_suite: None,
_phantom: PhantomData,
};
/// An [RSNElement] equivalent to WPA3-Personal.
pub const WPA3_PERSONAL: RSNElement<
'static,
[IEEE80211CipherSuiteSelector; 1],
[IEEE80211AKMType; 1],
[IEEE80211PMKID; 0],
> = RSNElement {
group_data_cipher_suite: Some(IEEE80211CipherSuiteSelector::Tkip),
pairwise_cipher_suite_list: Some([IEEE80211CipherSuiteSelector::Tkip]),
akm_list: Some([IEEE80211AKMType::Sae]),
rsn_capbilities: None,
pmkid_list: None,
group_management_cipher_suite: None,
_phantom: PhantomData,
};
/// An [RSNElement] equivalent to OWE.
pub const OWE: RSNElement<
'static,
[IEEE80211CipherSuiteSelector; 1],
[IEEE80211AKMType; 1],
[IEEE80211PMKID; 0],
> = RSNElement {
group_data_cipher_suite: Some(IEEE80211CipherSuiteSelector::Ccmp128),
pairwise_cipher_suite_list: Some([IEEE80211CipherSuiteSelector::Ccmp128]),
akm_list: Some([IEEE80211AKMType::OpportunisticWirelessEncryption]),
rsn_capbilities: Some(
RSNCapabilities::new()
.with_mfp_enabled(true)
.with_mfp_required(true),
),
pmkid_list: None,
group_management_cipher_suite: Some(IEEE80211CipherSuiteSelector::Ccmp128),
_phantom: PhantomData,
};
}
impl<
'a,
LPairwiseCipherSuiteList: IEEE80211List<IEEE80211CipherSuiteSelector, u16> + Clone,
Expand Down

0 comments on commit 1e69fa9

Please sign in to comment.