23 #include "ndn-cxx/security/impl/openssl.hpp"
29 class Base64Encode::Impl : boost::noncopyable
33 : m_base64(BIO_new(BIO_f_base64()))
34 , m_sink(BIO_new(BIO_s_mem()))
37 BIO_push(m_base64, m_sink);
42 BIO_free_all(m_base64);
52 : m_impl(make_unique<Impl>())
55 BIO_set_flags(m_impl->m_base64, BIO_FLAGS_BASE64_NO_NL);
61 Base64Encode::preTransform()
67 Base64Encode::convert(span<const uint8_t> data)
72 int wLen = BIO_write(m_impl->m_base64, data.data(), data.size());
75 if (!BIO_should_retry(m_impl->m_base64)) {
88 Base64Encode::finalize()
90 if (BIO_flush(m_impl->m_base64) != 1)
93 while (!isConverterEmpty()) {
102 Base64Encode::fillOutputBuffer()
104 int nRead = BIO_pending(m_impl->m_sink);
109 auto buffer = make_unique<OBuffer>(nRead);
110 int rLen = BIO_read(m_impl->m_sink, buffer->data(), nRead);
115 buffer->erase(buffer->begin() + rLen, buffer->end());
121 Base64Encode::isConverterEmpty()
123 return BIO_pending(m_impl->m_sink) <= 0;
126 unique_ptr<Transform>
129 return make_unique<Base64Encode>(needBreak);