SensitiveData::SensitiveData(std::string&& data) :
d_data(std::move(data))
{
+#ifdef HAVE_LIBSODIUM
+ // let's be nice and try to zero out the SSO buffer
+ sodium_memzero(data.data(), data.capacity());
+#endif
data.clear();
#ifdef HAVE_LIBSODIUM
sodium_mlock(d_data.data(), d_data.size());
void SensitiveData::clear()
{
#ifdef HAVE_LIBSODIUM
+ // let's be nice and try to zero out the SSO buffer (be careful, sodium_munlock will zero out the current size
+ // which might be zero if the object was moved)
+ sodium_memzero(d_data.data(), d_data.capacity());
sodium_munlock(d_data.data(), d_data.size());
#endif
d_data.clear();