24 #include "ndn-cxx/security/impl/openssl-helper.hpp" 26 #include <boost/lexical_cast.hpp> 32 class SignerFilter::Impl
40 : m_impl(make_unique<Impl>())
42 const EVP_MD* md = detail::digestAlgorithmToEvpMd(algo);
45 boost::lexical_cast<std::string>(algo)));
47 if (EVP_DigestSignInit(m_impl->ctx,
nullptr, md,
nullptr,
48 reinterpret_cast<EVP_PKEY*>(key.getEvpPkey())) != 1)
50 boost::lexical_cast<std::string>(algo) +
" digest and " +
51 boost::lexical_cast<std::string>(key.
getKeyType()) +
" key"));
57 SignerFilter::convert(
const uint8_t* buf,
size_t size)
59 if (EVP_DigestSignUpdate(m_impl->ctx, buf, size) != 1)
66 SignerFilter::finalize()
69 if (EVP_DigestSignFinal(m_impl->ctx,
nullptr, &sigLen) != 1)
72 auto buffer = make_unique<OBuffer>(
sigLen);
73 if (EVP_DigestSignFinal(m_impl->ctx, buffer->data(), &
sigLen) != 1)
76 buffer->erase(buffer->begin() +
sigLen, buffer->end());
85 return make_unique<SignerFilter>(algo, key);