quantcrypt/kdf/common/
kdf_type.rs

1use crate::kdf::common::config::oids::Oid;
2use strum::IntoEnumIterator;
3use strum_macros::EnumIter;
4
5/// Define the KDF types
6#[derive(Clone, Debug, PartialEq, EnumIter)]
7pub enum KdfType {
8    /// Hkdf with SHA-256
9    HkdfWithSha256,
10    /// Hkdf with SHA-512
11    HkdfWithSha384,
12    /// Hkdf with SHA-512
13    HkdfWithSha512,
14    /// Kmac with 128-bit key
15    Kmac128,
16    /// Kmac with 256-bit key
17    Kmac256,
18}
19
20impl KdfType {
21    /// Get all KDF types
22    pub fn all() -> Vec<KdfType> {
23        KdfType::iter().collect()
24    }
25
26    /// Get the OID of the KDF
27    pub fn from_oid(oid: &str) -> Option<KdfType> {
28        let all_kdf_types = KdfType::all();
29        all_kdf_types
30            .into_iter()
31            .find(|kdf_type| kdf_type.get_oid() == oid)
32    }
33}