Skip to content

Commit

Permalink
pass down serialization feature to evercrypt
Browse files Browse the repository at this point in the history
This isn't actually needed in here. But this might make problems
with consumers of the library down the chain that want to use
evercrypt with this feature.
  • Loading branch information
franziskuskiefer committed Nov 9, 2020
1 parent 28db5da commit 1dc9cf0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
24 changes: 24 additions & 0 deletions tests/test_features.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 1dc9cf0

Please sign in to comment.