X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=lab1_rust%2Fsrc%2Foracle_machine.rs;h=8bf39333b4e4b91b9e96fb70f9381ed137a0d67d;hb=66947be1f53eeb6906da6fa13cf4aabcee0d7948;hp=316f06ef475e50e7c9e443058126f7bcef6c9a6e;hpb=c484911fa250681026144ddb9e521daa2c2b4351;p=crypto_lab1.git diff --git a/lab1_rust/src/oracle_machine.rs b/lab1_rust/src/oracle_machine.rs index 316f06e..8bf3933 100644 --- a/lab1_rust/src/oracle_machine.rs +++ b/lab1_rust/src/oracle_machine.rs @@ -6,11 +6,11 @@ use packet; use packet::{ Packet, Error }; use end_point::EndPoint; -/// Try to decipher a ciphered data block by using the previous XOR operand and an oracle on the provided address and port. +/// Tries to decipher a ciphered data block by using the previous XOR operand and an oracle on the provided address and port. /// May print some messages on stdout. pub fn decipher(address: &str, port: u16, original_xor_operand: &[u8, ..16], cipher_block: &[u8, ..16], variant: packet::Variant) -> Option> { let mut end_point = EndPoint::new( - match TcpStream::connect(address, port) { + match TcpStream::connect((address, port)) { Ok(s) => s, _ => { println!("Unable to connect to the oracle on [{}]:{}", address, port); @@ -20,7 +20,7 @@ pub fn decipher(address: &str, port: u16, original_xor_operand: &[u8, ..16], cip variant, ); - // See 'packet::Packet' documentation for a complete description about the binary packet structure. + // Sees 'packet::Packet' documentation for a complete description about the binary packet structure. let mut final_packet = [0u8, ..2 + 1 + 8 + 32 + 10]; final_packet[1] = (final_packet.len() as u8) - 2; // Data length. copy_memory(final_packet.slice_mut(2 + 1 + 8 + 16, 2 + 1 + 8 + 32), cipher_block); @@ -40,7 +40,7 @@ pub fn decipher(address: &str, port: u16, original_xor_operand: &[u8, ..16], cip for v in range_inclusive(0u8, 255) { // For each values of the current byte. - // Compute and write timestamp. + // Computes and writes timestamp. current_timestamp += 2; { let mut timestamp_writer = io::BufWriter::new(final_packet.slice_mut(2 + 1, 2 + 1 + 8));