eva-crypto 0.1.2

Prototype level implementations of some encryption algorithms, with some generic traits.
Documentation
use eva_crypto::generic::u8x4_to_u32;
use eva_crypto::sm4::*;

#[cfg(test)]
#[test]
fn test_key_expansion() {
    let key: [u8; 16] = [
        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32,
        0x10,
    ];
    assert_eq!(u8x4_to_u32(SM4::new(&key).round_keys[31]), 0x9124a012);
}

#[test]
fn sm4() {
    let key: [u8; 16] = [
        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32,
        0x10,
    ];
    let plaintext: [u8; 16] = [
        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32,
        0x10,
    ];
    let ciphertext: [u8; 16] = [
        0x68, 0x1e, 0xdf, 0x34, 0xd2, 0x06, 0x96, 0x5e, 0x86, 0xb3, 0xe9, 0x4f, 0x53, 0x6e, 0x42,
        0x46,
    ];
    assert_eq!(SM4::new(&key).encrypt(&plaintext), ciphertext.to_vec());
    assert_eq!(SM4::new(&key).decrypt(&ciphertext), plaintext.to_vec());
}