8 #ifndef BOTAN_SECURE_MEMORY_BUFFERS_H_
9 #define BOTAN_SECURE_MEMORY_BUFFERS_H_
11 #include <botan/types.h>
12 #include <botan/mem_ops.h>
16 #include <type_traits>
31 #if !defined(_ITERATOR_DEBUG_LEVEL) || _ITERATOR_DEBUG_LEVEL == 0
32 static_assert(std::is_integral<T>::value,
"secure_allocator supports only integer types");
57 template<
typename T,
typename U>
inline bool
61 template<
typename T,
typename U>
inline bool
65 template<
typename T>
using secure_vector = std::vector<T, secure_allocator<T>>;
66 template<
typename T>
using secure_deque = std::deque<T, secure_allocator<T>>;
74 return std::vector<T>(in.begin(), in.end());
77 template<
typename T,
typename Alloc,
typename Alloc2>
78 std::vector<T, Alloc>&
80 const std::vector<T, Alloc2>& in)
82 out.reserve(out.size() + in.size());
83 out.insert(out.end(), in.begin(), in.end());
87 template<
typename T,
typename Alloc>
88 std::vector<T, Alloc>&
operator+=(std::vector<T, Alloc>& out,
T in)
94 template<
typename T,
typename Alloc,
typename L>
95 std::vector<T, Alloc>&
operator+=(std::vector<T, Alloc>& out,
96 const std::pair<const T*, L>& in)
98 out.reserve(out.size() + in.second);
99 out.insert(out.end(), in.first, in.first + in.second);
103 template<
typename T,
typename Alloc,
typename L>
104 std::vector<T, Alloc>&
operator+=(std::vector<T, Alloc>& out,
105 const std::pair<T*, L>& in)
107 out.reserve(out.size() + in.second);
108 out.insert(out.end(), in.first, in.first + in.second);
116 template<
typename T,
typename Alloc>
126 template<
typename T,
typename Alloc>
127 void zap(std::vector<T, Alloc>& vec)
void deallocate(T *p, std::size_t n)
bool operator!=(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
void zap(std::vector< T, Alloc > &vec)
BOTAN_MALLOC_FN void * allocate_memory(size_t elems, size_t elem_size)
void clear_mem(T *ptr, size_t n)
T * allocate(std::size_t n)
std::deque< T, secure_allocator< T >> secure_deque
secure_allocator() noexcept=default
std::vector< T, secure_allocator< T >> secure_vector
secure_vector< T > SecureVector
void deallocate_memory(void *p, size_t elems, size_t elem_size)
std::vector< T, Alloc > & operator+=(std::vector< T, Alloc > &out, const std::vector< T, Alloc2 > &in)
std::vector< T > unlock(const secure_vector< T > &in)
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
void zeroise(std::vector< T, Alloc > &vec)