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