Skip to content

Commit

Permalink
Merge pull request #49 from japaric/opt-in-serde
Browse files Browse the repository at this point in the history
hpke-rs-crypto: make serde opt-in
  • Loading branch information
franziskuskiefer authored Nov 27, 2023
2 parents 3e7e671 + eff141e commit aae8d0a
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 @@ -10,6 +10,9 @@ readme = "Readme.md"
repository = "https://github.com/franziskuskiefer/hpke-rs"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"], optional = true }
rand_core = { version = "0.6.4" }
getrandom = { version = "0.2", features = ["js"] }

[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 aae8d0a

Please sign in to comment.