diff --git a/chacha20poly1305/Cargo.toml b/chacha20poly1305/Cargo.toml index 43b02128c..94036cab5 100644 --- a/chacha20poly1305/Cargo.toml +++ b/chacha20poly1305/Cargo.toml @@ -10,13 +10,9 @@ edition.workspace = true repository.workspace = true readme.workspace = true -[features] -default = ["hacl"] -hacl = ["dep:libcrux-poly1305", "dep:libcrux-hacl-rs", "dep:libcrux-macros"] - [dependencies] libcrux-poly1305 = { version = "=0.0.2-beta.2", path = "../poly1305/", features = [ "expose-hacl", -], optional = true } -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/", optional = true } -libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros", optional = true } +] } +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/" } +libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } diff --git a/chacha20poly1305/src/impl_hacl.rs b/chacha20poly1305/src/impl_hacl.rs index 44223e6bf..dcec76bcd 100644 --- a/chacha20poly1305/src/impl_hacl.rs +++ b/chacha20poly1305/src/impl_hacl.rs @@ -1,4 +1,4 @@ -use crate::{AeadError, MacError, KEY_LEN, NONCE_LEN, TAG_LEN}; +use crate::{AeadError, KEY_LEN, NONCE_LEN, TAG_LEN}; /// The ChaCha20-Poly1305 AEAD encryption function. Writes the concatenation of the ciphertexoft /// produced by ChaCha20 and the MAC tag into `ctxt` and returns the two pieces separately. @@ -24,9 +24,6 @@ pub fn encrypt<'a>( } // ensure destination slice has just the right length - let ctxt_len = ptxt.len() + TAG_LEN; - let ctxtu32 = &mut ctxt[..ctxt_len]; - let (ctxt_cpa, tag) = ctxt.split_at_mut(ptxt.len()); let tag: &mut [u8; TAG_LEN] = tag.try_into().unwrap(); diff --git a/chacha20poly1305/src/lib.rs b/chacha20poly1305/src/lib.rs index c4cd612c7..90852f83f 100644 --- a/chacha20poly1305/src/lib.rs +++ b/chacha20poly1305/src/lib.rs @@ -35,7 +35,6 @@ pub enum MacError { InvalidMacTag, } -#[cfg(feature = "hacl")] mod hacl { pub(crate) use libcrux_poly1305::hacl::mac_poly1305; @@ -44,8 +43,6 @@ mod hacl { pub(crate) mod chacha20_vec32; } -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::*; diff --git a/curve25519/Cargo.toml b/curve25519/Cargo.toml index fccb866f3..c7e990139 100644 --- a/curve25519/Cargo.toml +++ b/curve25519/Cargo.toml @@ -10,13 +10,6 @@ edition.workspace = true repository.workspace = true readme.workspace = true -[features] -default = ["hacl"] -hacl = ["dep:libcrux-sha2", "dep:libcrux-hacl-rs", "dep:libcrux-macros"] - [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/", optional = true } -libcrux-sha2 = { version = "=0.0.2-beta.2", path = "../sha2", optional = true, features = [ - "hacl", -] } -libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros", optional = true } +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/" } +libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } diff --git a/curve25519/src/lib.rs b/curve25519/src/lib.rs index 5e697f9c1..e61317202 100644 --- a/curve25519/src/lib.rs +++ b/curve25519/src/lib.rs @@ -1,12 +1,9 @@ #![no_std] -#[cfg(feature = "hacl")] pub use libcrux_hacl_rs::curve25519_51 as hacl; -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::{ecdh, secret_to_public}; /// The length of Curve25519 secret keys. @@ -22,8 +19,9 @@ pub const SHK_LEN: usize = 32; pub struct Error; /// This trait is implemented by the backing implementations. -/// Only used for implementation agility. -pub trait Curve25519 { +/// Only used for ensuring implementations follow the same interface, not really consumed. +#[allow(dead_code)] +trait Curve25519 { /// Computes a public key from a secret key. fn secret_to_public(pk: &mut [u8; PK_LEN], sk: &[u8; SK_LEN]); diff --git a/ed25519/Cargo.toml b/ed25519/Cargo.toml index 18fd3021d..3eaae4193 100644 --- a/ed25519/Cargo.toml +++ b/ed25519/Cargo.toml @@ -10,13 +10,9 @@ edition.workspace = true repository.workspace = true readme.workspace = true -[features] -default = ["hacl"] -hacl = ["dep:libcrux-sha2", "dep:libcrux-hacl-rs", "dep:libcrux-macros"] - [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/", optional = true } -libcrux-sha2 = { version = "=0.0.2-beta.2", path = "../sha2", optional = true, features = [ - "hacl", +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/" } +libcrux-sha2 = { version = "=0.0.2-beta.2", path = "../sha2", features = [ + "expose-hacl", ] } -libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros", optional = true } +libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } diff --git a/ed25519/src/lib.rs b/ed25519/src/lib.rs index 9dfd36fa8..706bde8a0 100644 --- a/ed25519/src/lib.rs +++ b/ed25519/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#[cfg(feature = "hacl")] pub mod hacl { //! This module contains generated hacl code. @@ -8,8 +7,6 @@ pub mod hacl { pub mod ed25519_precomptable; } -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::*; diff --git a/libcrux-ecdh/Cargo.toml b/libcrux-ecdh/Cargo.toml index 3fa7eb40c..fdd85df6c 100644 --- a/libcrux-ecdh/Cargo.toml +++ b/libcrux-ecdh/Cargo.toml @@ -15,9 +15,7 @@ path = "src/ecdh.rs" [dependencies] rand = { version = "0.8" } libcrux-hacl = { version = "=0.0.2-beta.2", path = "../sys/hacl" } -libcrux-curve25519 = { version = "=0.0.2-beta.2", path = "../curve25519", features = [ - "hacl", -] } +libcrux-curve25519 = { version = "=0.0.2-beta.2", path = "../curve25519" } [dev-dependencies] rand_core = { version = "0.6" } diff --git a/libcrux-hkdf/Cargo.toml b/libcrux-hkdf/Cargo.toml index c1b9e2839..a317bf967 100644 --- a/libcrux-hkdf/Cargo.toml +++ b/libcrux-hkdf/Cargo.toml @@ -13,13 +13,8 @@ description = "Libcrux HKDF implementation" path = "src/hkdf.rs" [features] -default = ["hacl"] -hacl = ["dep:libcrux-hmac", "dep:libcrux-hacl-rs"] - [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/", optional = true } -libcrux-hmac = { version = "=0.0.2-beta.2", path = "../libcrux-hmac", optional = true, features = [ - "hacl", +libcrux-hmac = { version = "=0.0.2-beta.2", path = "../libcrux-hmac", features = [ "expose-hacl", - ] } +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/" } diff --git a/libcrux-hkdf/src/hkdf.rs b/libcrux-hkdf/src/hkdf.rs index 6c912b352..e77d598d2 100644 --- a/libcrux-hkdf/src/hkdf.rs +++ b/libcrux-hkdf/src/hkdf.rs @@ -7,13 +7,10 @@ extern crate alloc; use alloc::vec::Vec; -#[cfg(feature = "hacl")] pub mod hacl; -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::{HkdfSha2_256, HkdfSha2_384, HkdfSha2_512}; pub trait HkdfMode { @@ -115,7 +112,6 @@ pub enum Error { /// HKDF extract using hash function `mode`, `salt`, and the input key material `ikm`. /// Returns the pre-key material in a vector of tag length. -#[cfg(feature = "hacl")] #[inline(always)] pub fn extract( alg: Algorithm, @@ -134,7 +130,6 @@ pub fn extract( /// HKDF expand using hash function `mode`, pre-key material `prk`, `info`, and output length `okm_len`. /// Returns the key material in a vector of length `okm_len` or [`Error::OkmLengthTooLarge`] /// if the requested output length is too large. -#[cfg(feature = "hacl")] #[inline(always)] pub fn expand( alg: Algorithm, @@ -155,7 +150,6 @@ pub fn expand( /// Calls `extract` and `expand` with the given input. /// Returns the key material in a vector of length `okm_len` or [`Error::OkmLengthTooLarge`] /// if the requested output length is too large. -#[cfg(feature = "hacl")] #[inline(always)] pub fn hkdf( mode: Algorithm, diff --git a/libcrux-hmac/Cargo.toml b/libcrux-hmac/Cargo.toml index 99fc53231..bb3bc108d 100644 --- a/libcrux-hmac/Cargo.toml +++ b/libcrux-hmac/Cargo.toml @@ -13,13 +13,11 @@ description = "Libcrux HMAC implementation" path = "src/hmac.rs" [features] -default = ["hacl"] -hacl = ["dep:libcrux-sha2", "dep:libcrux-hacl-rs", "dep:libcrux-macros"] -expose-hacl = ["hacl"] +expose-hacl = [] [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/", optional = true } -libcrux-sha2 = { version = "=0.0.2-beta.2", path = "../sha2", optional = true, features = [ +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/" } +libcrux-sha2 = { version = "=0.0.2-beta.2", path = "../sha2", features = [ "expose-hacl", ] } -libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros", optional = true } +libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } diff --git a/libcrux-hmac/src/hmac.rs b/libcrux-hmac/src/hmac.rs index 1f0243a99..8b9207712 100644 --- a/libcrux-hmac/src/hmac.rs +++ b/libcrux-hmac/src/hmac.rs @@ -7,7 +7,7 @@ extern crate alloc; use alloc::vec::Vec; -#[cfg(all(feature = "hacl", not(feature = "expose-hacl")))] +#[cfg(not(feature = "expose-hacl"))] mod hacl { pub(crate) mod hash_sha1; pub(crate) mod hmac; @@ -19,10 +19,8 @@ pub mod hacl { pub mod hmac; } -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::*; /// The HMAC algorithm defining the used hash function. diff --git a/poly1305/Cargo.toml b/poly1305/Cargo.toml index e7300cf29..575bcc697 100644 --- a/poly1305/Cargo.toml +++ b/poly1305/Cargo.toml @@ -11,10 +11,8 @@ repository.workspace = true readme.workspace = true [features] -default = ["hacl"] -hacl = ["dep:libcrux-hacl-rs", "dep:libcrux-macros"] -expose-hacl = ["hacl"] +expose-hacl = [] [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/", optional = true } -libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros", optional = true } +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs/" } +libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } diff --git a/poly1305/src/lib.rs b/poly1305/src/lib.rs index d940f8aae..ea06d97cf 100644 --- a/poly1305/src/lib.rs +++ b/poly1305/src/lib.rs @@ -15,7 +15,7 @@ pub enum Error { InvalidMacTag, } -#[cfg(all(feature = "hacl", not(feature = "expose-hacl")))] +#[cfg(not(feature = "expose-hacl"))] mod hacl { pub(crate) mod mac_poly1305; } @@ -25,8 +25,6 @@ pub mod hacl { pub mod mac_poly1305; } -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::*; diff --git a/rsa/Cargo.toml b/rsa/Cargo.toml index 268526ea3..fcc1f3faf 100644 --- a/rsa/Cargo.toml +++ b/rsa/Cargo.toml @@ -11,12 +11,10 @@ repository.workspace = true readme.workspace = true [features] -default = ["hacl"] -hacl = ["dep:libcrux-hacl-rs"] -expose-hacl = ["hacl"] +expose-hacl = [] [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs", optional = true } +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs" } libcrux-traits = { version = "=0.0.2-beta.2", path = "../traits/" } libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } libcrux-sha2 = { version = "=0.0.2-beta.2", path = "../sha2", features = [ diff --git a/rsa/src/lib.rs b/rsa/src/lib.rs index c67d40d9d..058222358 100644 --- a/rsa/src/lib.rs +++ b/rsa/src/lib.rs @@ -1,6 +1,6 @@ #![no_std] -#[cfg(all(feature = "hacl", not(feature = "expose-hacl")))] +#[cfg(not(feature = "expose-hacl"))] mod hacl { pub(crate) mod rsapss; @@ -38,12 +38,10 @@ impl DigestAlgorithm { pub enum Error { SaltTooLarge, MessageTooLarge, - SigningFailed, VerificationFailed, + SigningFailed, } -#[cfg(feature = "hacl")] mod impl_hacl; -#[cfg(feature = "hacl")] pub use impl_hacl::*; diff --git a/sha2/Cargo.toml b/sha2/Cargo.toml index a216d3c7e..9460ea2df 100644 --- a/sha2/Cargo.toml +++ b/sha2/Cargo.toml @@ -11,11 +11,9 @@ repository.workspace = true readme.workspace = true [features] -default = ["hacl"] -hacl = ["dep:libcrux-hacl-rs"] -expose-hacl = ["hacl"] +expose-hacl = [] [dependencies] -libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs", optional = true } +libcrux-hacl-rs = { version = "=0.0.2-beta.2", path = "../hacl-rs" } libcrux-traits = { version = "=0.0.2-beta.2", path = "../traits/" } libcrux-macros = { version = "=0.0.2-beta.2", path = "../macros" } diff --git a/sha2/src/lib.rs b/sha2/src/lib.rs index 0231fd743..7e2407b18 100644 --- a/sha2/src/lib.rs +++ b/sha2/src/lib.rs @@ -13,16 +13,15 @@ pub const SHA384_LENGTH: usize = 48; pub const SHA512_LENGTH: usize = 64; /// The generated hacl code -#[cfg(all(feature = "hacl", not(feature = "expose-hacl")))] +#[cfg(not(feature = "expose-hacl"))] mod hacl; +/// The generated hacl code #[cfg(feature = "expose-hacl")] pub mod hacl; /// The implementation of our types using that hacl code -#[cfg(feature = "hacl")] mod impl_hacl; /// use it if we want to use hacl -#[cfg(feature = "hacl")] pub use impl_hacl::*;