24 #include "../security/detail/openssl.hpp" 25 #include "../security/transform/digest-filter.hpp" 26 #include "../security/transform/stream-sink.hpp" 27 #include "../security/transform/stream-source.hpp" 44 namespace tr = security::transform;
52 namespace tr = security::transform;
54 m_input = make_unique<tr::StepSource>();
55 m_output = make_unique<OBufferStream>();
57 m_isFinalized =
false;
66 BOOST_ASSERT(m_input !=
nullptr);
71 return m_output->buf();
80 if (lhs.size() != rhs.size()) {
85 return CRYPTO_memcmp(lhs.data(), rhs.data(), lhs.size()) == 0;
92 update(buf->data(), buf->size());
99 update(reinterpret_cast<const uint8_t*>(str.data()), str.size());
113 update(reinterpret_cast<const uint8_t*>(&value),
sizeof(uint64_t));
121 BOOST_THROW_EXCEPTION(
Error(
"Digest has been already finalized"));
123 BOOST_ASSERT(m_input !=
nullptr);
124 m_input->write(buffer, size);
139 sha256.
update(buffer, size);
Copyright (c) 2011-2015 Regents of the University of California.
Provides stateful SHA-256 digest calculation.
std::string toHex(const uint8_t *buffer, size_t length, bool wantUpperCase)
Return a string containing the hex representation of the bytes in buffer.
static const size_t DIGEST_SIZE
Length in bytes of a SHA-256 digest.
const uint8_t * wire() const
Get pointer to encoded wire.
bool operator==(Sha256 &digest)
Check if the supplied digest is equal to this digest.
Represents a TLV element of NDN packet format.
std::string toString()
Convert digest to std::string.
Sha256()
Create an empty SHA-256 digest.
void update(const uint8_t *buffer, size_t size)
Add a raw buffer to the digest calculation.
size_t size() const
Get size of encoded wire, including Type-Length-Value.
void reset()
Discard the current state and start a new digest calculation.
Use the SHA256 hash of the public key as the key id.
ConstBufferPtr computeDigest()
Finalize and return the digest based on all previously supplied inputs.
void printHex(std::ostream &os, uint64_t num, bool wantUpperCase)
Output the hex representation of num to the output stream os.
implements an output stream that constructs ndn::Buffer
unique_ptr< T > make_unique(Args &&... args)
Sha256 & operator<<(Sha256 &src)
Add existing digest to the digest calculation.
General-purpose automatically managed/resized buffer.
std::ostream & operator<<(std::ostream &os, Sha256 &digest)
shared_ptr< const Buffer > ConstBufferPtr