23 #include "../detail/openssl.hpp"
34 ,
m_md(BIO_new(BIO_f_md()))
35 ,
m_sink(BIO_new(BIO_s_null()))
58 const uint8_t* sig,
size_t sigLen)
59 : m_impl(new
Impl(key, sig, sigLen))
63 if (!BIO_set_md(m_impl->m_md, EVP_sha256()))
64 BOOST_THROW_EXCEPTION(
Error(
getIndex(),
"Cannot set digest"));
69 BOOST_THROW_EXCEPTION(
Error(
getIndex(),
"Digest algorithm is not supported"));
74 VerifierFilter::convert(
const uint8_t* buf,
size_t size)
76 int wLen = BIO_write(m_impl->m_md, buf, size);
79 if (!BIO_should_retry(m_impl->m_md)) {
81 BOOST_THROW_EXCEPTION(
Error(
getIndex(),
"Failed to accept more input"));
91 VerifierFilter::finalize()
93 EVP_PKEY* key =
reinterpret_cast<EVP_PKEY*
>(m_impl->m_key.getEvpPkey());
94 auto buffer = make_unique<OBuffer>(1);
96 EVP_MD_CTX* ctx =
nullptr;
97 BIO_get_md_ctx(m_impl->m_md, &ctx);
98 int res = EVP_VerifyFinal(ctx, m_impl->m_sig, m_impl->m_sigLen, key);
101 BOOST_THROW_EXCEPTION(Error(
getIndex(),
"Verification error"));
103 (*buffer)[0] = (res != 0) ? 1 : 0;
109 unique_ptr<Transform>
111 const uint8_t* sig,
size_t sigLen)
113 return make_unique<VerifierFilter>(algo, key, sig, sigLen);
Copyright (c) 2013-2016 Regents of the University of California.
Use the SHA256 hash of the public key as the key id.