Struct skipjack_rs::Skipjack
source · [−]pub struct Skipjack { /* private fields */ }
Expand description
Struct representing a Skipjack cipher instance.
Implementations
sourceimpl Skipjack
impl Skipjack
sourcepub fn new(key: SkipjackKey) -> Skipjack
pub fn new(key: SkipjackKey) -> Skipjack
sourcepub fn encrypt(&self, block: &mut Block)
pub fn encrypt(&self, block: &mut Block)
SkipJack encryption function
SkipJack encrypts 64-bit data blocks in-place by alternating between the two stepping rules A and B.
The encryption requires a total of 32 steps. It begins with step 0 (counter at 1) and steps according to Rule A for 8 steps, then switches to Rule B for the next 8 steps.
This procedure is repeated once, after which the ciphertext is returned.
Arguments
block
- 16-bit plaintext array of length 4
Examples
use skipjack_rs::*;
let skipjack = Skipjack::new([0x00, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11].into());
let mut buf = [0x3322, 0x1100, 0xddcc, 0xbbaa].into();
skipjack.encrypt(&mut buf);
assert_eq!(buf, [0x2587, 0xcae2, 0x7a12, 0xd300].into());
sourcepub fn decrypt(&self, block: &mut Block)
pub fn decrypt(&self, block: &mut Block)
SkipJack decryption function
SkipJack decrypts 64-bit data block in-place by alternating between the two stepping rules A and B in reverse order.
The decryption, just like the encryption, requires a total of 32 steps. It begins with step 32 (counter at 32) and counts down to 0. It steps according to Rule B for 8 steps, then switches to Rule A for 8 steps.
This procedure is repeated once, after which the plaintext is returned.
Arguments
block
- 16-bit ciphertext array of length 4
Examples
use skipjack_rs::*;
let skipjack: Skipjack =
Skipjack::new([0x00, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11].into());
let mut buf = [0x2587, 0xcae2, 0x7a12, 0xd300].into();
skipjack.decrypt(&mut buf);
assert_eq!(buf, [0x3322, 0x1100, 0xddcc, 0xbbaa].into());
Auto Trait Implementations
impl RefUnwindSafe for Skipjack
impl Send for Skipjack
impl Sync for Skipjack
impl Unpin for Skipjack
impl UnwindSafe for Skipjack
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more