xtea 0.1.0

XTEA block cipher
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit, array::Array};
use xtea::Xtea;

#[test]
fn xtea() {
    // https://web.archive.org/web/20231115163347/https://asecuritysite.com/encryption/xtea
    let key = b"0123456789012345";
    let plaintext = b"ABCDEFGH";
    let ciphertext = [0xea, 0x0c, 0x3d, 0x7c, 0x1c, 0x22, 0x55, 0x7f];
    let cipher = Xtea::new_from_slice(key).unwrap();

    let mut block = Array(*plaintext);
    cipher.encrypt_block(&mut block);
    assert_eq!(ciphertext, block.as_slice());

    cipher.decrypt_block(&mut block);
    assert_eq!(plaintext, block.as_slice());
}