X-Git-Url: http://git.euphorik.ch/?p=crypto_lab1.git;a=blobdiff_plain;f=lab1_rust%2Fsrc%2Foracle_machine.rs;fp=lab1_rust%2Fsrc%2Foracle_machine.rs;h=018e2a5948cd024526ede01fba3eed4a25472f02;hp=8bf39333b4e4b91b9e96fb70f9381ed137a0d67d;hb=4d892f864a1f47eb1aab23f1c70ccb143081849c;hpb=e389f9aabe1585c2e5111e4bf874e7dbc29935b3 diff --git a/lab1_rust/src/oracle_machine.rs b/lab1_rust/src/oracle_machine.rs index 8bf3933..018e2a5 100644 --- a/lab1_rust/src/oracle_machine.rs +++ b/lab1_rust/src/oracle_machine.rs @@ -3,7 +3,8 @@ use std::io::TcpStream; use std::iter::range_inclusive; use std::slice::bytes::copy_memory; use packet; -use packet::{ Packet, Error }; +use packet::Packet; +use packet::PacketType::Error; use end_point::EndPoint; /// Tries to decipher a ciphered data block by using the previous XOR operand and an oracle on the provided address and port. @@ -49,8 +50,8 @@ pub fn decipher(address: &str, port: u16, original_xor_operand: &[u8, ..16], cip forged_xor_operand(&mut final_packet)[byte] = v; - match end_point.send_raw_with_result(final_packet) { - Ok(Ok(p @ Packet { t: Error(packet::AuthError), .. })) => { + match end_point.send_raw_with_result(&final_packet) { + Ok(Ok(p @ Packet { t: Error(packet::ErrorType::Auth), .. })) => { println!("We received a MAC Error: {}", p); // If we already got a MAC mismatch for the first byte then @@ -79,7 +80,7 @@ pub fn decipher(address: &str, port: u16, original_xor_operand: &[u8, ..16], cip break; } }, - Ok(Ok(Packet { t: Error(packet::CryptError), .. })) => (), // Ignored case: the padding is wrong. + Ok(Ok(Packet { t: Error(packet::ErrorType::Crypt), .. })) => (), // Ignored case: the padding is wrong. other => { println!("Unexcepted response, aborting. {}", other); return None