From 5f057aef3c16259ca07703bc93d41baba657fcad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 30 Jan 2026 18:27:09 +0300 Subject: [PATCH] crypto-common: remove weak key test methods --- crypto-common/src/lib.rs | 56 +--------------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/crypto-common/src/lib.rs b/crypto-common/src/lib.rs index 164db413f..20181b54f 100644 --- a/crypto-common/src/lib.rs +++ b/crypto-common/src/lib.rs @@ -167,19 +167,6 @@ pub trait KeyInit: KeySizeUser + Sized { /// Create new value from fixed size key. fn new(key: &Key) -> Self; - /// Check if the key might be considered weak. - #[inline] - fn weak_key_test(_key: &Key) -> Result<(), WeakKeyError> { - Ok(()) - } - - /// Create new value from fixed size key after checking it for weakness. - #[inline] - fn new_checked(key: &Key) -> Result { - Self::weak_key_test(key)?; - Ok(Self::new(key)) - } - /// Create new value from variable size key. #[inline] fn new_from_slice(key: &[u8]) -> Result { @@ -210,19 +197,6 @@ pub trait KeyIvInit: KeySizeUser + IvSizeUser + Sized { /// Create new value from fixed length key and nonce. fn new(key: &Key, iv: &Iv) -> Self; - /// Check if the key might be considered weak. - #[inline] - fn weak_key_test(_key: &Key) -> Result<(), WeakKeyError> { - Ok(()) - } - - /// Create new value from fixed length key and nonce after checking the key for weakness. - #[inline] - fn new_checked(key: &Key, iv: &Iv) -> Result { - Self::weak_key_test(key)?; - Ok(Self::new(key, iv)) - } - /// Create new value from variable length key and nonce. #[inline] fn new_from_slices(key: &[u8], iv: &[u8]) -> Result { @@ -356,11 +330,6 @@ where fn new_from_slices(key: &[u8], iv: &[u8]) -> Result { T::Inner::new_from_slice(key).and_then(|i| T::inner_iv_slice_init(i, iv)) } - - #[inline] - fn weak_key_test(key: &Key) -> Result<(), WeakKeyError> { - T::Inner::weak_key_test(key) - } } impl KeyInit for T @@ -379,11 +348,6 @@ where .map_err(|_| InvalidLength) .map(Self::inner_init) } - - #[inline] - fn weak_key_test(key: &Key) -> Result<(), WeakKeyError> { - T::Inner::weak_key_test(key) - } } // Unfortunately this blanket impl is impossible without mutually @@ -406,11 +370,6 @@ where .map_err(|_| InvalidLength) .map(Self::inner_init) } - - #[inline] - fn weak_key_test(key: &Key) -> Result<(), WeakKeyError> { - T::Inner::weak_key_test(key) - } } */ @@ -422,7 +381,7 @@ pub struct InvalidKey; impl fmt::Display for InvalidKey { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - f.write_str("WeakKey") + f.write_str("InvalidKey") } } @@ -442,16 +401,3 @@ impl fmt::Display for InvalidLength { } impl core::error::Error for InvalidLength {} - -/// The error type returned when a key is found to be weak. -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -pub struct WeakKeyError; - -impl fmt::Display for WeakKeyError { - #[inline] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - f.write_str("WeakKey") - } -} - -impl core::error::Error for WeakKeyError {}