Boost C++ Libraries: Ticket #13312: boost::locale::conv and secure memory buffers https://svn.boost.org/trac10/ticket/13312 <p> Sometimes it is useful to convert passwords from one encoding to another to guess the right encoding (for example to import certificates which have been exported with broken software). </p> <p> For such (and maybe other cases) it would be nice if from_utf and to_utf had an option to specify the output memory buffer. I guess this would be best done via a template specialization. </p> <p> I realize that this is a somewhat obscure concern. The benefit of trying to keep a password in secure memory is discussed even among experts. There are many other places higher (pipes, keyboard buffers) and lower (cpu caches) in the stack where password traces can remain. On the other hand, scanning the swap space for key material and passwords in the clear is a basic security check. For me, this is something that should be fixed if it is easy to do. </p> <p> Right now, I am using this pattern, which at best relies on RVO and leaves a small race: </p> <pre class="wiki"> std::string convertedpw_ = boost::locale::conv::from_utf&lt;char&gt;(password, charset); Botan::secure_vector&lt;uint8_t&gt; convertedpw(convertedpw_.size()); memcpy(convertedpw.data(), convertedpw_.data(), convertedpw_.size()); /* Best effort. */ Botan::secure_scrub_memory((void *)convertedpw_.data(), convertedpw_.size()); </pre><p> Anyway, thanks a lot for a great library! </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13312 Trac 1.4.3