Compare commits

..

22 Commits

Author SHA1 Message Date
Denis Angell
2d187658ae Update mulDiv.cpp 2024-09-20 17:05:20 +02:00
Denis Angell
94dbb2398f Merge branch 'dev' into strict-builds 2024-09-20 17:00:05 +02:00
Denis Angell
0c2cab76c9 Merge branch 'dev' into strict-builds 2024-09-04 16:50:53 +02:00
Denis Angell
77f9415e51 Update loops.txt 2024-07-08 11:25:36 +02:00
Denis Angell
fa7406fe1e add header includes 2024-07-08 11:22:17 +02:00
Denis Angell
84eee588d3 Merge branch 'dev' into strict-builds 2024-06-05 12:17:36 +02:00
Denis Angell
03569dbb11 add correct imports 2024-05-14 12:03:07 +02:00
Denis Angell
cb77121e20 Merge branch 'dev' into strict-builds 2024-05-06 12:14:05 +02:00
Denis Angell
c55a97c51a Update STValidation.h 2024-03-25 09:27:17 +01:00
Denis Angell
fc0be9c416 Merge branch 'dev' into strict-builds 2024-03-25 09:13:55 +01:00
Denis Angell
aaccf9b5b2 revert remove json log 2024-03-25 09:12:55 +01:00
Denis Angell
17af075665 revert remove json log 2024-03-25 09:12:33 +01:00
Denis Angell
e6b362c832 Merge branch 'dev' into strict-builds 2024-03-22 13:38:51 +01:00
Denis Angell
5b2b915955 clang-format 2024-03-18 14:57:35 +01:00
Denis Angell
e801ead39d fix more headers 2024-03-18 14:52:00 +01:00
Denis Angell
78a96dd633 add missing headers 2024-03-18 13:17:10 +01:00
Denis Angell
b3984c166d misc 2024-03-18 13:13:09 +01:00
Denis Angell
945f737706 Update ServerInfo.cpp 2024-03-18 13:09:01 +01:00
Denis Angell
8360ff8bc2 more linting 2024-03-18 13:03:05 +01:00
Denis Angell
c1274d2a12 Update ServerDefinitions_test.cpp 2024-03-18 13:02:03 +01:00
Denis Angell
4aa79b6100 Update ClaimReward_test.cpp 2024-03-18 12:59:05 +01:00
Denis Angell
6a4c563ced fix
invalid operands to binary expression ('basic_ostream<char, std::char_traits<char>>' and 'Json::Value')
2024-03-18 12:38:25 +01:00
20 changed files with 131 additions and 382 deletions

View File

