1use thiserror::Error;
6
7#[derive(Error, PartialEq, Copy, Clone, Debug)]
9pub enum Error {
10 #[error("parameter error")]
12 Param(#[from] ParamError),
13 #[error("builder error")]
15 Builder(#[from] BuilderError),
16 #[error("protocol error")]
18 Protocol(#[from] ProtocolError),
19 #[error("tag error")]
21 Tag(#[from] TagError),
22}
23
24#[derive(Error, PartialEq, Copy, Clone, Debug)]
26pub enum ParamError {
27 #[error("not enough parameters given")]
29 TooFewParameters,
30 #[error("invalid protocol identifier")]
32 InvalidProtocol,
33 #[error("invalid or unsupported handshake pattern")]
35 InvalidHandshake,
36 #[error("invalid key agreement protocol")]
38 InvalidKeyType,
39 #[error("invalid strobe protocol version")]
41 InvalidStrobeVersion,
42 #[error("invalid ephemeral key setup")]
44 InvalidEphemeralKeys,
45 #[error("invalid channel duplex mode")]
47 InvalidChannelDuplex,
48 #[error("invalid channel transport order")]
50 InvalidTransportOrder,
51}
52
53#[derive(Error, PartialEq, Copy, Clone, Debug)]
55pub enum BuilderError {
56 #[error("missing local secret key needed for this handshake pattern")]
58 MissingLocalSecretKey,
59 #[error("missing remote public key needed for this handshake pattern")]
61 MissingRemotePublicKey,
62 #[error("missing pre-shared key needed for this handshake pattern")]
64 MissingPreSharedKey,
65 #[error("invalid tag")]
67 InvalidTag,
68 #[error("missing bytes")]
70 MissingBytes,
71}
72
73#[derive(Error, PartialEq, Copy, Clone, Debug)]
75pub enum ProtocolError {
76 #[error("incorrect state for this operation")]
78 InvalidState,
79 #[error("invalid or missing key")]
81 InvalidKey,
82 #[error("invalid tag error")]
84 InvalidTag,
85 #[error("invalid mac error")]
87 InvalidMac,
88 #[error("invalid data")]
90 InvalidData,
91 #[error("out buffer isn't empty")]
93 NonEmptyBuffer,
94 #[error("invalid length for tagged data")]
96 InvalidBufferLen,
97
98 #[error("sending pre-shared key error")]
100 SendingPsk,
101 #[error("receiving pre-shared key error")]
103 ReceivingPsk,
104 #[error("sending prologue error")]
106 SendingPrologue,
107 #[error("receiving prologue error")]
109 ReceivingPrologue,
110 #[error("sending secret key error")]
112 SendingSecretKey,
113 #[error("receiving secret key error")]
115 ReceivingSecretKey,
116
117 #[error("invalid handshake operaion")]
119 InvalidHandshakeOp,
120 #[error("invalid parameter for channel operation")]
122 InvalidTransportOp,
123 #[error("error calculating shared secret")]
125 SharedSecretCalculationFailed,
126 #[error("message limit reached, repeat handshake")]
128 MessageLimitReached,
129 #[error("invalid nonce")]
131 InvalidNonce,
132 #[error("channel state mismatch")]
134 ChannelStateMismatch,
135 #[error("invalid send command")]
137 InvalidSend,
138 #[error("invalid recv command")]
140 InvalidRecv,
141}
142
143#[derive(Error, PartialEq, Copy, Clone, Debug)]
145pub enum TagError {
146 #[error("tag parse error")]
148 ParseError,
149}