use tezcrypto::{cbc256_encrypt, cbc256_decrypt};
use hex::decode;

#[test]
fn test_cbc256_encrypt() {
    let key = decode("603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4").unwrap();
    let iv = decode("000102030405060708090A0B0C0D0E0F").unwrap();
    let plaintext = decode("6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710").unwrap();
    let ciphertext = decode("F58C4C04D6E5F1BA779EABFB5F7BFBD69CFC4E967EDB808D679F777BC6702C7D39F23369A9D9BACFA530E26304231461B2EB05E2C39BE9FCDA6C19078C6A9D1B").unwrap();

    let result = cbc256_encrypt(&plaintext, &key, &iv);
    assert_eq!(result, ciphertext);
}

#[test]
fn test_cbc256_decrypt() {
    let key = decode("603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4").unwrap();
    let iv = decode("000102030405060708090A0B0C0D0E0F").unwrap();
    let ciphertext = decode("F58C4C04D6E5F1BA779EABFB5F7BFBD69CFC4E967EDB808D679F777BC6702C7D39F23369A9D9BACFA530E26304231461B2EB05E2C39BE9FCDA6C19078C6A9D1B").unwrap();
    let plaintext = decode("6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710").unwrap();

    let result = cbc256_decrypt(&ciphertext, &key, &iv);
    assert_eq!(result, plaintext);
}
