diff --git a/src/ikm.rs b/src/ikm.rs index 8584257..fb8f544 100644 --- a/src/ikm.rs +++ b/src/ikm.rs @@ -158,6 +158,15 @@ impl InputKeyMaterialList { } } +#[cfg(feature = "ikm-management")] +impl std::ops::Deref for InputKeyMaterialList { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.ikm_lst + } +} + #[cfg(test)] mod tests { use super::*; @@ -331,6 +340,20 @@ mod tests { assert!(res.is_err()); } + #[test] + #[cfg(feature = "ikm-management")] + fn iterate() { + let mut lst = InputKeyMaterialList::new(); + for _ in 0..10 { + let _ = lst.add_ikm(); + } + let mut id = 1; + for ikm in lst.iter() { + assert_eq!(id, ikm.id); + id += 1; + } + } + #[test] #[cfg(feature = "encryption")] fn get_latest_ikm() { diff --git a/src/lib.rs b/src/lib.rs index 5fd09af..bd5d380 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,7 @@ mod storage; pub use encryption::{decrypt, encrypt}; pub use error::Error; #[cfg(any(feature = "encryption", feature = "ikm-management"))] -pub use ikm::{InputKeyMaterialList, InputKeyMaterial, IkmId}; +pub use ikm::{IkmId, InputKeyMaterial, InputKeyMaterialList}; #[cfg(any(feature = "encryption", feature = "ikm-management"))] pub use scheme::Scheme;