24 #include "ndn-cxx/security/impl/openssl-helper.hpp"
26 #include <boost/lexical_cast.hpp>
30 class SignerFilter::Impl
38 : m_impl(make_unique<Impl>())
40 const EVP_MD* md = detail::digestAlgorithmToEvpMd(algo);
43 boost::lexical_cast<std::string>(algo)));
45 if (EVP_DigestSignInit(m_impl->ctx,
nullptr, md,
nullptr,
46 reinterpret_cast<EVP_PKEY*
>(key.getEvpPkey())) != 1)
48 boost::lexical_cast<std::string>(algo) +
" digest and " +
49 boost::lexical_cast<std::string>(key.
getKeyType()) +
" key"));
55 SignerFilter::convert(span<const uint8_t> buf)
57 if (EVP_DigestSignUpdate(m_impl->ctx, buf.data(), buf.size()) != 1)
64 SignerFilter::finalize()
67 if (EVP_DigestSignFinal(m_impl->ctx,
nullptr, &sigLen) != 1)
70 auto buffer = make_unique<OBuffer>(sigLen);
71 if (EVP_DigestSignFinal(m_impl->ctx, buffer->data(), &sigLen) != 1)
74 buffer->erase(buffer->begin() + sigLen, buffer->end());
83 return make_unique<SignerFilter>(algo, key);