1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use failure::Fail;
use hex::FromHexError;
use openssl::error::ErrorStack;
use std::io;
use openssl_errors::openssl_errors;
#[derive(Debug, Fail)]
pub enum PskClientError {
#[fail(display = "Missing PSK Key")]
MissingKey,
#[fail(display = "Could not parse PSK key hex: {}", _0)]
UnparseableKeyHex(FromHexError),
#[fail(display = "Could not read input: {}", _0)]
ReadError(io::Error),
#[fail(display = "Missing PSK identity")]
MissingIdentity,
#[fail(display = "The specified host is invalid: {}", _0)]
NoValidHost(io::Error),
#[fail(display = "Failed to initialise OpenSSL: {}", _0)]
FailedInitialisation(ErrorStack),
#[fail(display = "Invalid cipherlist '{}': {}", _0, _1)]
InvalidCipherList(String, ErrorStack),
#[fail(display = "TCP stream connection error: {}", _0)]
TcpConnectError(io::Error),
#[fail(display = "SSL handshake error: {}", _0)]
SslHandshakeError(String),
}
openssl_errors! {
pub library PskClientOpenSSLError("PSK Client Helper Library") {
functions {
CONNECT_WRITE_ID("connect_write_identity");
CONNECT_WRITE_KEY("connect_write_key");
}
reasons {
IO_ERROR("An IO error occured");
}
}
}