diff --git a/Cargo.toml b/Cargo.toml index 156aec5..2b72172 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ evercrypt-sys = { git = "https://github.com/franziskuskiefer/evercrypt-rust", pa [features] rust-crypto = ["evercrypt/rust-crypto-aes"] -serialization = ["serde", "serde_json"] +serialization = ["serde", "serde_json", "evercrypt/serialization"] hazmat = [] [dev-dependencies] diff --git a/tests/test_features.rs b/tests/test_features.rs new file mode 100644 index 0000000..4d216e1 --- /dev/null +++ b/tests/test_features.rs @@ -0,0 +1,24 @@ +#[cfg(feature = "serialization")] +use evercrypt::prelude::*; + +#[cfg(feature = "serialization")] +use hpke::prelude::*; + +#[test] +#[cfg(feature = "serialization")] +fn test_serialization() { + let hpke = Hpke::new( + HpkeMode::Base, + HpkeKemMode::DhKem25519, + HpkeKdfMode::HkdfSha256, + HpkeAeadMode::AesGcm256, + ); + let hpke_serialized = serde_json::to_string(&hpke).unwrap(); + let hpke_out: Hpke = serde_json::from_str(&hpke_serialized).unwrap(); + assert_eq!(format!("{}", hpke), format!("{}", hpke_out)); + + let aead_mode = AeadMode::Aes256Gcm; + let serialized_mode = serde_json::to_string(&aead_mode).unwrap(); + let aead_mode_out: AeadMode = serde_json::from_str(&serialized_mode).unwrap(); + assert_eq!(aead_mode, aead_mode_out); +}