23 #include "ndn-cxx/security/impl/openssl-helper.hpp"
25 #include <boost/lexical_cast.hpp>
31 class DigestFilter::Impl
39 : m_impl(make_unique<Impl>())
41 const EVP_MD* md = detail::digestAlgorithmToEvpMd(algo);
45 if (EVP_DigestInit_ex(m_impl->ctx, md,
nullptr) == 0)
52 DigestFilter::convert(span<const uint8_t> buf)
54 if (EVP_DigestUpdate(m_impl->ctx, buf.data(), buf.size()) == 0)
61 DigestFilter::finalize()
63 auto buffer = make_unique<OBuffer>(EVP_MAX_MD_SIZE);
64 unsigned int mdLen = 0;
66 if (EVP_DigestFinal_ex(m_impl->ctx, buffer->data(), &mdLen) == 0)
69 buffer->erase(buffer->begin() + mdLen, buffer->end());
78 return make_unique<DigestFilter>(algo);