CatapultServer  v0.5.0.1 (Elephant)
Challenge.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/ionet/Packet.h"
25 #include "catapult/types.h"
26 
27 namespace catapult { namespace crypto { class KeyPair; } }
28 
29 namespace catapult { namespace net {
30 
32  using Challenge = std::array<uint8_t, 64>;
33 
34 #pragma pack(push, 1)
35 
38  static constexpr ionet::PacketType Packet_Type = ionet::PacketType::Server_Challenge;
39 
42  };
43 
46  static constexpr ionet::PacketType Packet_Type = ionet::PacketType::Server_Challenge;
47 
50 
53 
56 
59  };
60 
63  static constexpr ionet::PacketType Packet_Type = ionet::PacketType::Client_Challenge;
64 
67  };
68 
69 #pragma pack(pop)
70 
72  std::shared_ptr<ServerChallengeRequest> GenerateServerChallengeRequest();
73 
76  std::shared_ptr<ServerChallengeResponse> GenerateServerChallengeResponse(
77  const ServerChallengeRequest& request,
78  const crypto::KeyPair& keyPair,
79  ionet::ConnectionSecurityMode securityMode);
80 
82  bool VerifyServerChallengeResponse(const ServerChallengeResponse& response, const Challenge& challenge);
83 
85  std::shared_ptr<ClientChallengeResponse> GenerateClientChallengeResponse(
86  const ServerChallengeResponse& request,
87  const crypto::KeyPair& keyPair);
88 
91  bool VerifyClientChallengeResponse(const ClientChallengeResponse& response, const Key& serverPublicKey, const Challenge& challenge);
92 }}
ConnectionSecurityMode.h
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::ionet::Packet
A packet header with a data payload.
Definition: Packet.h:32
catapult::net::ServerChallengeResponse::SecurityMode
ionet::ConnectionSecurityMode SecurityMode
Security mode requested by the client.
Definition: Challenge.h:58
catapult::net::VerifyClientChallengeResponse
bool VerifyClientChallengeResponse(const ClientChallengeResponse &response, const Key &serverPublicKey, const Challenge &challenge)
Definition: Challenge.cpp:86
catapult::net::ServerChallengeResponse::Packet_Type
static constexpr ionet::PacketType Packet_Type
Definition: Challenge.h:46
catapult::net::GenerateServerChallengeResponse
std::shared_ptr< ServerChallengeResponse > GenerateServerChallengeResponse(const ServerChallengeRequest &request, const crypto::KeyPair &keyPair, ionet::ConnectionSecurityMode securityMode)
Definition: Challenge.cpp:61
catapult::ionet::ConnectionSecurityMode
ConnectionSecurityMode
Possible connection security modes.
Definition: ConnectionSecurityMode.h:36
KeyPair.h
Packet.h
catapult::net::ServerChallengeResponse::Signature
catapult::Signature Signature
Client's signature on the server challenge and any additional request information.
Definition: Challenge.h:52
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
Challenge.h
catapult::ionet::PacketType
PacketType
An enumeration of known packet types.
Definition: PacketType.h:171
PacketHandlers.h
catapult::net::ClientChallengeResponse
Packet representing a challenge response from a server to a client.
Definition: Challenge.h:62
catapult::crypto::KeyPair
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
HexFormatter.h
Signer.h
catapult::net::Challenge
std::array< uint8_t, 64 > Challenge
Challenge data.
Definition: Challenge.h:32
catapult::net::ClientChallengeResponse::Packet_Type
static constexpr ionet::PacketType Packet_Type
Definition: Challenge.h:63
catapult::net::ServerChallengeRequest::Packet_Type
static constexpr ionet::PacketType Packet_Type
Definition: Challenge.h:38
catapult::net::ServerChallengeResponse::Challenge
net::Challenge Challenge
Challenge data that should be signed by the server.
Definition: Challenge.h:49
catapult::net::ServerChallengeResponse
Packet representing a challenge response and new challenge request from a client to a server.
Definition: Challenge.h:45
catapult::crypto::KeyPair::publicKey
const auto & publicKey() const
Returns a public key of a key pair.
Definition: KeyPair.h:56
catapult::net::VerifyServerChallengeResponse
bool VerifyServerChallengeResponse(const ServerChallengeResponse &response, const Challenge &challenge)
Verifies a client's response to challenge.
Definition: Challenge.cpp:74
catapult::net::ServerChallengeRequest::Challenge
net::Challenge Challenge
Challenge data that should be signed by the client.
Definition: Challenge.h:41
types.h
catapult::net::ClientChallengeResponse::Signature
catapult::Signature Signature
Server's signature on the client challenge.
Definition: Challenge.h:66
Casting.h
catapult::net::ServerChallengeRequest
Packet representing a challenge request from a server to a client.
Definition: Challenge.h:37
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::crypto::Verify
bool Verify(const Key &publicKey, const RawBuffer &dataBuffer, const Signature &signature)
Definition: Signer.cpp:136
catapult::net::ServerChallengeResponse::PublicKey
Key PublicKey
Client's public key.
Definition: Challenge.h:55
Logging.h
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::crypto::Sign
void Sign(const KeyPair &keyPair, const RawBuffer &dataBuffer, Signature &computedSignature)
Definition: Signer.cpp:82
catapult::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
catapult::net::GenerateServerChallengeRequest
std::shared_ptr< ServerChallengeRequest > GenerateServerChallengeRequest()
Generates a random server challenge request that is sent to a client.
Definition: Challenge.cpp:55
catapult::utils::RawBuffer
BasicRawBuffer< const uint8_t > RawBuffer
A const binary buffer.
Definition: RawBuffer.h:62