Skip to content

Instantly share code, notes, and snippets.

@zokier
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zokier/8732369 to your computer and use it in GitHub Desktop.
Save zokier/8732369 to your computer and use it in GitHub Desktop.
extern mod openssl = "openssl";
extern mod extra;
use crypto = openssl::crypto::symm;
use extra::hex::FromHex;
#[test]
fn test_aes_zeroes_key() {
let key = "00000000000000000000000000000000".from_hex().unwrap();
let plaintext = "80000000000000000000000000000000".from_hex().unwrap();
let ciphertext = "3ad78e726c1ec02b7ebfe92b23d9ec34".from_hex().unwrap();
let crypto_out = crypto::encrypt(crypto::AES_128_ECB, key, ~[], plaintext);
assert_eq!(ciphertext, crypto_out);
}
#[test]
fn test_aes_zeroes_plaintext() {
let key = "80000000000000000000000000000000".from_hex().unwrap();
let plaintext = "00000000000000000000000000000000".from_hex().unwrap();
let ciphertext = "0edd33d3c621e546455bd8ba1418bec8".from_hex().unwrap();
let crypto_out = crypto::encrypt(crypto::AES_128_ECB, key, ~[], plaintext);
assert_eq!(ciphertext, crypto_out);
}
running 2 tests
task 'test_aes_zeroes_key' failed at 'assertion failed: `(left == right) && (right == left)` (left: `~[58u8, 215u8, 142u8, 114u8, 108u8, 30u8, 192u8, 43u8, 126u8, 191u8, 233u8, 43u8, 35u8, 217u8, 236u8, 52u8]`, right: `~[58u8, 215u8, 142u8, 114u8, 108u8, 30u8, 192u8, 43u8, 126u8, 191u8, 233u8, 43u8, 35u8, 217u8, 236u8, 52u8, 1u8, 67u8, 219u8, 99u8, 238u8, 102u8, 176u8, 205u8, 255u8, 159u8, 105u8, 145u8, 118u8, 128u8, 21u8, 30u8]`)', test_aes.rs:12
test test_aes_zeroes_key ... FAILED
task 'test_aes_zeroes_plaintext' failed at 'assertion failed: `(left == right) && (right == left)` (left: `~[14u8, 221u8, 51u8, 211u8, 198u8, 33u8, 229u8, 70u8, 69u8, 91u8, 216u8, 186u8, 20u8, 24u8, 190u8, 200u8]`, right: `~[14u8, 221u8, 51u8, 211u8, 198u8, 33u8, 229u8, 70u8, 69u8, 91u8, 216u8, 186u8, 20u8, 24u8, 190u8, 200u8, 173u8, 116u8, 83u8, 100u8, 205u8, 206u8, 40u8, 241u8, 70u8, 242u8, 109u8, 220u8, 76u8, 110u8, 194u8, 26u8]`)', test_aes.rs:21
test test_aes_zeroes_plaintext ... FAILED
failures:
test_aes_zeroes_key
test_aes_zeroes_plaintext
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured
task '<main>' failed at 'Some tests failed', /build/rust-git/src/rust/src/libextra/test.rs:166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment