From f0af2c1b75c366b228925a8b88cf3bf19066dc41 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 27 Mar 2015 00:16:51 -0400 Subject: make the decrypt primitives return options based on valid padding --- tests/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/lib.rs b/tests/lib.rs index cc37ec4..3dbfa55 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -107,7 +107,7 @@ fn problem_7 () { let key = b"YELLOW SUBMARINE"; let plaintext = read("data/7.out.txt"); let got = matasano::decrypt_aes_128_ecb(&ciphertext[..], key); - assert_eq!(got, plaintext); + assert_eq!(got, Some(plaintext)); } #[test] @@ -139,7 +139,7 @@ fn problem_10 () { let key = b"YELLOW SUBMARINE"; let plaintext = read("data/10.out.txt"); let got = matasano::decrypt_aes_128_cbc(&ciphertext[..], key, &[0; 16]); - assert_eq!(got, plaintext); + assert_eq!(got, Some(plaintext)); } #[test] @@ -228,7 +228,7 @@ fn problem_13 () { matasano::encrypt_aes_128_ecb(profile_for(email).as_bytes(), &key[..]) }; let decrypter = |ciphertext: &[u8]| -> Option> { - let plaintext = matasano::decrypt_aes_128_ecb(ciphertext, &key[..]); + let plaintext = matasano::decrypt_aes_128_ecb(ciphertext, &key[..]).unwrap(); let plaintext_str = std::str::from_utf8(&plaintext[..]).unwrap(); if let Some(params) = matasano::parse_query_string(plaintext_str) { return Some( @@ -327,7 +327,7 @@ fn problem_16 () { }; let verify = |ciphertext: &[u8]| -> bool { - let plaintext = matasano::decrypt_aes_128_cbc(ciphertext, &key[..], &iv[..]); + let plaintext = matasano::decrypt_aes_128_cbc(ciphertext, &key[..], &iv[..]).unwrap(); return (0..(plaintext.len() - admin.len())).any(|i| { plaintext .iter() -- cgit v1.2.3-54-g00ecf