24 #include "ndn-cxx/security/impl/openssl-helper.hpp" 26 #include <boost/lexical_cast.hpp> 32 class VerifierFilter::Impl
35 Impl(
const uint8_t* sig,
size_t siglen)
49 const uint8_t* sig,
size_t sigLen)
50 : m_impl(make_unique<Impl>(sig, sigLen))
52 const EVP_MD* md = detail::digestAlgorithmToEvpMd(algo);
55 boost::lexical_cast<std::string>(algo)));
57 if (EVP_DigestVerifyInit(m_impl->ctx,
nullptr, md,
nullptr,
58 reinterpret_cast<EVP_PKEY*>(key.getEvpPkey())) != 1)
60 boost::lexical_cast<std::string>(algo) +
" digest and " +
61 boost::lexical_cast<std::string>(key.
getKeyType()) +
" key"));
67 VerifierFilter::convert(
const uint8_t* buf,
size_t size)
69 if (EVP_DigestVerifyUpdate(m_impl->ctx, buf, size) != 1)
76 VerifierFilter::finalize()
78 int res = EVP_DigestVerifyFinal(m_impl->ctx, m_impl->sig, m_impl->siglen);
80 auto buffer = make_unique<OBuffer>(1);
81 (*buffer)[0] = (res == 1) ? 1 : 0;
89 const uint8_t* sig,
size_t sigLen)
91 return make_unique<VerifierFilter>(algo, key, sig, sigLen);