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:
Josh Juran
2015-03-25 14:01:01 -07:00
committed by seelabs
parent 6675ee7f5c
commit 7d75041fb1
5 changed files with 33 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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))

View File

@@ -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);

View File

@@ -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>