23 #include "ndn-cxx/security/impl/openssl.hpp" 33 class Base64Encode::Impl
37 : m_base64(BIO_new(BIO_f_base64()))
38 , m_sink(BIO_new(BIO_s_mem()))
41 BIO_push(m_base64, m_sink);
46 BIO_free_all(m_base64);
55 : m_impl(make_unique<Impl>())
58 BIO_set_flags(m_impl->m_base64, BIO_FLAGS_BASE64_NO_NL);
64 Base64Encode::preTransform()
70 Base64Encode::convert(
const uint8_t* data,
size_t dataLen)
75 int wLen = BIO_write(m_impl->m_base64, data, dataLen);
78 if (!BIO_should_retry(m_impl->m_base64)) {
91 Base64Encode::finalize()
93 if (BIO_flush(m_impl->m_base64) != 1)
96 while (!isConverterEmpty()) {
105 Base64Encode::fillOutputBuffer()
107 int nRead = BIO_pending(m_impl->m_sink);
112 auto buffer = make_unique<OBuffer>(nRead);
113 int rLen = BIO_read(m_impl->m_sink, buffer->data(), nRead);
118 buffer->erase(buffer->begin() + rLen, buffer->end());
123 Base64Encode::isConverterEmpty()
125 return (BIO_pending(m_impl->m_sink) <= 0);
128 unique_ptr<Transform>
131 return make_unique<Base64Encode>(needBreak);