Add the report.
[crypto_lab1.git] / lab1_rust / src / oracle_machine.rs
diff --git a/lab1_rust/src/oracle_machine.rs b/lab1_rust/src/oracle_machine.rs
new file mode 100644 (file)
index 0000000..68aef94
--- /dev/null
@@ -0,0 +1,19 @@
+use std::io;
+use std::io::{ TcpStream };
+use end_point::EndPoint;
+
+/// Try to decypher a cyphered data block by using an oracle on the provided address and port.
+/// May prints some message on the stdout.
+pub fn decypher(address: &str, port: u16, cypherblock: [u8, ..16]) -> Option<Vec<u8>> {
+   let end_point = EndPoint::new(
+      match TcpStream::connect(address, port) {
+         Ok(s) => s,
+         _ => {
+            println!("Unable to connect to the oracle on {}:{}", address, port);
+            return None
+         }
+      }
+   );
+
+   None
+}