7#ifndef BOTAN_MEM_UTILS_H_
8#define BOTAN_MEM_UTILS_H_
10#include <botan/types.h>
36template <std::
unsigned_
integral T>
39 std::memset(buf, 0,
sizeof(T) * n);
43template <std::
unsigned_
integral T>
45 if(in !=
nullptr && out !=
nullptr && n > 0) {
46 std::memmove(out, in,
sizeof(T) * n);
53template <
typename... Ptrs>
55 static_assert((... && std::is_pointer_v<Ptrs>),
"All arguments must be pointers");
56 return (... || (ptr ==
nullptr));
60 const uint8_t* b =
reinterpret_cast<const uint8_t*
>(s);
61 return std::span{b, len};
77 return std::string(
reinterpret_cast<const char*
>(bytes.data()), bytes.size());
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
std::string bytes_to_string(std::span< const uint8_t > bytes)
void zeroize_buffer(T buf[], size_t n)
std::span< const uint8_t > cstr_as_span_of_bytes(const char *s)
void unchecked_copy_memory(T *out, const T *in, size_t n)
void secure_zeroize_buffer(void *ptr, size_t n)
bool any_null_pointers(Ptrs... ptr)