util: Add constructor of Digest object from std::istream&
Change-Id: Ie3fa6511da751fe3b7b39d7a18b4909a28376d02
Refs: #3022
diff --git a/src/util/digest.cpp b/src/util/digest.cpp
index 156d372..664df2b 100644
--- a/src/util/digest.cpp
+++ b/src/util/digest.cpp
@@ -32,6 +32,19 @@
}
template<typename Hash>
+Digest<Hash>::Digest(std::istream& is)
+ : m_isInProcess(false)
+ , m_isFinalized(true)
+{
+ using namespace CryptoPP;
+
+ m_buffer = make_shared<Buffer>(m_hash.DigestSize());
+ FileSource(is, true,
+ new HashFilter(m_hash,
+ new ArraySink(m_buffer->get(), m_buffer->size())));
+}
+
+template<typename Hash>
void
Digest<Hash>::reset()
{
diff --git a/src/util/digest.hpp b/src/util/digest.hpp
index b0189a4..0fdb3a3 100644
--- a/src/util/digest.hpp
+++ b/src/util/digest.hpp
@@ -64,6 +64,13 @@
Digest();
/**
+ * @brief Create digest of the input stream @p
+ * @param is input stream
+ */
+ explicit
+ Digest(std::istream& is);
+
+ /**
* @brief Discard the current state and start a new digest.
*/
void