Skip to main content

Decryptor

Struct Decryptor 

Source
pub struct Decryptor<C: BlockCipher> { /* private fields */ }
Available on crate features aes or tdes only.
Expand description

Stateful decryptor object for unauthenticated symmetric ciphers used in the SSH packet encryption protocol.

Note we need encryption support for decryption in order to support AES-CTR, where encryption and decryption are the same operation.

Implementations§

Source§

impl<C: BlockCipher> Decryptor<C>

Source

pub fn new(cipher: Cipher, key: &[u8], iv: &[u8]) -> Result<Self>

Create a new decryptor object with the given Cipher, key, and iv (i.e. initialization vector).

§Errors
  • Returns Error::Crypto if the given cipher cannot be used with Decryptor.
  • Returns Error::Length if key or iv are the wrong length for the given cipher.
  • Returns Error::UnsupportedCipher if support for the given cipher is not enabled in the crate features.
Source

pub fn peek<T, F>(&mut self, f: F) -> T
where F: FnMut(&mut Self) -> T,

Call the provided function with an ephemeral Decryptor state which will be reset upon completion, returning the result of the function.

Trait Implementations§

Source§

impl<C: BlockCipher> BlockModeDecrypt for Decryptor<C>

Source§

fn decrypt_with_backend( &mut self, _f: impl BlockModeDecClosure<BlockSize = Self::BlockSize>, )

Decrypt data using backend provided to the rank-2 closure.
Source§

fn decrypt_block(&mut self, block: &mut Block<Self>)

Decrypt single block in-place.
Source§

fn decrypt_blocks(&mut self, blocks: &mut [Block<Self>])

Decrypt blocks in-place.
Source§

fn decrypt_block_inout( &mut self, block: InOut<'_, '_, Array<u8, Self::BlockSize>>, )

Decrypt single inout block.
Source§

fn decrypt_blocks_inout( &mut self, blocks: InOutBuf<'_, '_, Array<u8, Self::BlockSize>>, )

Decrypt inout blocks.
Source§

fn decrypt_block_b2b( &mut self, in_block: &Array<u8, Self::BlockSize>, out_block: &mut Array<u8, Self::BlockSize>, )

Decrypt in_block and write result to out_block.
Source§

fn decrypt_blocks_b2b( &mut self, in_blocks: &[Array<u8, Self::BlockSize>], out_blocks: &mut [Array<u8, Self::BlockSize>], ) -> Result<(), NotEqualError>

Decrypt blocks buffer-to-buffer. Read more
Source§

impl<C: BlockCipher> BlockSizeUser for Decryptor<C>

Source§

type BlockSize = <C as BlockSizeUser>::BlockSize

Size of the block in bytes.
Source§

fn block_size() -> usize

Return block size in bytes.
Source§

impl<C: BlockCipher> Debug for Decryptor<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: BlockCipher> InnerUser for Decryptor<C>

Source§

type Inner = C

Inner type.

Auto Trait Implementations§

§

impl<C> Freeze for Decryptor<C>

§

impl<C> RefUnwindSafe for Decryptor<C>

§

impl<C> Send for Decryptor<C>
where C: Send,

§

impl<C> Sync for Decryptor<C>
where C: Sync,

§

impl<C> Unpin for Decryptor<C>

§

impl<C> UnsafeUnpin for Decryptor<C>

§

impl<C> UnwindSafe for Decryptor<C>

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> KeySizeUser for T
where T: InnerUser, <T as InnerUser>::Inner: KeySizeUser,

Source§

type KeySize = <<T as InnerUser>::Inner as KeySizeUser>::KeySize

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.