VicCipher

Struct VicCipher 

Source
pub struct VicCipher {
    pub sc: StraddlingCheckerboard,
    /* private fields */
}
Expand description

VIC cipher implementation combining straddling checkerboard and transposition ciphers.

The VIC cipher uses a complex key derivation system and three main components:

  • A straddling checkerboard for initial encoding
  • A first regular transposition
  • A second irregular transposition

Fields§

§sc: StraddlingCheckerboard

Implementations§

Source§

impl VicCipher

Source

pub fn new(persn: &str, ind: &str, phrase: &str, imsg: &str) -> Result<Self>

Creates a new VIC cipher instance with the specified key material.

This constructor performs the complex key derivation process used in the VIC cipher, which involves expanding the key material into three separate keys:

  • A key for the first regular transposition
  • A key for the second irregular transposition
  • A key for the straddling checkerboard
§Arguments
  • persn - Personal number used for the straddling checkerboard (typically 2 digits)
  • ind - Indicator string containing at least 5 digits used in key derivation
  • phrase - Key phrase that must be at least 20 characters long, used for key expansion
  • imsg - Initial message number as a string of digits
§Returns

Returns Ok(VicCipher) if the cipher was successfully constructed, or Err(String) if any of the key material is invalid or if the transposition or straddling checkerboard construction fails.

§Examples
let cipher = VicCipher::new(
    "89",
    "741776",
    "IDREAMOFJEANNIEWITHT",
    "77651"
).unwrap();

Trait Implementations§

Source§

impl Block for VicCipher

Source§

fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize

Encrypts plaintext using the VIC cipher.

The encryption process consists of three steps:

  1. Encode using the straddling checkerboard
  2. Apply the first (regular) transposition
  3. Apply the second (irregular) transposition
§Arguments
  • dst - Destination buffer for ciphertext (must be large enough)
  • src - Source plaintext as bytes
§Returns

Returns the number of bytes written to the destination buffer.

Source§

fn decrypt(&self, dst: &mut [u8], src: &[u8]) -> usize

Decrypts ciphertext using the VIC cipher.

The decryption process reverses the encryption steps:

  1. Reverse the second (irregular) transposition
  2. Reverse the first (regular) transposition
  3. Decode using the straddling checkerboard
§Arguments
  • dst - Destination buffer for plaintext (must be large enough)
  • src - Source ciphertext as bytes
§Returns

Returns the number of bytes written to the destination buffer.

Source§

fn block_size(&self) -> usize

Source§

impl Debug for VicCipher

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.