CatapultServer  v0.5.0.1 (Elephant)
VerifyPeer.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/functions.h"
24 #include "catapult/types.h"
25 #include <memory>
26 
27 namespace catapult {
28  namespace crypto { class KeyPair; }
29  namespace ionet { class PacketIo; }
30 }
31 
32 namespace catapult { namespace net {
33 
34 #define VERIFY_RESULT_LIST \
35  /* An i/o error occurred while processing a server challenge request. */ \
36  ENUM_VALUE(Io_Error_ServerChallengeRequest) \
37  \
38  /* An i/o error occurred while processing a server challenge response. */ \
39  ENUM_VALUE(Io_Error_ServerChallengeResponse) \
40  \
41  /* An i/o error occurred while processing a client challenge response. */ \
42  ENUM_VALUE(Io_Error_ClientChallengeResponse) \
43  \
44  /* Peer sent malformed data. */ \
45  ENUM_VALUE(Malformed_Data) \
46  \
47  /* Peer failed the challenge. */ \
48  ENUM_VALUE(Failure_Challenge) \
49  \
50  /* Peer requested an unsupported connection (e.g. unsupported security mode). */ \
51  ENUM_VALUE(Failure_Unsupported_Connection) \
52  \
53  /* Peer passed the challenge. */ \
54  ENUM_VALUE(Success)
55 
56 #define ENUM_VALUE(LABEL) LABEL,
57  enum class VerifyResult {
60  };
61 #undef ENUM_VALUE
62 
67 
70  };
71 
73  std::ostream& operator<<(std::ostream& out, VerifyResult value);
74 
77 
81  void VerifyClient(
82  const std::shared_ptr<ionet::PacketIo>& pClientIo,
83  const crypto::KeyPair& keyPair,
84  ionet::ConnectionSecurityMode allowedSecurityModes,
85  const VerifyCallback& callback);
86 
89  void VerifyServer(
90  const std::shared_ptr<ionet::PacketIo>& pServerIo,
91  const VerifiedPeerInfo& serverPeerInfo,
92  const crypto::KeyPair& keyPair,
93  const VerifyCallback& callback);
94 }}
ConnectionSecurityMode.h
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
m_allowedSecurityModes
ionet::ConnectionSecurityMode m_allowedSecurityModes
Definition: VerifyPeer.cpp:114
m_keyPair
const crypto::KeyPair & m_keyPair
Definition: VerifyPeer.cpp:113
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::net::operator<<
std::ostream & operator<<(std::ostream &out, NodeRequestResult value)
Insertion operator for outputting value to out.
MacroBasedEnum.h
catapult::net::VerifyCallback
consumer< VerifyResult, const VerifiedPeerInfo & > VerifyCallback
Callback that is called with the result of a verify operation and verified peer information on succes...
Definition: VerifyPeer.h:76
catapult::net::VerifyServer
void VerifyServer(const std::shared_ptr< ionet::PacketIo > &pServerIo, const VerifiedPeerInfo &serverPeerInfo, const crypto::KeyPair &keyPair, const VerifyCallback &callback)
Definition: VerifyPeer.cpp:201
catapult::net::VerifyClientChallengeResponse
bool VerifyClientChallengeResponse(const ClientChallengeResponse &response, const Key &serverPublicKey, const Challenge &challenge)
Definition: Challenge.cpp:86
m_callback
VerifyCallback m_callback
Definition: VerifyPeer.cpp:115
catapult::net::GenerateServerChallengeResponse
std::shared_ptr< ServerChallengeResponse > GenerateServerChallengeResponse(const ServerChallengeRequest &request, const crypto::KeyPair &keyPair, ionet::ConnectionSecurityMode securityMode)
Definition: Challenge.cpp:61
VerifyPeer.h
functions.h
m_pRequest
std::shared_ptr< ServerChallengeRequest > m_pRequest
Definition: VerifyPeer.cpp:116
catapult::ionet::ConnectionSecurityMode
ConnectionSecurityMode
Possible connection security modes.
Definition: ConnectionSecurityMode.h:36
catapult::net::GenerateClientChallengeResponse
std::shared_ptr< ClientChallengeResponse > GenerateClientChallengeResponse(const ServerChallengeResponse &request, const crypto::KeyPair &keyPair)
Generates a server response to a client challenge (request) using the server key pair (keyPair).
Definition: Challenge.cpp:78
m_serverPeerInfo
VerifiedPeerInfo m_serverPeerInfo
Definition: VerifyPeer.cpp:194
catapult::net::VerifyResult
VerifyResult
Enumeration of verification results.
Definition: VerifyPeer.h:58
Challenge.h
catapult::ionet::SocketOperationCode
SocketOperationCode
Enumeration of socket operation results.
Definition: SocketOperationCode.h:50
m_pIo
std::shared_ptr< ionet::PacketIo > m_pIo
Definition: VerifyPeer.cpp:112
PacketSocket.h
catapult::crypto::KeyPair
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
catapult::net::VerifyResult::VERIFY_RESULT_LIST
catapult::net::VerifyClient
void VerifyClient(const std::shared_ptr< ionet::PacketIo > &pClientIo, const crypto::KeyPair &keyPair, ionet::ConnectionSecurityMode allowedSecurityModes, const VerifyCallback &callback)
Definition: VerifyPeer.cpp:120
MacroBasedEnumIncludes.h
catapult::net::VerifiedPeerInfo
Information about the verified node.
Definition: VerifyPeer.h:64
catapult::net::VerifiedPeerInfo::SecurityMode
ionet::ConnectionSecurityMode SecurityMode
Security mode established.
Definition: VerifyPeer.h:69
catapult::net::VerifyServerChallengeResponse
bool VerifyServerChallengeResponse(const ServerChallengeResponse &response, const Challenge &challenge)
Verifies a client's response to challenge.
Definition: Challenge.cpp:74
types.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::net::VerifiedPeerInfo::PublicKey
Key PublicKey
Public key of the node.
Definition: VerifyPeer.h:66
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
catapult::net::GenerateServerChallengeRequest
std::shared_ptr< ServerChallengeRequest > GenerateServerChallengeRequest()
Generates a random server challenge request that is sent to a client.
Definition: Challenge.cpp:55