mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add ripple::byte_view, ripple::const_byte_view
This commit is contained in:
@@ -337,16 +337,21 @@ uint256 Serializer::getSHA256 (int size) const
|
||||
|
||||
uint256 Serializer::getSHA512Half (int size) const
|
||||
{
|
||||
return getSHA512Half (mData, size);
|
||||
assert (size != 0);
|
||||
if (size == 0)
|
||||
return uint256();
|
||||
if (size < 0 || size > mData.size())
|
||||
return getSHA512Half (mData);
|
||||
|
||||
return getSHA512Half (const_byte_view (
|
||||
mData.data(), mData.data() + size));
|
||||
}
|
||||
|
||||
uint256 Serializer::getSHA512Half (Blob const& data, int size)
|
||||
uint256 Serializer::getSHA512Half (const_byte_view v)
|
||||
{
|
||||
uint256 j[2];
|
||||
|
||||
if ((size < 0) || (size > data.size ())) size = data.size ();
|
||||
|
||||
SHA512 (& (data.front ()), size, (unsigned char*) j);
|
||||
SHA512 (v.data(), v.size(),
|
||||
reinterpret_cast<unsigned char*> (j));
|
||||
return j[0];
|
||||
}
|
||||
|
||||
@@ -357,11 +362,6 @@ uint256 Serializer::getSHA512Half (const unsigned char* data, int len)
|
||||
return j[0];
|
||||
}
|
||||
|
||||
uint256 Serializer::getSHA512Half (const std::string& strData)
|
||||
{
|
||||
return getSHA512Half (reinterpret_cast<const unsigned char*> (strData.data ()), strData.size ());
|
||||
}
|
||||
|
||||
uint256 Serializer::getPrefixHash (uint32 prefix, const unsigned char* data, int len)
|
||||
{
|
||||
char be_prefix[4];
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#ifndef RIPPLE_SERIALIZER_H
|
||||
#define RIPPLE_SERIALIZER_H
|
||||
|
||||
#include "../../ripple/common/byte_view.h"
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class CKey; // forward declaration
|
||||
|
||||
class Serializer
|
||||
@@ -98,9 +102,9 @@ public:
|
||||
uint160 getRIPEMD160 (int size = -1) const;
|
||||
uint256 getSHA256 (int size = -1) const;
|
||||
uint256 getSHA512Half (int size = -1) const;
|
||||
static uint256 getSHA512Half (Blob const& data, int size = -1);
|
||||
static uint256 getSHA512Half (const_byte_view v);
|
||||
|
||||
static uint256 getSHA512Half (const unsigned char* data, int len);
|
||||
static uint256 getSHA512Half (const std::string& strData);
|
||||
|
||||
// prefix hash functions
|
||||
static uint256 getPrefixHash (uint32 prefix, const unsigned char* data, int len);
|
||||
@@ -294,5 +298,7 @@ public:
|
||||
Blob getVL ();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
|
||||
@@ -28,17 +28,17 @@ struct bignum_st;
|
||||
typedef struct bignum_st BIGNUM;
|
||||
|
||||
namespace ripple {
|
||||
|
||||
#include "crypto/Base58Data.h"
|
||||
#include "crypto/RFC1751.h"
|
||||
|
||||
#include "protocol/BuildInfo.h"
|
||||
#include "protocol/FieldNames.h"
|
||||
#include "protocol/HashPrefix.h"
|
||||
#include "protocol/Protocol.h"
|
||||
#include "protocol/RippleAddress.h"
|
||||
#include "protocol/RippleSystem.h"
|
||||
}
|
||||
#include "protocol/Serializer.h" // needs CKey
|
||||
namespace ripple {
|
||||
#include "protocol/TER.h"
|
||||
#include "protocol/SerializedTypes.h" // needs Serializer, TER
|
||||
#include "protocol/SerializedObjectTemplate.h"
|
||||
|
||||
Reference in New Issue
Block a user