/// Creates a new SAE handshake for the given group ID and authentication parameters.
Creates a new SAE handshake for the given group ID and authentication parameters.
Creates a new SAE handshake for the given group ID and authentication parameters .
pub fn new_sae_handshake(
    group_id: u16,
    akm: Akm,
    pwe_method: PweMethod,
    ssid: Ssid,
    password: Vec<u8>,
    password_id: Option<Vec<u8>>,
    mac: MacAddr,
    peer_mac: MacAddr,
) -> Result<Box<dyn SaeHandshake>, Error> {
    match akm.suite_type {
        akm::SAE | akm::FT_SAE => (),
        _ => bail!("Cannot construct SAE handshake with AKM {:?}", akm),
    };
    let (hmac, group_constructor) = match EcGroupId::from_u16(group_id) {
        Some(EcGroupId::P256) => {
            // IEEE 802.11-2020 12.4.2
            // Group 19 has a 256-bit prime length, thus we use SHA256.
            let hmac = Box::new(HmacUtilsImpl::<Sha256>::new());
            let group_constructor = Box::new(|| {
                ecc::Group::new(EcGroupId::P256).map(|group| {
                    Box::new(group)
                        as Box<
                            dyn internal::FiniteCyclicGroup<
                                Element = <ecc::Group as internal::FiniteCyclicGroup>::Element,
                            >,
                        >
                })
            });
            (hmac, group_constructor)
        }
        _ => bail!("Unsupported SAE group id: {}", group_id),
    };
    Ok(Box::new(state::SaeHandshakeImpl::new(
        group_constructor,
        internal::SaeParameters {
            hmac,
            pwe_method,
            ssid,
            password,
            password_id,
            sta_a_mac: mac,
            sta_b_mac: peer_mac,
        },
    )?))
}
pub fn new_sae_handshake ( group_id : u16 , akm : Akm , pwe_method : PweMethod , ssid : Ssid , password : Vec < u8 > , password_id : Option < Vec < u8 > > , mac : MacAddr , peer_mac : MacAddr , ) -> Result < Box < dyn SaeHandshake > , Error > { match akm . suite_type { akm :: SAE | akm :: FT_SAE => ( ) , _ => bail ! ( " " akm ) , } ; let ( hmac , group_constructor ) = match EcGroupId :: from_u16 ( group_id ) { Some ( EcGroupId :: P256 ) => { // IEEE 802.11-2020 12.4.2 // Group 19 has a 256-bit prime length, thus we use SHA256. let hmac = Box :: new ( HmacUtilsImpl :: < Sha256 > :: new ( ) ) ; let group_constructor = Box :: new ( | | { ecc :: Group :: new ( EcGroupId :: P256 ) . map ( | group | { Box :: new ( group ) as Box < dyn internal :: FiniteCyclicGroup < Element = < ecc :: Group as internal :: FiniteCyclicGroup > :: Element , > , > } ) } ) ; ( hmac , group_constructor ) } _ => bail ! ( " " group_id ) , } ; Ok ( Box :: new ( state :: SaeHandshakeImpl :: new ( group_constructor , internal :: SaeParameters { hmac , pwe_method , ssid , password , password_id , sta_a_mac : mac , sta_b_mac : peer_mac , } , ) ? ) ) }
Creates a new SAE handshake for the given group ID and authentication parameters.
Creates a new SAE handshake for the given group ID and authentication parameters .
group_id
u16
akm
Akm
pwe_method
PweMethod
ssid
Ssid
password
Vec<u8>
password_id
Option<Vec<u8>>
mac
MacAddr
peer_mac
MacAddr