Skip to main content

TripleDes

Struct TripleDes 

Source
pub struct TripleDes { /* private fields */ }
Expand description

A Triple-DES (TDEA) cipher.

Implementations§

Source§

impl TripleDes

Source

pub fn new_3key(key: &[u8; 24]) -> Result<Self, DesKeyError>

Construct a 3TDEA instance from a 24-byte key K1 ∥ K2 ∥ K3.

§Panics

Panics if the internal fixed-size key splits fail, which would only happen if this constructor were changed inconsistently with its type.

Source

pub fn new_3key_wiping(key: &mut [u8; 24]) -> Result<Self, DesKeyError>

Construct a 3TDEA instance and wipe the provided key buffer.

Source

pub fn new_2key(key: &[u8; 16]) -> Result<Self, DesKeyError>

Construct a 2TDEA instance from a 16-byte key K1 ∥ K2 (K3 = K1).

§Panics

Panics if the internal fixed-size key splits fail, which would only happen if this constructor were changed inconsistently with its type.

Source

pub fn new_2key_wiping(key: &mut [u8; 16]) -> Result<Self, DesKeyError>

Construct a 2TDEA instance and wipe the provided key buffer.

Source

pub fn new_single_key(key: &[u8; 8]) -> Result<Self, DesKeyError>

Construct from three 8-byte keys. K1=K2=K3 is valid (degenerates to single DES) and is used by the NIST CAVP “KEYs” tests.

Source

pub fn new_single_key_unchecked(key: &[u8; 8]) -> Self

Construct from one DES key used as K1 = K2 = K3 without weak-key checks.

Source

pub fn new_single_key_wiping(key: &mut [u8; 8]) -> Result<Self, DesKeyError>

Construct from one DES key used as K1 = K2 = K3 and wipe the buffer.

Source

pub fn encrypt_block(&self, block: &[u8; 8]) -> [u8; 8]

Encrypt a single 64-bit block: C = E(K3, D(K2, E(K1, P)))

Source

pub fn decrypt_block(&self, block: &[u8; 8]) -> [u8; 8]

Decrypt a single 64-bit block: P = D(K1, E(K2, D(K3, C)))

Trait Implementations§

Source§

impl BlockCipher for TripleDes

Source§

const BLOCK_LEN: usize = 8

Block length in bytes.
Source§

fn encrypt(&self, block: &mut [u8])

Encrypt one block in-place. Panics if block.len() != BLOCK_LEN.
Source§

fn decrypt(&self, block: &mut [u8])

Decrypt one block in-place. Panics if block.len() != BLOCK_LEN.
Source§

impl Drop for TripleDes

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.