pub struct InsecureKey<'k, SZ: KeySz> { /* private fields */ }Expand description
Represents a key associated with the desired hashing function which can be insecure.
§Security
It is not recommended to use this unless you have a very good reason. This reason in general
should be legacy system compatibility, modern systems without this constant
should not leverage this, instead, use the KeySlice, or provide the exact key
corresponding to the digest size of the underlying hashing function.
§FIPS Compliance
Using this plays into FIPS compliance, without this crate’s allow-non-fips feature
enabled, this cannot be constructed with a key smaller than the acceptable FIPS standard
of 14 bytes.
For more information, See FIPS 198-1, Section 3 Cryptographic Keys reference to NIST SP 800-107. Which discusses this minimum security strength of 112 bits (14 bytes) in SP 800-107, Section 5.2 Digital Signatures and SP 800-107 Section 5.3.2 The HMAC Key.
Implementations§
Source§impl<'k, SZ: KeySz> InsecureKey<'k, SZ>
impl<'k, SZ: KeySz> InsecureKey<'k, SZ>
Sourcepub const fn new(slice: &'k [u8]) -> Result<Self, InvalidSize>
pub const fn new(slice: &'k [u8]) -> Result<Self, InvalidSize>
Create a new InsecureKey instance.
§Security
Please read the InsecureKey’s type documentation regarding security, and why it is
strongly recommended to use safer, more secure alternatives like KeySlice or passing
a key of the underlying hash functions digest length for compile-time checks.
§Errors
This will return InvalidSize on conditions dependent on the allow-non-fips feature
flag.
allow-non-fipsenabled: This will returnInvalidSizeif the provided key is empty.allow-non-fipsdisabled: Pursuant to the FIPS requirements for HMAC and KDFs (for more information again read theInsecureKey’s type documentation), this will returnInvalidSizeif the provided key is shorter than the minimum acceptable FIPS standard of 14 bytes.- any configuration:
Regardless of the enabled feature flags, if the length of the key is greater than
u32::MAXthis will returnInvalidSize.
Trait Implementations§
Source§impl<'k, SZ: KeySz> GenericKey for InsecureKey<'k, SZ>
impl<'k, SZ: KeySz> GenericKey for InsecureKey<'k, SZ>
Source§impl<'k, SZ: KeySz> TryFrom<&'k [u8]> for InsecureKey<'k, SZ>
impl<'k, SZ: KeySz> TryFrom<&'k [u8]> for InsecureKey<'k, SZ>
Source§fn try_from(value: &'k [u8]) -> Result<Self, Self::Error>
fn try_from(value: &'k [u8]) -> Result<Self, Self::Error>
Create a new InsecureKey instance.
§Security
Please read the InsecureKey’s type documentation regarding security, and why it is
strongly recommended to use safer, more secure alternatives like KeySlice or passing
a key of the underlying hash functions digest length for compile-time checks.
§Errors
This will return InvalidSize on conditions dependent on the allow-non-fips feature
flag.
allow-non-fipsenabled: This will returnInvalidSizeif the provided key is empty.allow-non-fipsdisabled: Pursuant to the FIPS requirements for HMAC and KDFs (for more information again read theInsecureKey’s type documentation), this will returnInvalidSizeif the provided key is shorter than the minimum acceptable FIPS standard of 14 bytes.- any configuration:
Regardless of the enabled feature flags, if the length of the key is greater than
u32::MAXthis will returnInvalidSize.