diff --git a/Cargo.toml b/Cargo.toml index e03a33f..df83bb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chacha20stream" -version = "1.0.2" +version = "1.0.3" keywords = ["chacha20_poly1305", "stream", "wrapper", "encryption", "decryption"] description = "A writable wrapper stream for encryption and decryption with the stream cipher chacha20_poly1305" homepage = "https://git.flanchan.moe/flanchan/chacha20stream" @@ -24,6 +24,7 @@ base64 = "0.13" getrandom = "0.2" openssl = "0.10" pin-project = {version = "1.0.6", optional = true} +serde = {version = "1.0", features = ["derive"], optional = true} smallvec = {version = "1.6", features=["union"], optional = true} tokio = {version = "0.2", optional = true} @@ -32,4 +33,4 @@ rustc_version = "0.2" [dev-dependencies] tempfile = "3.2.0" -tokio = {version = "0.2", features=["full"]} \ No newline at end of file +tokio = {version = "0.2", features=["full"]} diff --git a/src/key.rs b/src/key.rs index f494143..007e509 100644 --- a/src/key.rs +++ b/src/key.rs @@ -40,6 +40,7 @@ use crate::ext::*; /// assert_eq!(key_encoded.parse::().unwrap(), key); /// ``` #[derive(Debug, Clone, PartialEq, Eq, Hash, Copy, Default)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(transparent)] pub struct Key([u8; KEY_SIZE]); @@ -75,6 +76,7 @@ pub struct Key([u8; KEY_SIZE]); /// assert_eq!(iv_encoded.parse::().unwrap(), iv); /// ``` #[derive(Debug, Clone, PartialEq, Eq, Hash, Copy, Default)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(transparent)] pub struct IV([u8; IV_SIZE]); diff --git a/src/lib.rs b/src/lib.rs index c0293bd..61a82c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,6 +36,7 @@ fn decrypt_message_to(output: &mut W, encrypted: &[u8], key: * **smallvec** - Use `smallvec` crate to store the in-memory buffer on the stack if it's smalle enough (*default*) * **async** - Enable `AsyncSink` with tokio 0.2 `AsyncWrite` * **explicit_clear** - Explicitly clear in-memory buffer after operations. +* **serde** - Enable `Key` and `IV` to be de/serialised with Serde. */ #![cfg_attr(nightly, feature(asm))]