[][src]Trait rcrypto::Cipher

pub trait Cipher {
    type Output;
    fn block_size(&self) -> Option<usize>;
fn encrypt(
        &self,
        dst: &mut Vec<u8>,
        plaintext_block: &[u8]
    ) -> Result<Self::Output, CryptoError>;
fn decrypt(
        &self,
        dst: &mut Vec<u8>,
        cipher_block: &[u8]
    ) -> Result<Self::Output, CryptoError>; }

A trait for cryptography algorithms

Associated Types

type Output

Loading content...

Required methods

fn block_size(&self) -> Option<usize>

The cryptography algorithm used data block size(in bytes) for plaintext, None means that there is no requirement for the data block size.

fn encrypt(
    &self,
    dst: &mut Vec<u8>,
    plaintext_block: &[u8]
) -> Result<Self::Output, CryptoError>

To encrypt the data_block and output the encrypted data dst, the length in bytes of the encrypted data will return if encrypt success, otherwise CryptoError returned.

fn decrypt(
    &self,
    dst: &mut Vec<u8>,
    cipher_block: &[u8]
) -> Result<Self::Output, CryptoError>

To decrypt the cipher_block and output the decrypted data dst, the length in bytes of the decrypted data will return if decrypt success, other CryptoError returned.

Loading content...

Implementors

impl Cipher for AES[src]

type Output = usize

impl Cipher for DES[src]

type Output = usize

impl Cipher for SM4[src]

type Output = usize

impl Cipher for TDES[src]

type Output = usize

impl Cipher for ZUCCipher[src]

type Output = usize

impl<C, IV> Cipher for OFB<C, IV> where
    C: Cipher,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, IV> Cipher for OFBDecrypt<C, IV> where
    C: Cipher,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, IV> Cipher for OFBEncrypt<C, IV> where
    C: Cipher,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, P> Cipher for ECBDecrypt<C, P> where
    C: Cipher,
    P: 'static + Padding
[src]

type Output = usize

impl<C, P> Cipher for ECBEncrypt<C, P> where
    C: Cipher,
    P: 'static + Padding
[src]

type Output = usize

impl<C, P, IV> Cipher for CBC<C, P, IV> where
    C: Cipher,
    P: 'static + Padding,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, P, IV> Cipher for CBCDecrypt<C, P, IV> where
    C: Cipher,
    P: 'static + Padding,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, P, IV> Cipher for CBCEncrypt<C, P, IV> where
    C: Cipher,
    P: 'static + Padding,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, P, IV> Cipher for CFB<C, P, IV> where
    C: Cipher,
    P: 'static + Padding,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, P, IV> Cipher for CFBDecrypt<C, P, IV> where
    C: Cipher,
    P: 'static + Padding,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, P, IV> Cipher for CFBEncrypt<C, P, IV> where
    C: Cipher,
    P: 'static + Padding,
    IV: InitialVec<C>, 
[src]

type Output = usize

impl<C, T> Cipher for CTR<C, T> where
    C: Cipher,
    T: Counter
[src]

type Output = usize

impl<C, T> Cipher for CTRDecrypt<C, T> where
    C: Cipher,
    T: Counter
[src]

type Output = usize

impl<C, T> Cipher for CTREncrypt<C, T> where
    C: Cipher,
    T: Counter
[src]

type Output = usize

impl<C: Cipher, P: 'static + Padding> Cipher for ECB<C, P>[src]

type Output = usize

impl<H, R> Cipher for OAEP<H, R> where
    H: Digest,
    R: IterSource<u32>, 
[src]

type Output = ()

fn encrypt(
    &self,
    dst: &mut Vec<u8>,
    plaintext_block: &[u8]
) -> Result<(), CryptoError>
[src]

the length of plaintext text should be less than or equal to self.modulus_len() - 2*self.digest_len() - 2;

fn decrypt(
    &self,
    dst: &mut Vec<u8>,
    cipher_block: &[u8]
) -> Result<(), CryptoError>
[src]

the length of cipher text should be equal to self.modulus_len();

impl<H, R> Cipher for PKCS1<H, R> where
    H: Digest + Any,
    R: IterSource<u32>, 
[src]

type Output = ()

fn encrypt(
    &self,
    dst: &mut Vec<u8>,
    plaintext_block: &[u8]
) -> Result<Self::Output, CryptoError>
[src]

the length of plaintext should be less than or equal to self.encrypt_max_message_len()

fn decrypt(
    &self,
    dst: &mut Vec<u8>,
    cipher_block: &[u8]
) -> Result<Self::Output, CryptoError>
[src]

the length of ciphertex should be equal to self.modulus_len()

Loading content...