31 #ifndef LIBHOMEGEAR_BASE_SECUREVECTOR_H 32 #define LIBHOMEGEAR_BASE_SECUREVECTOR_H 45 class SecureVector :
public std::vector<T> {
50 template<
class InputIt>
SecureVector(InputIt first, InputIt last) : std::vector<T>(first, last) {}
56 std::fill(this->begin(), this->end(), 0);
60 if (count <= this->capacity()) {
65 std::vector<uint8_t> newVector;
66 newVector.resize(count);
67 std::copy(this->begin(), this->end(), newVector.begin());
68 this->swap(newVector);
69 std::fill(newVector.begin(), newVector.end(), 0);
73 if (count <= this->capacity()) {
74 this->resize(count, value);
78 std::vector<uint8_t> newVector;
79 newVector.resize(count, value);
80 std::copy(this->begin(), this->end(), newVector.begin());
81 this->swap(newVector);
82 std::fill(newVector.begin(), newVector.end(), 0);
86 std::vector<uint8_t> newVector;
87 newVector.resize(this->size() + other.size());
88 std::copy(other.begin(), other.end(), newVector.begin());
89 std::copy(this->begin(), this->end(), newVector.begin() + other.size());
90 this->swap(newVector);
91 std::fill(newVector.begin(), newVector.end(), 0);
95 std::vector<uint8_t> newVector;
96 newVector.resize(this->size() + other.size());
97 std::copy(this->begin(), this->end(), newVector.begin());
98 std::copy(other.begin(), other.end(), newVector.begin() + this->size());
99 this->swap(newVector);
100 std::fill(newVector.begin(), newVector.end(), 0);
107 #endif //LIBHOMEGEAR_BASE_SECUREVECTOR_H SecureVector(InputIt first, InputIt last)
Definition: SecureVector.h:50
SecureVector()
Definition: SecureVector.h:47
The class only makes sure that the vector is not copyable and the data is zeroed on destruction...
Definition: Io.h:40
Definition: BaseLib.cpp:34
void secureAppend(const SecureVector &other)
Definition: SecureVector.h:94
PVariable value
Definition: UiElements.h:217
SecureVector & operator=(const SecureVector &)=delete
void secureResize(size_t count, const T &value)
Definition: SecureVector.h:72
void securePrepend(const SecureVector &other)
Definition: SecureVector.h:85
void secureResize(size_t count)
Definition: SecureVector.h:59
~SecureVector()
Definition: SecureVector.h:55
SecureVector(size_t count)
Definition: SecureVector.h:48
SecureVector(size_t count, const T &value)
Definition: SecureVector.h:49