Skip to content

Commit

Permalink
hpke-rs-crypto: make serde opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed Nov 24, 2023
1 parent eff7733 commit 5332887
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ repository = "https://github.com/franziskuskiefer/hpke-rs"

[dependencies]
serde_json = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"], optional = true }
rand = { version = "0.8" }
getrandom = { version = "0.2", features = ["js"] }
tls_codec = { version = "0.4.0", features = ["derive"] }

[features]
serde = ["dep:serde"]
10 changes: 7 additions & 3 deletions traits/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
//!
//! Algorithm definitions for the [`crate::HpkeCrypto`] trait.
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crate::error;

/// KEM Modes
#[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq, Copy, Clone, Debug)]
#[repr(u16)]
pub enum KemAlgorithm {
/// DH KEM on P256
Expand Down Expand Up @@ -70,7 +72,8 @@ impl KemAlgorithm {
}
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[repr(u16)]
/// AEAD types
pub enum AeadAlgorithm {
Expand Down Expand Up @@ -150,7 +153,8 @@ impl AeadAlgorithm {
}
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[repr(u16)]
/// KDF types
/// Value are taken from the HPKE RFC (not published yet)
Expand Down

0 comments on commit 5332887

Please sign in to comment.