use crate::block::serpent::Serpent;
use crate::block::BlockCipher;

#[test]
fn test_libtomcrypt_vector_128bit() {
    let key = [
        0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00,
    ];
    let pt = [0u8; 16];
    let expected_ct = [
        0x26, 0x4E, 0x54, 0x81, 0xEF, 0xF4, 0x2A, 0x46, 0x06, 0xAB, 0xDA, 0x06, 0xC0, 0xBF, 0xDA,
        0x3D,
    ];

    let serpent = Serpent::new(&key).unwrap();
    let mut block = pt;
    serpent.encrypt_block(&mut block);
    assert_eq!(block, expected_ct);

    serpent.decrypt_block(&mut block);
    assert_eq!(block, pt);
}

#[test]
fn test_libtomcrypt_vector1() {
    let key = [
        0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00,
    ];
    let pt = [0u8; 16];
    let expected_ct = [
        0xA2, 0x23, 0xAA, 0x12, 0x88, 0x46, 0x3C, 0x0E, 0x2B, 0xE3, 0x8E, 0xBD, 0x82, 0x56, 0x16,
        0xC0,
    ];

    let serpent = Serpent::new(&key).unwrap();
    let mut block = pt;
    serpent.encrypt_block(&mut block);
    assert_eq!(block, expected_ct);

    serpent.decrypt_block(&mut block);
    assert_eq!(block, pt);
}
