Enum osshkeys::cipher::Cipher[][src]

#[non_exhaustive]
pub enum Cipher {
    Aes128_Cbc,
    Aes192_Cbc,
    Aes256_Cbc,
    Aes128_Ctr,
    Aes192_Ctr,
    Aes256_Ctr,
    TDes_Cbc,
    Null,
}
Expand description

Indicate the algorithm used by encryption/decryption

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Aes128_Cbc
Aes192_Cbc
Aes256_Cbc
Aes128_Ctr
Aes192_Ctr
Aes256_Ctr
TDes_Cbc
Null

Implementations

Encrypt the data

Mostly used by the internal codes. Usually you don’t need to call it directly.

Decrypt the data

Mostly used by the internal codes. Usually you don’t need to call it directly.

Get the required buffer length of the underlying backend

Different cipher backend have different destination buffer length requirement. You should make sure the length of dest buffer passed to decrypt_to() is equal to the result of this function.

let cipher = Cipher::Aes128_Cbc;
let src = hex!("ed58042b83e18d59bde732638136ac0e");
let key = hex!("2b7e151628aed2a6abf7158809cf4f3c");
let iv = hex!("000102030405060708090a0b0c0d0e0f");

let mut buf = vec![0; cipher.calc_buffer_len(src.len())];
let n = cipher.decrypt_to(&mut buf, &src, &key, &iv).unwrap();
buf.truncate(n);

Return the required key length in bytes

Return the required IV length in bytes

Return the block size of the algorithm

Return the name using in OpenSSH

Return true if Cipher::Null

This is a method for check the null cipher easily

Return true if not Cipher::Null

This is a method to check the null cipher easily

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.