diff options
author | Jesse Luehrs <doy@tozt.net> | 2015-03-28 19:25:19 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-03-28 19:25:19 -0400 |
commit | 59aaa954858f4ef5199dc65145b81b2d19238a75 (patch) | |
tree | 859a977e97b63893544c102da7c079f84fe2ca71 /tests | |
parent | 75b5c3f2f36d527216920d6d437bc1eef3237cd0 (diff) | |
download | matasano-59aaa954858f4ef5199dc65145b81b2d19238a75.tar.gz matasano-59aaa954858f4ef5199dc65145b81b2d19238a75.zip |
base64-decode these strings too, because why not
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/lib.rs b/tests/lib.rs index f0ead77..f15fefe 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -361,14 +361,15 @@ fn problem_17 () { ]; let key = random_aes_128_key(); - static mut chosen_plaintext: Option<&'static[u8]> = None; + static mut chosen_plaintext_idx: usize = 0; let encrypter = || { - let plaintext = strings[thread_rng().gen_range(0, strings.len())]; - unsafe { chosen_plaintext = Some(plaintext) }; + let idx = thread_rng().gen_range(0, strings.len()); + let plaintext = strings[idx].from_base64().unwrap(); + unsafe { chosen_plaintext_idx = idx }; let iv = random_aes_128_key(); return ( iv, - matasano::encrypt_aes_128_cbc(plaintext, &key[..], &iv[..]) + matasano::encrypt_aes_128_cbc(&plaintext[..], &key[..], &iv[..]) ); }; @@ -388,8 +389,9 @@ fn problem_17 () { &ciphertext[..], &validator ); - let expected = unsafe { &chosen_plaintext.unwrap() }; - assert_eq!(&plaintext, expected); + let idx = unsafe { chosen_plaintext_idx.clone() }; + let expected = strings[idx].from_base64().unwrap(); + assert_eq!(plaintext, expected); } } |