pub trait NewBlockCipher: Sized {
type KeySize: ArrayLength<u8>;
// Required method
fn new(key: &BlockCipherKey<Self>) -> Self;
// Provided method
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength> { ... }
}
Expand description
Instantiate a BlockCipher
algorithm.
Required Associated Types§
Sourcetype KeySize: ArrayLength<u8>
type KeySize: ArrayLength<u8>
Key size in bytes with which cipher guaranteed to be initialized.
Required Methods§
Sourcefn new(key: &BlockCipherKey<Self>) -> Self
fn new(key: &BlockCipherKey<Self>) -> Self
Create new block cipher instance from key with fixed size.
Provided Methods§
Sourcefn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
Create new block cipher instance from key with variable size.
Default implementation will accept only keys with length equal to
KeySize
, but some ciphers can accept range of key lengths.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.