From 56c20aeda0ddf5427f9e1b3112fec326db4a4401 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 23 Mar 2026 22:28:17 -0400 Subject: [PATCH] Rust wrapper: dilithium: remove unnecessary size define presence checks Fix F-1256 --- wrapper/rust/wolfssl-wolfcrypt/build.rs | 2 -- wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs | 6 ------ 2 files changed, 8 deletions(-) diff --git a/wrapper/rust/wolfssl-wolfcrypt/build.rs b/wrapper/rust/wolfssl-wolfcrypt/build.rs index da1b55d358..6f275d3a3b 100644 --- a/wrapper/rust/wolfssl-wolfcrypt/build.rs +++ b/wrapper/rust/wolfssl-wolfcrypt/build.rs @@ -461,8 +461,6 @@ fn scan_cfg() -> Result<()> { check_cfg(&binding, "DILITHIUM_LEVEL2_KEY_SIZE", "dilithium_level2"); check_cfg(&binding, "DILITHIUM_LEVEL3_KEY_SIZE", "dilithium_level3"); check_cfg(&binding, "DILITHIUM_LEVEL5_KEY_SIZE", "dilithium_level5"); - check_cfg(&binding, "DILITHIUM_SEED_SZ", "dilithium_make_key_seed_sz"); - check_cfg(&binding, "DILITHIUM_RND_SZ", "dilithium_rnd_sz"); /* mlkem / ML-KEM */ check_cfg(&binding, "wc_MlKemKey_Init", "mlkem"); diff --git a/wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs b/wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs index e3ba4756ec..cef8c44877 100644 --- a/wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs +++ b/wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs @@ -84,13 +84,11 @@ impl Dilithium { /// Required size in bytes of the seed passed to /// [`Dilithium::generate_from_seed()`] (`DILITHIUM_SEED_SZ`). - #[cfg(dilithium_make_key_seed_sz)] pub const DILITHIUM_SEED_SZ: usize = sys::DILITHIUM_SEED_SZ as usize; /// Required size in bytes of the seed passed to signing-with-seed /// functions such as [`Dilithium::sign_msg_with_seed()`] /// (`DILITHIUM_RND_SZ`). - #[cfg(dilithium_rnd_sz)] pub const SIGN_SEED_SIZE: usize = sys::DILITHIUM_RND_SZ as usize; /// Private (secret) key size in bytes for ML-DSA-44. @@ -277,7 +275,6 @@ impl Dilithium { heap: Option<*mut core::ffi::c_void>, dev_id: Option, ) -> Result { - #[cfg(dilithium_make_key_seed_sz)] if seed.len() != Self::DILITHIUM_SEED_SZ { return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); } @@ -1032,7 +1029,6 @@ impl Dilithium { sig: &mut [u8], seed: &[u8], ) -> Result { - #[cfg(dilithium_rnd_sz)] if seed.len() != sys::DILITHIUM_RND_SZ as usize { return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); } @@ -1077,7 +1073,6 @@ impl Dilithium { if ctx.len() > 255 { return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); } - #[cfg(dilithium_rnd_sz)] if seed.len() != sys::DILITHIUM_RND_SZ as usize { return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); } @@ -1126,7 +1121,6 @@ impl Dilithium { if ctx.len() > 255 { return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); } - #[cfg(dilithium_rnd_sz)] if seed.len() != sys::DILITHIUM_RND_SZ as usize { return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); }