24 #include "../detail/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)
52 const EVP_MD* md = detail::digestAlgorithmToEvpMd(algo);
54 BOOST_THROW_EXCEPTION(
Error(
getIndex(),
"Unsupported digest algorithm " +
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)
59 BOOST_THROW_EXCEPTION(
Error(
getIndex(),
"Failed to initialize verification context with " +
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)
70 BOOST_THROW_EXCEPTION(
Error(
getIndex(),
"Failed to accept more input"));
76 VerifierFilter::finalize()
78 int res = EVP_DigestVerifyFinal(m_impl->ctx,
79 #
if OPENSSL_VERSION_NUMBER < 0x1000200fL
80 const_cast<uint8_t*>(m_impl->sig),
86 auto buffer = make_unique<OBuffer>(1);
87 (*buffer)[0] = (res == 1) ? 1 : 0;
95 const uint8_t* sig,
size_t sigLen)
97 return make_unique<VerifierFilter>(algo, key, sig, sigLen);
Copyright (c) 2013-2017 Regents of the University of California.
unique_ptr< T > make_unique(Args &&...args)