Move SecureString class to ipmid/types.hpp

SecureString class doesn't have access in user_library to use in
other files

Tested:
Added class to ipmid/types.hpp from user_channel/user_mgmt.hpp
Build got successful.

Signed-off-by: Snehalatha Venkatesh <snehalathax.v@intel.com>
Change-Id: I5e0c4bb0744113e70540b272f16a5116421048fb
diff --git a/include/ipmid/types.hpp b/include/ipmid/types.hpp
index 0e15e85..6eec66b 100644
--- a/include/ipmid/types.hpp
+++ b/include/ipmid/types.hpp
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <openssl/crypto.h>
 #include <stdint.h>
 
 #include <map>
@@ -237,4 +238,32 @@
 
 } // namespace network
 
+template <typename T>
+class SecureAllocator : public std::allocator<T>
+{
+  public:
+    template <typename U>
+    struct rebind
+    {
+        typedef SecureAllocator<U> other;
+    };
+
+    void deallocate(T* p, size_t n)
+    {
+        OPENSSL_cleanse(p, n);
+        return std::allocator<T>::deallocate(p, n);
+    }
+};
+using SecureString =
+    std::basic_string<char, std::char_traits<char>, SecureAllocator<char>>;
+
 } // namespace ipmi
+namespace std
+{
+
+template <>
+inline ipmi::SecureString::~SecureString()
+{
+    OPENSSL_cleanse(&((*this)[0]), this->size());
+}
+} // namespace std