Add a SecureBuffer class
SecureBuffer is like SecureString, but a specialization of
std::vector<uint8_t> that cleans up after itself
Tested: Executed various ipmi commands to see that they still work
Change-Id: Ifd255ef682d6e46d981de6a5a294d12f3666698b
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/include/ipmid/types.hpp b/include/ipmid/types.hpp
index 1705335..9c59ea0 100644
--- a/include/ipmid/types.hpp
+++ b/include/ipmid/types.hpp
@@ -259,13 +259,21 @@
using SecureString =
std::basic_string<char, std::char_traits<char>, SecureAllocator<char>>;
+using SecureBuffer = std::vector<uint8_t, SecureAllocator<uint8_t>>;
+
} // namespace ipmi
+
namespace std
{
-
template <>
inline ipmi::SecureString::~SecureString()
{
OPENSSL_cleanse(&((*this)[0]), this->size());
}
+
+template <>
+inline ipmi::SecureBuffer::~SecureBuffer()
+{
+ OPENSSL_cleanse(&((*this)[0]), this->size());
+}
} // namespace std