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.
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 block size of the algorithm
Return true
if Cipher::Null
This is a method for check the null cipher easily
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Cipher
impl UnwindSafe for Cipher
Blanket Implementations
Mutably borrows from an owned value. Read more