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: StraddlingCheckerboardImplementations§
Source§impl VicCipher
impl VicCipher
Sourcepub fn new(persn: &str, ind: &str, phrase: &str, imsg: &str) -> Result<Self>
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 derivationphrase- Key phrase that must be at least 20 characters long, used for key expansionimsg- 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
impl Block for VicCipher
Source§fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
Encrypts plaintext using the VIC cipher.
The encryption process consists of three steps:
- Encode using the straddling checkerboard
- Apply the first (regular) transposition
- 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
fn decrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
Decrypts ciphertext using the VIC cipher.
The decryption process reverses the encryption steps:
- Reverse the second (irregular) transposition
- Reverse the first (regular) transposition
- 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.