AutocryptCipher

Struct AutocryptCipher 

Source
pub struct AutocryptCipher { /* private fields */ }

Implementations§

Source§

impl AutocryptCipher

Source

pub fn new(key: &str) -> Self

Trait Implementations§

Source§

impl Block for AutocryptCipher

Source§

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 written
  • src - 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

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 written
  • src - 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");
Source§

fn block_size(&self) -> usize

Source§

impl Debug for AutocryptCipher

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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.