diff --git a/rust/pv/src/crypto.rs b/rust/pv/src/crypto.rs index 6d9e14c5..10cce1e2 100644 --- a/rust/pv/src/crypto.rs +++ b/rust/pv/src/crypto.rs @@ -41,6 +41,15 @@ pub enum SymKeyType { Aes256Xts, } +impl From for Nid { + fn from(value: SymKeyType) -> Self { + match value { + SymKeyType::Aes256 => Self::AES_256_GCM, + SymKeyType::Aes256Xts => Self::AES_256_XTS, + } + } +} + /// Types of symmetric keys #[non_exhaustive] #[derive(Debug, Clone, PartialEq, Eq)] @@ -491,4 +500,16 @@ mod tests { assert_eq!(hmac, exp); } + + #[test] + fn from_symkeytype() { + assert_eq!( + >::into(SymKeyType::Aes256), + Nid::AES_256_GCM + ); + assert_eq!( + >::into(SymKeyType::Aes256Xts), + Nid::AES_256_XTS + ); + } }