Fix assorted warnings

This commit is contained in:
Joseph Birr-Pixton 2016-05-30 10:31:45 +01:00
parent a7204bfd52
commit 1aa22a1476
4 changed files with 9 additions and 36 deletions

View File

@ -68,15 +68,6 @@ impl io::Read for TlsClient {
}
}
fn read_file(filename: &str) -> Vec<u8> {
use std::io::Read;
let mut r = Vec::new();
let mut f = std::fs::File::open(filename).unwrap();
f.read_to_end(&mut r).unwrap();
r
}
impl TlsClient {
fn new(sock: TcpStream, hostname: &str) -> TlsClient {
let mut config = rustls::client::ClientConfig::default();

View File

@ -2,7 +2,7 @@ use msgs::enums::CipherSuite;
use session::SessionSecrets;
use session::MessageCipher;
use suites::{SupportedCipherSuite, DEFAULT_CIPHERSUITES};
use msgs::handshake::{CertificatePayload, ClientExtension, DigitallySignedStruct};
use msgs::handshake::{CertificatePayload, DigitallySignedStruct};
use msgs::enums::{ContentType, AlertDescription, AlertLevel};
use msgs::deframer::MessageDeframer;
use msgs::fragmenter::{MessageFragmenter, MAX_FRAGMENT_LEN};

View File

@ -374,21 +374,3 @@ pub static TRAFFIC: Handler = Handler {
expect: expect_traffic,
handle: handle_traffic
};
/* -- Generic invalid state -- */
fn expect_invalid() -> Expectation {
Expectation {
content_types: Vec::new(),
handshake_types: Vec::new()
}
}
fn handle_invalid(_sess: &mut ClientSession, _m: &Message) -> Result<ConnState, HandshakeError> {
Err(HandshakeError::General("bad state".to_string()))
}
pub static INVALID_STATE: Handler = Handler {
expect: expect_invalid,
handle: handle_invalid
};

View File

@ -61,8 +61,8 @@ mod tests {
use std::io;
use msgs;
const first_message: &'static [u8] = b"\x16\x03\x01\x01\x49\x01\x00\x01\x45\x03\x03\x37\x84\xff\xb8\x8d\xeb\x79\xcc\x8c\xb8\xd4\x7e\xf7\x99\x75\x1e\x60\x30\x9a\x18\xf9\x90\xa9\xae\x60\x6c\xf7\xa5\xf8\x95\x88\xf6\x00\x00\xb4\xc0\x30\xc0\x2c\xc0\x28\xc0\x24\xc0\x14\xc0\x0a\x00\xa5\x00\xa3\x00\xa1\x00\x9f\x00\x6b\x00\x6a\x00\x69\x00\x68\x00\x39\x00\x38\x00\x37\x00\x36\x00\x88\x00\x87\x00\x86\x00\x85\xc0\x32\xc0\x2e\xc0\x2a\xc0\x26\xc0\x0f\xc0\x05\x00\x9d\x00\x3d\x00\x35\x00\x84\xc0\x2f\xc0\x2b\xc0\x27\xc0\x23\xc0\x13\xc0\x09\x00\xa4\x00\xa2\x00\xa0\x00\x9e\x00\x67\x00\x40\x00\x3f\x00\x3e\x00\x33\x00\x32\x00\x31\x00\x30\x00\x9a\x00\x99\x00\x98\x00\x97\x00\x45\x00\x44\x00\x43\x00\x42\xc0\x31\xc0\x2d\xc0\x29\xc0\x25\xc0\x0e\xc0\x04\x00\x9c\x00\x3c\x00\x2f\x00\x96\x00\x41\xc0\x11\xc0\x07\xc0\x0c\xc0\x02\x00\x05\x00\x04\xc0\x12\xc0\x08\x00\x16\x00\x13\x00\x10\x00\x0d\xc0\x0d\xc0\x03\x00\x0a\x00\x15\x00\x12\x00\x0f\x00\x0c\x00\x09\x00\xff\x01\x00\x00\x68\x00\x00\x00\x0f\x00\x0d\x00\x00\x0a\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x00\x0b\x00\x04\x03\x00\x01\x02\x00\x0a\x00\x1c\x00\x1a\x00\x17\x00\x19\x00\x1c\x00\x1b\x00\x18\x00\x1a\x00\x16\x00\x0e\x00\x0d\x00\x0b\x00\x0c\x00\x09\x00\x0a\x00\x23\x00\x00\x00\x0d\x00\x20\x00\x1e\x06\x01\x06\x02\x06\x03\x05\x01\x05\x02\x05\x03\x04\x01\x04\x02\x04\x03\x03\x01\x03\x02\x03\x03\x02\x01\x02\x02\x02\x03\x00\x0f\x00\x01\x01";
const second_message: &'static [u8] = b"\x15\x03\x03\x00\x02\x01\x6e";
const FIRST_MESSAGE: &'static [u8] = b"\x16\x03\x01\x01\x49\x01\x00\x01\x45\x03\x03\x37\x84\xff\xb8\x8d\xeb\x79\xcc\x8c\xb8\xd4\x7e\xf7\x99\x75\x1e\x60\x30\x9a\x18\xf9\x90\xa9\xae\x60\x6c\xf7\xa5\xf8\x95\x88\xf6\x00\x00\xb4\xc0\x30\xc0\x2c\xc0\x28\xc0\x24\xc0\x14\xc0\x0a\x00\xa5\x00\xa3\x00\xa1\x00\x9f\x00\x6b\x00\x6a\x00\x69\x00\x68\x00\x39\x00\x38\x00\x37\x00\x36\x00\x88\x00\x87\x00\x86\x00\x85\xc0\x32\xc0\x2e\xc0\x2a\xc0\x26\xc0\x0f\xc0\x05\x00\x9d\x00\x3d\x00\x35\x00\x84\xc0\x2f\xc0\x2b\xc0\x27\xc0\x23\xc0\x13\xc0\x09\x00\xa4\x00\xa2\x00\xa0\x00\x9e\x00\x67\x00\x40\x00\x3f\x00\x3e\x00\x33\x00\x32\x00\x31\x00\x30\x00\x9a\x00\x99\x00\x98\x00\x97\x00\x45\x00\x44\x00\x43\x00\x42\xc0\x31\xc0\x2d\xc0\x29\xc0\x25\xc0\x0e\xc0\x04\x00\x9c\x00\x3c\x00\x2f\x00\x96\x00\x41\xc0\x11\xc0\x07\xc0\x0c\xc0\x02\x00\x05\x00\x04\xc0\x12\xc0\x08\x00\x16\x00\x13\x00\x10\x00\x0d\xc0\x0d\xc0\x03\x00\x0a\x00\x15\x00\x12\x00\x0f\x00\x0c\x00\x09\x00\xff\x01\x00\x00\x68\x00\x00\x00\x0f\x00\x0d\x00\x00\x0a\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x00\x0b\x00\x04\x03\x00\x01\x02\x00\x0a\x00\x1c\x00\x1a\x00\x17\x00\x19\x00\x1c\x00\x1b\x00\x18\x00\x1a\x00\x16\x00\x0e\x00\x0d\x00\x0b\x00\x0c\x00\x09\x00\x0a\x00\x23\x00\x00\x00\x0d\x00\x20\x00\x1e\x06\x01\x06\x02\x06\x03\x05\x01\x05\x02\x05\x03\x04\x01\x04\x02\x04\x03\x03\x01\x03\x02\x03\x03\x02\x01\x02\x02\x02\x03\x00\x0f\x00\x01\x01";
const SECOND_MESSAGE: &'static [u8] = b"\x15\x03\x03\x00\x02\x01\x6e";
struct ByteRead<'a> {
buf: &'a [u8],
@ -132,7 +132,7 @@ mod tests {
#[test]
fn check_incremental() {
let mut d = MessageDeframer::new();
input_whole_incremental(&mut d, first_message);
input_whole_incremental(&mut d, FIRST_MESSAGE);
assert_eq!(1, d.frames.len());
pop_first(&mut d);
}
@ -140,8 +140,8 @@ mod tests {
#[test]
fn check_incremental_2() {
let mut d = MessageDeframer::new();
input_whole_incremental(&mut d, first_message);
input_whole_incremental(&mut d, second_message);
input_whole_incremental(&mut d, FIRST_MESSAGE);
input_whole_incremental(&mut d, SECOND_MESSAGE);
assert_eq!(2, d.frames.len());
pop_first(&mut d);
pop_second(&mut d);
@ -150,7 +150,7 @@ mod tests {
#[test]
fn check_whole() {
let mut d = MessageDeframer::new();
assert_len(first_message.len(), input_bytes(&mut d, first_message));
assert_len(FIRST_MESSAGE.len(), input_bytes(&mut d, FIRST_MESSAGE));
assert_eq!(d.frames.len(), 1);
pop_first(&mut d);
}
@ -158,8 +158,8 @@ mod tests {
#[test]
fn check_whole_2() {
let mut d = MessageDeframer::new();
assert_len(first_message.len(), input_bytes(&mut d, first_message));
assert_len(second_message.len(), input_bytes(&mut d, second_message));
assert_len(FIRST_MESSAGE.len(), input_bytes(&mut d, FIRST_MESSAGE));
assert_len(SECOND_MESSAGE.len(), input_bytes(&mut d, SECOND_MESSAGE));
assert_eq!(d.frames.len(), 2);
pop_first(&mut d);
pop_second(&mut d);