From: Ummon Date: Tue, 9 Dec 2014 10:24:02 +0000 (+0100) Subject: Test the new syntax 'if let'. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=9cdc634f2ce4d0e88f4d3af1d6f555a5449da189;p=crypto_lab1.git Test the new syntax 'if let'. --- diff --git a/lab1_rust/Cargo.lock b/lab1_rust/Cargo.lock index d718268..7f3c078 100644 --- a/lab1_rust/Cargo.lock +++ b/lab1_rust/Cargo.lock @@ -8,7 +8,7 @@ dependencies = [ [[package]] name = "openssl" version = "0.2.2" -source = "git+https://github.com/sfackler/rust-openssl.git#b8a41f79a1a78791dddd453db0aab5f0957152fc" +source = "git+https://github.com/sfackler/rust-openssl.git#6cdd2cf577434ca3473c217e8a272ee965ef131f" dependencies = [ "openssl-sys 0.2.2 (git+https://github.com/sfackler/rust-openssl.git)", ] @@ -16,7 +16,7 @@ dependencies = [ [[package]] name = "openssl-sys" version = "0.2.2" -source = "git+https://github.com/sfackler/rust-openssl.git#b8a41f79a1a78791dddd453db0aab5f0957152fc" +source = "git+https://github.com/sfackler/rust-openssl.git#6cdd2cf577434ca3473c217e8a272ee965ef131f" dependencies = [ "pkg-config 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/lab1_rust/src/end_point.rs b/lab1_rust/src/end_point.rs index f69f78e..97104c6 100644 --- a/lab1_rust/src/end_point.rs +++ b/lab1_rust/src/end_point.rs @@ -299,10 +299,9 @@ impl EndPoint { fn read(&mut self) -> ReadingResult { fn send_error(ep: &mut EndPoint, error_type: packet::ErrorType) { - match ep.send(Error(error_type)) { - Err(e) => println!("Unable to send error packet: {}", e), - Ok(_) => () - }; + if let Err(e) = ep.send(Error(error_type)) { + println!("Unable to send error packet: {}", e) + } }; self.socket.set_timeout(DEFAULT_TIMEOUT); diff --git a/lab1_rust/src/packet.rs b/lab1_rust/src/packet.rs index 4016ccb..7e9c38c 100644 --- a/lab1_rust/src/packet.rs +++ b/lab1_rust/src/packet.rs @@ -77,12 +77,12 @@ pub enum PacketType { /// 0x0A: Decrypt error /// 0x0B: Authentication error /// TTTTTTTT: Timestamp (64 bits) -/// D...D: Encrypted data (AES-256 CBC mode) of: -/// |I|C...C|P...P| for command and answer packet: -/// I: Command ID -/// C: Command payload (from 7 to 39 bytes) -/// P: Padding from 1 to 16, |I|C...C|P...P| size must be a multiple of 16 -/// |0000000000000000| for error packet (16 bytes length) +/// D...D: Encrypted data (AES-256 CBC mode) of: +/// |I|C...C|P...P| for command and answer packet: +/// I: Command ID +/// C: Command payload (from 7 to 39 bytes) +/// P: Padding from 1 to 16, |I|C...C|P...P| size must be a multiple of 16 +/// |0000000000000000| for error packet (16 bytes length) /// MMMMMMMMMM: first 10 bytes (most significant) of the HMAC-SHA256 of: /// for command and answer packet: /// |I|C...C| for weak variant