rippled
Handshake.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_OVERLAY_HANDSHAKE_H_INCLUDED
21 #define RIPPLE_OVERLAY_HANDSHAKE_H_INCLUDED
22 
23 #include <ripple/app/main/Application.h>
24 #include <ripple/beast/utility/Journal.h>
25 #include <ripple/protocol/BuildInfo.h>
26 #include <boost/asio/ip/tcp.hpp>
27 #include <boost/asio/ssl/context.hpp>
28 #include <boost/asio/ssl/stream.hpp>
29 #include <boost/beast/core/tcp_stream.hpp>
30 #include <boost/beast/ssl/ssl_stream.hpp>
31 
32 #include <boost/asio/ssl.hpp>
33 #include <boost/beast/http/fields.hpp>
34 #include <boost/optional.hpp>
35 #include <utility>
36 
37 namespace ripple {
38 
39 using socket_type = boost::beast::tcp_stream;
40 using stream_type = boost::beast::ssl_stream<socket_type>;
41 
51 boost::optional<uint256>
53 
56 void
58  boost::beast::http::fields& h,
59  uint256 const& sharedValue,
60  boost::optional<std::uint32_t> networkID,
61  beast::IP::Address public_ip,
62  beast::IP::Address remote_ip,
63  Application& app);
64 
78  boost::beast::http::fields const& headers,
79  uint256 const& sharedValue,
80  boost::optional<std::uint32_t> networkID,
81  beast::IP::Address public_ip,
82  beast::IP::Address remote,
83  Application& app);
84 
85 } // namespace ripple
86 
87 #endif
ripple::Application
Definition: Application.h:97
utility
ripple::buildHandshake
void buildHandshake(boost::beast::http::fields &h, ripple::uint256 const &sharedValue, boost::optional< std::uint32_t > networkID, beast::IP::Address public_ip, beast::IP::Address remote_ip, Application &app)
Insert fields headers necessary for upgrading the link to the peer protocol.
Definition: Handshake.cpp:102
ripple::verifyHandshake
PublicKey verifyHandshake(boost::beast::http::fields const &headers, ripple::uint256 const &sharedValue, boost::optional< std::uint32_t > networkID, beast::IP::Address public_ip, beast::IP::Address remote, Application &app)
Validate header fields necessary for upgrading the link to the peer protocol.
Definition: Handshake.cpp:155
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:73
beast::IP::Address
boost::asio::ip::address Address
Definition: IPAddress.h:41
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::makeSharedValue
boost::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
Definition: Handshake.cpp:70
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::stream_type
boost::beast::ssl_stream< socket_type > stream_type
Definition: Handshake.h:40
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::socket_type
boost::beast::tcp_stream socket_type
Definition: Handshake.h:39