nym_gateway_requests/registration/handshake/
error.rs

1// Copyright 2020 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::shared_key::SharedKeyUsageError;
5use crate::GatewayProtocolVersion;
6use crate::GatewayProtocolVersionExt;
7use thiserror::Error;
8
9#[derive(Debug, Error)]
10pub enum HandshakeError {
11    #[error("received key material of invalid length: {received}. Expected: {expected}")]
12    KeyMaterialOfInvalidSize { received: usize, expected: usize },
13
14    #[error("no nonce has been provided for aes256-gcm-siv key derivation")]
15    MissingNonceForCurrentKey,
16
17    #[error(transparent)]
18    KeyUsageFailure(#[from] SharedKeyUsageError),
19
20    #[error("received invalid signature")]
21    InvalidSignature,
22    #[error("encountered network error")]
23    NetworkError,
24    #[error("encountered network error")]
25    ClosedStream,
26    #[error("error on the remote: {0}")]
27    RemoteError(String),
28    #[error("received response was malformed:")]
29    MalformedResponse,
30    #[error("sent request was malformed")]
31    MalformedRequest,
32    #[error("sent request was malformed")]
33    HandshakeFailure,
34    #[error("received shutdown")]
35    ReceivedShutdown,
36
37    #[error("timed out waiting for a handshake message")]
38    Timeout,
39
40    #[error("Connection is in an invalid state - please send a bug report")]
41    ConnectionInInvalidState,
42
43    #[error("the gateway requests protocol version that's not supported by this client. it wants to use v{version} whilst we only understand up to v{}", GatewayProtocolVersion::CURRENT)]
44    UnsupportedProtocol { version: GatewayProtocolVersion },
45}