@@ -44,7 +44,7 @@ else()
endif()
# TBD:
# Boost_USE_DEBUG_RUNTIME: When ON, uses Boost libraries linked against the
find_package(Boost 1.86 REQUIRED
find_package(Boost 1.70 REQUIRED
COMPONENTS
chrono
container

View File

@@ -11,8 +11,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(Boost_NO_BOOST_CMAKE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64-v4")
# make GIT_COMMIT_HASH define available to all sources
find_package(Git)
if(Git_FOUND)

View File

@@ -90,11 +90,11 @@ echo "-- Install Cmake 3.23.1 --" &&
pwd &&
( wget -nc -q https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-linux-x86_64.tar.gz; echo "" ) &&
tar -xzf cmake-3.23.1-linux-x86_64.tar.gz -C /hbb/ &&
echo "-- Install Boost 1.86.0 --" &&
echo "-- Install Boost 1.75.0 --" &&
pwd &&
( wget -nc -q https://boostorg.jfrog.io/artifactory/main/release/1.86.0/source/boost_1_86_0.tar.gz; echo "" ) &&
tar -xzf boost_1_86_0.tar.gz &&
cd boost_1_86_0 && ./bootstrap.sh && ./b2 link=static -j$3 && ./b2 install &&
( wget -nc -q https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz; echo "" ) &&
tar -xzf boost_1_75_0.tar.gz &&
cd boost_1_75_0 && ./bootstrap.sh && ./b2 link=static -j$3 && ./b2 install &&
cd ../ &&
echo "-- Install Protobuf 3.20.0 --" &&
pwd &&
@@ -127,9 +127,9 @@ echo "-- Build WasmEdge --" &&
cd WasmEdge-0.11.2 &&
( mkdir build; echo "" ) &&
cd build &&
export BOOST_ROOT="/usr/local/src/boost_1_86_0" &&
export BOOST_ROOT="/usr/local/src/boost_1_75_0" &&
export Boost_LIBRARY_DIRS="/usr/local/lib" &&
export BOOST_INCLUDEDIR="/usr/local/src/boost_1_86_0" &&
export BOOST_INCLUDEDIR="/usr/local/src/boost_1_75_0" &&
export PATH=`echo $PATH | sed -E "s/devtoolset-7/devtoolset-9/g"` &&
cmake .. \
-DCMAKE_BUILD_TYPE=Release \

View File

@@ -111,7 +111,7 @@ public:
std::uint32_t minimumTxnInLedgerSA = 1000;
/// Number of transactions per ledger that fee escalation "works
/// towards".
std::uint32_t targetTxnInLedger = 1000;
std::uint32_t targetTxnInLedger = 256;
/** Optional maximum allowed value of transactions per ledger before
fee escalation kicks in. By default, the maximum is an emergent
property of network, validator, and consensus performance. This

View File

@@ -194,14 +194,8 @@ ETLSource::onResolve(
{
boost::beast::get_lowest_layer(*ws_).expires_after(
std::chrono::seconds(30));
// Use async_connect with the entire results
boost::beast::get_lowest_layer(*ws_).async_connect(
results,
[this](
boost::beast::error_code ec,
boost::asio::ip::tcp::resolver::results_type::endpoint_type
ep) { onConnect(ec, ep); });
results, [this](auto ec, auto ep) { onConnect(ec, ep); });
}
}

View File

@@ -24,7 +24,6 @@
#include <ripple/beast/utility/Journal.h>
#include <boost/beast/core/string.hpp>
#include <boost/filesystem.hpp>
#include <fstream>
#include <map>
#include <memory>
#include <mutex>

View File

@@ -549,8 +549,7 @@ using uint128 = base_uint<128>;
using uint160 = base_uint<160>;
using uint256 = base_uint<256>;
/*
* template <std::size_t Bits, class Tag>
template <std::size_t Bits, class Tag>
[[nodiscard]] inline constexpr std::strong_ordering
operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
{
@@ -571,19 +570,6 @@ operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
return (*ret.first > *ret.second) ? std::strong_ordering::greater
: std::strong_ordering::less;
}
*/
template <std::size_t Bits, class Tag>
[[nodiscard]] inline constexpr std::strong_ordering
operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
{
return std::lexicographical_compare_three_way(
lhs.cbegin(),
lhs.cend(),
rhs.cbegin(),
rhs.cend(),
std::compare_three_way{});
}
template <std::size_t Bits, typename Tag>
[[nodiscard]] inline constexpr bool

View File

@@ -1,8 +1,28 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2014 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_BASICS_HARDENED_HASH_H_INCLUDED
#define RIPPLE_BASICS_HARDENED_HASH_H_INCLUDED
#include <ripple/beast/hash/hash_append.h>
#include <ripple/beast/hash/xxhasher.h>
#include <cstdint>
#include <functional>
#include <mutex>
@@ -12,68 +32,10 @@
#include <unordered_set>
#include <utility>
#if defined(__x86_64__) || defined(_M_X64)
#include <cpuid.h>
#include <immintrin.h>
#endif
namespace ripple {
namespace detail {
#if defined(__x86_64__) || defined(_M_X64)
inline bool
check_aesni_support()
{
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx))
{
return (ecx & bit_AES) != 0;
}
return false;
}
// Helper function to contain all AES-NI operations
#if defined(__GNUC__) || defined(__clang__)
__attribute__((__target__("aes")))
#endif
inline __m128i
aesni_hash_block(__m128i state, __m128i key, const void* data, size_t len)
{
const uint8_t* ptr = static_cast<const uint8_t*>(data);
while (len >= 16)
{
__m128i block = _mm_loadu_si128(reinterpret_cast<const __m128i*>(ptr));
state = _mm_xor_si128(state, block);
state = _mm_aesenc_si128(state, key);
ptr += 16;
len -= 16;
}
if (len > 0)
{
alignas(16) uint8_t last_block[16] = {0};
std::memcpy(last_block, ptr, len);
__m128i block =
_mm_load_si128(reinterpret_cast<const __m128i*>(last_block));
state = _mm_xor_si128(state, block);
state = _mm_aesenc_si128(state, key);
}
return state;
}
// Helper function for final AES round
#if defined(__GNUC__) || defined(__clang__)
__attribute__((__target__("aes")))
#endif
inline __m128i
aesni_hash_final(__m128i state, __m128i key)
{
return _mm_aesenclast_si128(state, key);
}
#endif
using seed_pair = std::pair<std::uint64_t, std::uint64_t>;
template <bool = true>
@@ -86,9 +48,12 @@ make_seed_pair() noexcept
std::random_device rng;
std::mt19937_64 gen;
std::uniform_int_distribution<std::uint64_t> dist;
state_t() : gen(rng())
{
}
// state_t(state_t const&) = delete;
// state_t& operator=(state_t const&) = delete;
};
static state_t state;
std::lock_guard lock(state.mutex);
@@ -97,23 +62,46 @@ make_seed_pair() noexcept
} // namespace detail
/**
* Seed functor once per construction
A std compatible hash adapter that resists adversarial inputs.
For this to work, T must implement in its own namespace:
@code
template <class Hasher>
void
hash_append (Hasher& h, T const& t) noexcept
{
// hash_append each base and member that should
// participate in forming the hash
using beast::hash_append;
hash_append (h, static_cast<T::base1 const&>(t));
hash_append (h, static_cast<T::base2 const&>(t));
// ...
hash_append (h, t.member1);
hash_append (h, t.member2);
// ...
}
@endcode
Do not use any version of Murmur or CityHash for the Hasher
template parameter (the hashing algorithm). For details
see https://131002.net/siphash/#at
*/
template <class HashAlgorithm = beast::xxhasher>
class hardened_hash
{
private:
detail::seed_pair m_seeds;
#if defined(__x86_64__) || defined(_M_X64)
bool using_aesni_;
#endif
public:
using result_type = typename HashAlgorithm::result_type;
hardened_hash()
: m_seeds(detail::make_seed_pair<>())
#if defined(__x86_64__) || defined(_M_X64)
, using_aesni_(detail::check_aesni_support())
#endif
hardened_hash() : m_seeds(detail::make_seed_pair<>())
{
}
@@ -121,24 +109,7 @@ public:
result_type
operator()(T const& t) const noexcept
{
#if defined(__x86_64__) || defined(_M_X64)
if (using_aesni_)
{
alignas(16) __m128i key =
_mm_set_epi64x(m_seeds.first, m_seeds.second);
alignas(16) __m128i state = _mm_setzero_si128();
// Hash the data using AES-NI
const char* data = reinterpret_cast<const char*>(&t);
state = detail::aesni_hash_block(state, key, data, sizeof(t));
state = detail::aesni_hash_final(state, key);
return static_cast<result_type>(_mm_cvtsi128_si64(state));
}
#endif
// Original implementation using xxhasher
HashAlgorithm h(m_seeds.first, m_seeds.second);
using beast::hash_append;
hash_append(h, t);
return static_cast<result_type>(h);
}

View File

@@ -18,7 +18,6 @@
//==============================================================================
#include <ripple/basics/FileUtilities.h>
#include <fstream>
namespace ripple {
@@ -42,7 +41,7 @@ getFileContents(
return {};
}
std::ifstream fileStream(fullPath.string(), std::ios::in);
ifstream fileStream(fullPath, std::ios::in);
if (!fileStream)
{
@@ -72,8 +71,7 @@ writeFileContents(
using namespace boost::filesystem;
using namespace boost::system::errc;
std::ofstream fileStream(
destPath.string(), std::ios::out | std::ios::trunc);
ofstream fileStream(destPath, std::ios::out | std::ios::trunc);
if (!fileStream)
{

View File

@@ -240,7 +240,7 @@ public:
bool LEDGER_REPLAY = false;
// Work queue limits
int MAX_TRANSACTIONS = 1000;
int MAX_TRANSACTIONS = 250;
static constexpr int MAX_JOB_QUEUE_TX = 1000;
static constexpr int MIN_JOB_QUEUE_TX = 100;

View File

@@ -18,7 +18,6 @@
//==============================================================================
#include <ripple/app/rdb/Download.h>
#include <fstream>
namespace ripple {

View File

@@ -44,7 +44,7 @@ getFeatureValue(
return {};
boost::smatch match;
boost::regex rx(feature + "=([^;\\s]+)");
auto const value = std::string(header->value());
auto const value = header->value().to_string();
if (boost::regex_search(value, match, rx))
return {match[1]};
return {};
@@ -233,7 +233,7 @@ verifyHandshake(
{
if (auto const iter = headers.find("Server-Domain"); iter != headers.end())
{
if (!isProperlyFormedTomlDomain(std::string(iter->value())))
if (!isProperlyFormedTomlDomain(iter->value().to_string()))
throw std::runtime_error("Invalid server domain");
}
@@ -243,8 +243,7 @@ verifyHandshake(
uint32_t peer_nid = 0;
if (auto const iter = headers.find("Network-ID"); iter != headers.end())
{
if (!beast::lexicalCastChecked(
peer_nid, std::string(iter->value())))
if (!beast::lexicalCastChecked(peer_nid, iter->value().to_string()))
throw std::runtime_error("Invalid peer network identifier");
}
@@ -256,7 +255,7 @@ verifyHandshake(
if (auto const iter = headers.find("Network-Time"); iter != headers.end())
{
auto const netTime =
[str = std::string(iter->value())]() -> TimeKeeper::time_point {
[str = iter->value().to_string()]() -> TimeKeeper::time_point {
TimeKeeper::duration::rep val;
if (beast::lexicalCastChecked(val, str))
@@ -292,7 +291,7 @@ verifyHandshake(
if (auto const iter = headers.find("Public-Key"); iter != headers.end())
{
auto pk = parseBase58<PublicKey>(
TokenType::NodePublic, std::string(iter->value()));
TokenType::NodePublic, iter->value().to_string());
if (pk)
{
@@ -318,7 +317,7 @@ verifyHandshake(
if (iter == headers.end())
throw std::runtime_error("No session signature specified");
auto sig = base64_decode(std::string(iter->value()));
auto sig = base64_decode(iter->value().to_string());
if (!verifyDigest(publicKey, sharedValue, makeSlice(sig), false))
throw std::runtime_error("Failed to verify session");
@@ -331,7 +330,7 @@ verifyHandshake(
{
boost::system::error_code ec;
auto const local_ip = boost::asio::ip::address::from_string(
std::string(iter->value()), ec);
iter->value().to_string(), ec);
if (ec)
throw std::runtime_error("Invalid Local-IP");
@@ -346,7 +345,7 @@ verifyHandshake(
{
boost::system::error_code ec;
auto const remote_ip = boost::asio::ip::address::from_string(
std::string(iter->value()), ec);
iter->value().to_string(), ec);
if (ec)
throw std::runtime_error("Invalid Remote-IP");

View File

@@ -176,7 +176,7 @@ PeerImp::run()
if (auto const iter = headers_.find("Closed-Ledger");
iter != headers_.end())
{
closed = parseLedgerHash(std::string(iter->value()));
closed = parseLedgerHash(iter->value().to_string());
if (!closed)
fail("Malformed handshake data (1)");
@@ -185,7 +185,7 @@ PeerImp::run()
if (auto const iter = headers_.find("Previous-Ledger");
iter != headers_.end())
{
previous = parseLedgerHash(std::string(iter->value()));
previous = parseLedgerHash(iter->value().to_string());
if (!previous)
fail("Malformed handshake data (2)");
@@ -372,8 +372,8 @@ std::string
PeerImp::getVersion() const
{
if (inbound_)
return std::string(headers_["User-Agent"]);
return std::string(headers_["Server"]);
return headers_["User-Agent"].to_string();
return headers_["Server"].to_string();
}
Json::Value
@@ -399,7 +399,7 @@ PeerImp::json()
if (auto const d = domain(); !d.empty())
ret[jss::server_domain] = domain();
if (auto const nid = std::string(headers_["Network-ID"]); !nid.empty())
if (auto const nid = headers_["Network-ID"].to_string(); !nid.empty())
ret[jss::network_id] = nid;
ret[jss::load] = usage_.balance();
@@ -839,7 +839,7 @@ PeerImp::name() const
std::string
PeerImp::domain() const
{
return std::string(headers_["Server-Domain"]);
return headers_["Server-Domain"].to_string();
}
//------------------------------------------------------------------------------

View File

@@ -21,6 +21,7 @@
#define RIPPLE_PEERFINDER_CHECKER_H_INCLUDED
#include <ripple/beast/net/IPAddressConversion.h>
#include <boost/asio/detail/handler_invoke_helpers.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/intrusive/list.hpp>

View File

@@ -18,168 +18,19 @@
//==============================================================================
#include <ripple/protocol/digest.h>
#include <immintrin.h>
#include <openssl/ripemd.h>
#include <openssl/sha.h>
#include <type_traits>
namespace ripple {
namespace detail {
#if defined(__x86_64__)
#if defined(__clang__)
#pragma clang attribute push( \
__attribute__((target("xsave,avx512f,avx512bw"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC push_options
#pragma GCC target("xsave,avx512f,avx512bw")
#endif
static bool
check_avx512()
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx))
{
if ((ecx & bit_AVX) && (ecx & bit_OSXSAVE))
{
unsigned long long xcr0 = _xgetbv(0);
if ((xcr0 & 6) == 6)
{
if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx))
return (ebx & bit_AVX512F) && (ebx & bit_AVX512BW);
}
}
}
return false;
}
#if defined(__clang__)
#pragma clang attribute pop
#elif defined(__GNUC__)
#pragma GCC pop_options
#endif
#endif
static bool
has_avx512()
{
static const bool support = [] {
#if defined(__x86_64__)
return check_avx512();
#else
return false;
#endif
}();
return support;
}
#if defined(__x86_64__)
#if defined(__clang__)
#pragma clang attribute push( \
__attribute__((target("avx512f,avx512bw"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC push_options
#pragma GCC target("avx512f,avx512bw")
#endif
static void
process_sha256_blocks_avx512(
SHA256_CTX* ctx,
const uint8_t* data,
size_t blocks)
{
for (size_t i = 0; i < blocks; ++i)
{
__m512i block = _mm512_loadu_si512(
reinterpret_cast<const __m512i*>(data + (i * 64)));
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
const __m512i swap = _mm512_setr_epi64(
0x0001020304050607,
0x08090a0b0c0d0e0f,
0x1011121314151617,
0x18191a1b1c1d1e1f,
0x2021222324252627,
0x28292a2b2c2d2e2f,
0x3031323334353637,
0x38393a3b3c3d3e3f);
block = _mm512_shuffle_epi8(block, swap);
#endif
SHA256_Update(ctx, data + (i * 64), 64);
}
}
static void
process_sha512_blocks_avx512(
SHA512_CTX* ctx,
const uint8_t* data,
size_t blocks)
{
for (size_t i = 0; i < blocks; ++i)
{
__m512i block = _mm512_loadu_si512(
reinterpret_cast<const __m512i*>(data + (i * 64)));
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
const __m512i swap = _mm512_setr_epi64(
0x0001020304050607,
0x08090a0b0c0d0e0f,
0x1011121314151617,
0x18191a1b1c1d1e1f,
0x2021222324252627,
0x28292a2b2c2d2e2f,
0x3031323334353637,
0x38393a3b3c3d3e3f);
block = _mm512_shuffle_epi8(block, swap);
#endif
SHA512_Update(ctx, data + (i * 64), 64);
}
}
static void
process_ripemd160_blocks_avx512(
RIPEMD160_CTX* ctx,
const uint8_t* data,
size_t blocks)
{
for (size_t i = 0; i < blocks; ++i)
{
__m512i block = _mm512_loadu_si512(
reinterpret_cast<const __m512i*>(data + (i * 64)));
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
const __m512i swap = _mm512_setr_epi64(
0x0001020304050607,
0x08090a0b0c0d0e0f,
0x1011121314151617,
0x18191a1b1c1d1e1f,
0x2021222324252627,
0x28292a2b2c2d2e2f,
0x3031323334353637,
0x38393a3b3c3d3e3f);
block = _mm512_shuffle_epi8(block, swap);
#endif
RIPEMD160_Update(ctx, data + (i * 64), 64);
}
}
#if defined(__clang__)
#pragma clang attribute pop
#elif defined(__GNUC__)
#pragma GCC pop_options
#endif
#endif
} // namespace detail
// RIPEMD160 implementation
openssl_ripemd160_hasher::openssl_ripemd160_hasher()
{
static_assert(sizeof(ctx_) >= sizeof(RIPEMD160_CTX), "");
auto ctx = reinterpret_cast<RIPEMD160_CTX*>(ctx_);
static_assert(
sizeof(decltype(openssl_ripemd160_hasher::ctx_)) ==
sizeof(RIPEMD160_CTX),
"");
auto const ctx = reinterpret_cast<RIPEMD160_CTX*>(ctx_);
RIPEMD160_Init(ctx);
}
@@ -188,113 +39,68 @@ openssl_ripemd160_hasher::operator()(
void const* data,
std::size_t size) noexcept
{
auto ctx = reinterpret_cast<RIPEMD160_CTX*>(ctx_);
#if defined(__x86_64__)
if (detail::has_avx512() && size >= 64)
{
size_t blocks = size / 64;
detail::process_ripemd160_blocks_avx512(
ctx, static_cast<const uint8_t*>(data), blocks);
size_t remaining = size % 64;
if (remaining)
RIPEMD160_Update(
ctx,
static_cast<const uint8_t*>(data) + (blocks * 64),
remaining);
return;
}
#endif
auto const ctx = reinterpret_cast<RIPEMD160_CTX*>(ctx_);
RIPEMD160_Update(ctx, data, size);
}
openssl_ripemd160_hasher::operator result_type() noexcept
{
auto ctx = reinterpret_cast<RIPEMD160_CTX*>(ctx_);
auto const ctx = reinterpret_cast<RIPEMD160_CTX*>(ctx_);
result_type digest;
RIPEMD160_Final(digest.data(), ctx);
return digest;
}
// SHA256 implementation
openssl_sha256_hasher::openssl_sha256_hasher()
{
static_assert(sizeof(ctx_) >= sizeof(SHA256_CTX), "");
auto ctx = reinterpret_cast<SHA256_CTX*>(ctx_);
SHA256_Init(ctx);
}
//------------------------------------------------------------------------------
void
openssl_sha256_hasher::operator()(void const* data, std::size_t size) noexcept
{
auto ctx = reinterpret_cast<SHA256_CTX*>(ctx_);
#if defined(__x86_64__)
if (detail::has_avx512() && size >= 64)
{
size_t blocks = size / 64;
detail::process_sha256_blocks_avx512(
ctx, static_cast<const uint8_t*>(data), blocks);
size_t remaining = size % 64;
if (remaining)
SHA256_Update(
ctx,
static_cast<const uint8_t*>(data) + (blocks * 64),
remaining);
return;
}
#endif
SHA256_Update(ctx, data, size);
}
openssl_sha256_hasher::operator result_type() noexcept
{
auto ctx = reinterpret_cast<SHA256_CTX*>(ctx_);
result_type digest;
SHA256_Final(digest.data(), ctx);
return digest;
}
// SHA512 implementation
openssl_sha512_hasher::openssl_sha512_hasher()
{
static_assert(sizeof(ctx_) >= sizeof(SHA512_CTX), "");
auto ctx = reinterpret_cast<SHA512_CTX*>(ctx_);
static_assert(
sizeof(decltype(openssl_sha512_hasher::ctx_)) == sizeof(SHA512_CTX),
"");
auto const ctx = reinterpret_cast<SHA512_CTX*>(ctx_);
SHA512_Init(ctx);
}
void
openssl_sha512_hasher::operator()(void const* data, std::size_t size) noexcept
{
auto ctx = reinterpret_cast<SHA512_CTX*>(ctx_);
#if defined(__x86_64__)
if (detail::has_avx512() && size >= 64)
{
size_t blocks = size / 64;
detail::process_sha512_blocks_avx512(
ctx, static_cast<const uint8_t*>(data), blocks);
size_t remaining = size % 64;
if (remaining)
SHA512_Update(
ctx,
static_cast<const uint8_t*>(data) + (blocks * 64),
remaining);
return;
}
#endif
auto const ctx = reinterpret_cast<SHA512_CTX*>(ctx_);
SHA512_Update(ctx, data, size);
}
openssl_sha512_hasher::operator result_type() noexcept
{
auto ctx = reinterpret_cast<SHA512_CTX*>(ctx_);
auto const ctx = reinterpret_cast<SHA512_CTX*>(ctx_);
result_type digest;
SHA512_Final(digest.data(), ctx);
return digest;
}
//------------------------------------------------------------------------------
openssl_sha256_hasher::openssl_sha256_hasher()
{
static_assert(
sizeof(decltype(openssl_sha256_hasher::ctx_)) == sizeof(SHA256_CTX),
"");
auto const ctx = reinterpret_cast<SHA256_CTX*>(ctx_);
SHA256_Init(ctx);
}
void
openssl_sha256_hasher::operator()(void const* data, std::size_t size) noexcept
{
auto const ctx = reinterpret_cast<SHA256_CTX*>(ctx_);
SHA256_Update(ctx, data, size);
}
openssl_sha256_hasher::operator result_type() noexcept
{
auto const ctx = reinterpret_cast<SHA256_CTX*>(ctx_);
result_type digest;
SHA256_Final(digest.data(), ctx);
return digest;
}
} // namespace ripple

View File

@@ -247,11 +247,11 @@ build_map(boost::beast::http::fields const& h)
std::map<std::string, std::string> c;
for (auto const& e : h)
{
auto key(std::string(e.name_string()));
auto key(e.name_string().to_string());
std::transform(key.begin(), key.end(), key.begin(), [](auto kc) {
return std::tolower(static_cast<unsigned char>(kc));
});
c[key] = std::string(e.value());
c[key] = e.value().to_string();
}
return c;
}

View File

@@ -50,7 +50,7 @@ public:
{
auto it = h.find("X-User");
if (it != h.end())
user_ = std::string(it->value());
user_ = it->value().to_string();
fwdfor_ = std::string(forwardedFor(h));
}
}

View File

@@ -154,7 +154,7 @@ class LedgerLoad_test : public beast::unit_test::suite
copy_file(
sd.ledgerFile,
ledgerFileCorrupt,
copy_options::overwrite_existing,
copy_option::overwrite_if_exists,
ec);
if (!BEAST_EXPECTS(!ec, ec.message()))
return;

View File

@@ -29,7 +29,6 @@
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/stream.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/ssl.hpp>
#include <boost/beast/version.hpp>
@@ -575,7 +574,7 @@ private:
if (ec)
break;
auto path = req.target(); //.to_string();
auto path = req.target().to_string();
res.insert("Server", "TrustedPublisherServer");
res.version(req.version());
res.keep_alive(req.keep_alive());
@@ -678,8 +677,7 @@ private:
// unknown request
res.result(boost::beast::http::status::not_found);
res.insert("Content-Type", "text/html");
res.body() =
"The file '" + std::string(path) + "' was not found";
res.body() = "The file '" + path + "' was not found";
}
if (prepare)

View File

@@ -674,10 +674,10 @@ class ServerStatus_test : public beast::unit_test::suite,
resp.result() == boost::beast::http::status::switching_protocols);
BEAST_EXPECT(
resp.find("Upgrade") != resp.end() &&
std::string(resp["Upgrade"]) == "websocket");
resp["Upgrade"] == "websocket");
BEAST_EXPECT(
resp.find("Connection") != resp.end() &&
std::string(resp["Connection"]) == "Upgrade");
resp["Connection"] == "upgrade");
}
void