pub struct AutocryptCipher { /* private fields */ }Implementations§
Trait Implementations§
Source§impl Block for AutocryptCipher
impl Block for AutocryptCipher
Source§fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
Encrypts plaintext using the Autocrypt cipher with ciphertext feedback.
This method implements the autocrypt encryption scheme where:
- The first
key.len()characters are encrypted using the original key - Subsequent characters use previously generated ciphertext as the key (CBC-like mode)
§Arguments
dst- The destination buffer where ciphertext will be writtensrc- The source plaintext to encrypt (assumes uppercase A-Z characters)
§Returns
The number of bytes written to dst, which is min(src.len(), dst.len())
§Example
use old_crypto_rs::AutocryptCipher;
use old_crypto_rs::Block;
let cipher = AutocryptCipher::new("KEY");
let plaintext = b"HELLO";
let mut ciphertext = vec![0u8; plaintext.len()];
cipher.encrypt(&mut ciphertext, plaintext);
assert_eq!(&ciphertext, b"RIJCW");Source§fn decrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
fn decrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
Decrypts ciphertext using the Autocrypt cipher with ciphertext feedback.
This method implements the autocrypt decryption scheme where:
- The first
key.len()characters are decrypted using the original key - Subsequent characters use previously processed ciphertext as the key (CBC-like mode)
§Arguments
dst- The destination buffer where plaintext will be writtensrc- The source ciphertext to decrypt (assumes uppercase A-Z characters)
§Returns
The number of bytes written to dst, which is min(src.len(), dst.len())
§Example
use old_crypto_rs::AutocryptCipher;
use old_crypto_rs::Block;
let cipher = AutocryptCipher::new("KEY");
let ciphertext = b"RIJCW";
let mut plaintext = vec![0u8; ciphertext.len()];
cipher.decrypt(&mut plaintext, ciphertext);
assert_eq!(&plaintext, b"HELLO");fn block_size(&self) -> usize
Auto Trait Implementations§
impl Freeze for AutocryptCipher
impl RefUnwindSafe for AutocryptCipher
impl Send for AutocryptCipher
impl Sync for AutocryptCipher
impl Unpin for AutocryptCipher
impl UnwindSafe for AutocryptCipher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more