mod aes;
mod rc4;
use crate::Error;
use aes::NistAes;
use rc4::Rc4;
use wlan_common::ie::rsn::akm;
pub trait Algorithm {
#[allow(clippy::result_large_err, reason = "mass allow for https://fxbug.dev/381896734")]
fn wrap_key(&self, kek: &[u8], iv: &[u8; 16], data: &[u8]) -> Result<Vec<u8>, Error>;
#[allow(clippy::result_large_err, reason = "mass allow for https://fxbug.dev/381896734")]
fn unwrap_key(&self, kek: &[u8], iv: &[u8; 16], data: &[u8]) -> Result<Vec<u8>, Error>;
}
pub fn keywrap_algorithm(
key_descriptor_version: u16,
akm: &akm::Akm,
) -> Option<Box<dyn Algorithm>> {
match key_descriptor_version {
1 => Some(Box::new(Rc4)),
2 => Some(Box::new(NistAes)),
0 if akm.suite_type == akm::SAE => Some(Box::new(NistAes)),
_ => None,
}
}