quantcrypt/wrap/common/wrap_type.rs
1use crate::wrap::common::config::oids::Oid;
2use strum::IntoEnumIterator;
3use strum_macros::EnumIter;
4
5/// The type of a key wrap
6#[derive(Clone, Debug, PartialEq, EnumIter)]
7pub enum WrapType {
8 /// AES 128
9 Aes128,
10 /// AES 192
11 Aes256,
12}
13
14impl WrapType {
15 /// Get all key wrap types
16 ///
17 /// # Returns
18 ///
19 /// A vector of all key wrap types
20 pub fn all() -> Vec<WrapType> {
21 WrapType::iter().collect()
22 }
23
24 /// Get the wrap type from an OID
25 ///
26 /// # Arguments
27 ///
28 /// * `oid` - The OID to get the wrap type for
29 ///
30 /// # Returns
31 ///
32 /// The wrap type for the OID, or None if the OID is not found
33 pub fn from_oid(oid: &str) -> Option<WrapType> {
34 let all_wrap_types = WrapType::all();
35 all_wrap_types
36 .into_iter()
37 .find(|wrap_type| wrap_type.get_oid() == oid)
38 }
39}