mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fixes to cryptographic containers:
* Include Sign.cpp in unity builds * Fix AnySecretKey publicKey and sign * Make AnyPublicKey copyable * Define op != for Slice * Overload op << for Slice * Overload op << for KeyType
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_BASICS_SLICE_H_INCLUDED
|
||||
#define RIPPLE_BASICS_SLICE_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -96,6 +97,13 @@ operator== (Slice const& lhs, Slice const& rhs) noexcept
|
||||
lhs.data(), rhs.data(), lhs.size()) == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
operator!= (Slice const& lhs, Slice const& rhs) noexcept
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
operator< (Slice const& lhs, Slice const& rhs) noexcept
|
||||
@@ -105,6 +113,13 @@ operator< (Slice const& lhs, Slice const& rhs) noexcept
|
||||
rhs.data(), rhs.data() + rhs.size());
|
||||
}
|
||||
|
||||
template <class Stream>
|
||||
Stream& operator<<(Stream& s, Slice const& v)
|
||||
{
|
||||
s << strHex(v.data(), v.size());
|
||||
return s;
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,13 @@ KeyType keyTypeFromString (std::string const& s);
|
||||
|
||||
const char* to_string (KeyType type);
|
||||
|
||||
template <class Stream>
|
||||
inline
|
||||
Stream& operator<<(Stream& s, KeyType type)
|
||||
{
|
||||
return s << to_string(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,9 +102,16 @@ private:
|
||||
|
||||
public:
|
||||
AnyPublicKey() = delete;
|
||||
AnyPublicKey (AnyPublicKey const&) = delete;
|
||||
AnyPublicKey& operator= (AnyPublicKey const&) = delete;
|
||||
|
||||
AnyPublicKey (AnyPublicKey const& other)
|
||||
: buffer_type(other.buffer_type::member.data(),
|
||||
other.buffer_type::member.size())
|
||||
, AnyPublicKeySlice (buffer_type::member.data(),
|
||||
buffer_type::member.size())
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
AnyPublicKey (AnyPublicKey&& other)
|
||||
: buffer_type(std::move(other.buffer_type::member))
|
||||
|
||||
@@ -77,7 +77,7 @@ AnySecretKey::publicKey() const
|
||||
{
|
||||
unsigned char buf[33];
|
||||
buf[0] = 0xED;
|
||||
ed25519_publickey(p_.data() + 1, &buf[1]);
|
||||
ed25519_publickey(p_.data(), &buf[1]);
|
||||
return AnyPublicKey(buf, sizeof(buf));
|
||||
}
|
||||
default:
|
||||
@@ -94,7 +94,7 @@ AnySecretKey::sign (
|
||||
{
|
||||
case KeyType::ed25519:
|
||||
{
|
||||
auto const sk = p_.data() + 1;
|
||||
auto const sk = p_.data();
|
||||
ed25519_public_key pk;
|
||||
ed25519_publickey(sk, pk);
|
||||
Buffer b(64);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <ripple/protocol/impl/RippleAddress.cpp>
|
||||
#include <ripple/protocol/impl/Serializer.cpp>
|
||||
#include <ripple/protocol/impl/SField.cpp>
|
||||
#include <ripple/protocol/impl/Sign.cpp>
|
||||
#include <ripple/protocol/impl/SOTemplate.cpp>
|
||||
#include <ripple/protocol/impl/TER.cpp>
|
||||
#include <ripple/protocol/impl/TxFormats.cpp>
|
||||
|
||||
Reference in New Issue
Block a user