Skip to content

Commit

Permalink
dhkem: rename arithmetic feature to ecdh
Browse files Browse the repository at this point in the history
This maps to the `ecdh` feature name of the respective crates
  • Loading branch information
tarcieri committed Aug 8, 2024
1 parent 1606986 commit 8e2db9f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
23 changes: 13 additions & 10 deletions dhkem/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "dhkem"
description = """
Key Encapsulation Mechanism (KEM) adapters for Elliptic Curve Diffie Hellman (ECDH) protocols
Pure Rust implementation of Key Encapsulation Mechanism (KEM) adapters for Elliptic Curve
Diffie Hellman (ECDH) protocols
"""
version = "0.1.0"
edition = "2021"
Expand All @@ -15,6 +16,8 @@ readme = "README.md"
[dependencies]
kem = "0.3.0-pre.0"
rand_core = "0.6.4"

# optional dependencies
x25519 = { version = "2.0.1", package = "x25519-dalek", optional = true, default-features = false }
elliptic-curve = { version = "0.13.8", optional = true, default-features = false }
bign256 = { version = "0.13.1", optional = true, default-features = false, features = ["arithmetic"] }
Expand All @@ -29,16 +32,16 @@ zeroize = { version = "1.8.1", optional = true, default-features = false }

[features]
default = ["zeroize"]
arithmetic = ["dep:elliptic-curve", "elliptic-curve/ecdh"]
ecdh = ["dep:elliptic-curve", "elliptic-curve/ecdh"]
x25519 = ["dep:x25519", "x25519/reusable_secrets"]
bign256 = ["dep:bign256", "arithmetic"]
k256 = ["dep:k256", "arithmetic"]
p192 = ["dep:p192", "arithmetic"]
p224 = ["dep:p224", "arithmetic"]
p256 = ["dep:p256", "arithmetic"]
p384 = ["dep:p384", "arithmetic"]
p521 = ["dep:p521", "arithmetic"]
sm2 = ["dep:sm2", "arithmetic"]
bign256 = ["dep:bign256", "ecdh"]
k256 = ["dep:k256", "ecdh"]
p192 = ["dep:p192", "ecdh"]
p224 = ["dep:p224", "ecdh"]
p256 = ["dep:p256", "ecdh"]
p384 = ["dep:p384", "ecdh"]
p521 = ["dep:p521", "ecdh"]
sm2 = ["dep:sm2", "ecdh"]
zeroize = ["dep:zeroize"]

[dev-dependencies]
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions dhkem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//! draft of the [TLS KEM
//! combiner](https://datatracker.ietf.org/doc/html/draft-ietf-tls-hybrid-design-10).
#[cfg(feature = "arithmetic")]
pub mod arithmetic;
#[cfg(feature = "ecdh")]
pub mod ecdh;

#[cfg(feature = "x25519")]
mod x25519_kem;
Expand All @@ -29,7 +29,7 @@ pub use x25519_kem::X25519;
use kem::{Decapsulate, Encapsulate};
use rand_core::CryptoRngCore;

#[cfg(feature = "arithmetic")]
#[cfg(feature = "ecdh")]
use elliptic_curve::{
sec1::{self, ToEncodedPoint},
CurveArithmetic, PublicKey,
Expand Down Expand Up @@ -83,7 +83,7 @@ impl<X> DhDecapsulator<X> {
}
}

#[cfg(feature = "arithmetic")]
#[cfg(feature = "ecdh")]
impl<C> ToEncodedPoint<C> for DhEncapsulator<PublicKey<C>>
where
C: CurveArithmetic,
Expand Down Expand Up @@ -140,21 +140,21 @@ pub trait DhKem {
}

#[cfg(feature = "bign256")]
pub type BignP256 = arithmetic::ArithmeticKem<bign256::BignP256>;
pub type BignP256 = ecdh::ArithmeticKem<bign256::BignP256>;
#[cfg(feature = "k256")]
pub type Secp256k1 = arithmetic::ArithmeticKem<k256::Secp256k1>;
pub type Secp256k1 = ecdh::ArithmeticKem<k256::Secp256k1>;
#[cfg(feature = "p192")]
pub type NistP192 = arithmetic::ArithmeticKem<p192::NistP192>;
pub type NistP192 = ecdh::ArithmeticKem<p192::NistP192>;
#[cfg(feature = "p224")]
pub type NistP224 = arithmetic::ArithmeticKem<p224::NistP224>;
pub type NistP224 = ecdh::ArithmeticKem<p224::NistP224>;
#[cfg(feature = "p256")]
pub type NistP256 = arithmetic::ArithmeticKem<p256::NistP256>;
pub type NistP256 = ecdh::ArithmeticKem<p256::NistP256>;
// include an additional alias Secp256r1 = NistP256
#[cfg(feature = "p256")]
pub type Secp256r1 = arithmetic::ArithmeticKem<p256::NistP256>;
pub type Secp256r1 = ecdh::ArithmeticKem<p256::NistP256>;
#[cfg(feature = "p384")]
pub type NistP384 = arithmetic::ArithmeticKem<p384::NistP384>;
pub type NistP384 = ecdh::ArithmeticKem<p384::NistP384>;
#[cfg(feature = "p521")]
pub type NistP521 = arithmetic::ArithmeticKem<p521::NistP521>;
pub type NistP521 = ecdh::ArithmeticKem<p521::NistP521>;
#[cfg(feature = "sm2")]
pub type Sm2 = arithmetic::ArithmeticKem<sm2::Sm2>;
pub type Sm2 = ecdh::ArithmeticKem<sm2::Sm2>;
2 changes: 1 addition & 1 deletion dhkem/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl SecretBytes for x25519::SharedSecret {
}
}

#[cfg(feature = "arithmetic")]
#[cfg(feature = "ecdh")]
impl<C> SecretBytes for elliptic_curve::ecdh::SharedSecret<C>
where
C: elliptic_curve::CurveArithmetic,
Expand Down

0 comments on commit 8e2db9f

Please sign in to comment.