Begining of the machine oracle (work in progress..)
[crypto_lab1.git] / src / main.rs
index 5f2fdf9..64aef28 100644 (file)
@@ -11,22 +11,24 @@ use end_point::{ Client, Server };
 mod crypto;
 mod packet;
 mod end_point;
-
-/*
-TODO
-   * Comment stocker les clefs? à quels critères doivent elle répondre?
-   * 
-*/
+mod oracle_machine;
 
 const PORT: u16 = 4221;
 
 fn print_usage() {
-   println!("{} <genkey> | <tests> | ...", os::args()[0]);
+   println!(
+      r"{} genkey | tests | oracle-weak | oracle-fixed
+   genkey: Generate a 256 bits key
+   tests: launch some tests between a client and a weak server
+   oracle-weak: launch a padding oracle attack against a weak server
+   oracle-fixed: launch a padding oracle attack against a fixed server",
+      os::args()[0]
+   );
 }
 
-fn main() {   
+fn main() {
    let args = os::args();
-   
+
    if args.iter().any(|a| a.as_slice() == "--help" || a.as_slice() == "-h") {
       print_usage();
    } else if args.len() > 1 && args[1].as_slice() == "genkey" {
@@ -35,13 +37,19 @@ fn main() {
          Err(e) => println!("Unable to generate a key. Error: {}", e)
       }
    } else {
-      println!("Starting server..., Press any key to quit");
-      
+      println!("Starting server...");
+
       match Server::new("::1", PORT) {
          Ok(mut server) => {
             println!("Server started");
-            Client::start_tests("::1", PORT);            
-            io::stdin().read_line().ok().expect("Failed to read line");         
+
+            if args.len() > 1 && args[1].as_slice() == "tests" {
+               Client::start_tests("::1", PORT);
+            }
+
+            println!("Press any key to quit");
+            io::stdin().read_line().ok().expect("Failed to read line");
+
             server.close().ok().expect("Failed to close the server");
          },
          Err(e) =>