diff options
author | Jesse Luehrs <doy@tozt.net> | 2015-05-14 16:33:47 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-05-14 16:33:47 -0400 |
commit | 0cf3044d1262610680790f3353c97a59968aafdc (patch) | |
tree | 9438bf337e5cc1cc4d54597f33a7033a194e8c32 /tests | |
parent | 514c5542652b447857223ab645ee0b3c5260d374 (diff) | |
download | matasano-0cf3044d1262610680790f3353c97a59968aafdc.tar.gz matasano-0cf3044d1262610680790f3353c97a59968aafdc.zip |
problem 30
Diffstat (limited to 'tests')
-rw-r--r-- | tests/set4.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/set4.rs b/tests/set4.rs index 1d31a85..d6fbeb5 100644 --- a/tests/set4.rs +++ b/tests/set4.rs @@ -155,3 +155,25 @@ fn problem_29 () { }) ); } + +#[test] +fn problem_30 () { + let key: Vec<u8> = ::rand::thread_rng() + .gen_iter() + .take(::rand::thread_rng().gen_range(5, 25)) + .collect(); + + let valid_input = b"comment1=cooking%20MCs;userdata=foo;comment2=%20like%20a%20pound%20of%20bacon"; + let valid_mac = matasano::md4_mac(valid_input, &key[..]); + let possibles = matasano::crack_md4_mac_length_extension(valid_input, valid_mac, b";admin=true"); + assert!( + possibles.iter().all(|&(ref input, _)| { + input.ends_with(b";admin=true") + }) + ); + assert!( + possibles.iter().any(|&(ref input, ref mac)| { + &matasano::md4_mac(&input[..], &key[..])[..] == &mac[..] + }) + ); +} |