+fn do_oracle_attack(address: &str, variant: packet::Variant) {
+ // 16 bytes encrypted data from 'Packet::random_packet_data([4])'.
+ let cypher_block: [u8, ..16] = [254, 9, 228, 149, 60, 42, 165, 34, 233, 75, 112, 57, 37, 9, 116, 103]; // Known by the attacker.
+ let xor_operand: [u8, ..16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]; // This is the IV or the previous 16 bytes cypherblock. In our case we took the IV.
+
+ let expected_clear_block: [u8, ..16] = [44, 92, 31, 98, 220, 84, 226, 53, 58, 94, 45, 25, 242, 6, 199, 1]; // To be found by the attacker.
+
+ match oracle_machine::decypher(address, PORT, &xor_operand, &cypher_block, variant) {
+ Some(ref decyphered) if decyphered.as_slice() == expected_clear_block => {
+ println!("The oracle machine has found the clear block!:");
+ println!(" Expected block: {}", expected_clear_block.to_vec());
+ println!(" Decrypted block: {}", decyphered)
+ }
+ Some(ref other) =>
+ println!("The oracle machine hasn't found the clear block: {}", other),
+ _ =>
+ println!("The oracle machine hasn't found the clear block"),
+ }
+}
+
+enum Mode {
+ Help,
+ ServerAlone,
+ GenKey,
+ Tests,
+ OracleWeak,
+ OracleFixed,
+}
+
+fn mode() -> Mode {