diff options
-rw-r--r-- | brillo/secure_blob.cc | 9 | ||||
-rw-r--r-- | brillo/secure_blob.h | 14 |
2 files changed, 10 insertions, 13 deletions
diff --git a/brillo/secure_blob.cc b/brillo/secure_blob.cc index 0c7026a..70950f6 100644 --- a/brillo/secure_blob.cc +++ b/brillo/secure_blob.cc @@ -54,25 +54,26 @@ SecureBlob::SecureBlob(const std::string& data) : SecureBlob(data.begin(), data.end()) {} SecureBlob::~SecureBlob() { - SecureVector::clear(); + clear(); } void SecureBlob::resize(size_type count) { if (count < size()) { SecureMemset(data() + count, 0, capacity() - count); } - SecureVector::resize(count); + Blob::resize(count); } void SecureBlob::resize(size_type count, const value_type& value) { if (count < size()) { SecureMemset(data() + count, 0, capacity() - count); } - SecureVector::resize(count, value); + Blob::resize(count, value); } void SecureBlob::clear() { - SecureVector::clear(); + SecureMemset(data(), 0, capacity()); + Blob::clear(); } std::string SecureBlob::to_string() const { diff --git a/brillo/secure_blob.h b/brillo/secure_blob.h index e06646d..7705c1a 100644 --- a/brillo/secure_blob.h +++ b/brillo/secure_blob.h @@ -11,16 +11,13 @@ #include <brillo/asan.h> #include <brillo/brillo_export.h> -#include <brillo/secure_allocator.h> namespace brillo { +// TODO(sarthakkukreti): remove temp. SecureVector once we break SecureBlob's +// dependence on std::vector<uint8_t> using Blob = std::vector<uint8_t>; -// Define SecureVector as a vector using a SecureAllocator. -// Over time, the goal is to remove the differentiating functions -// from SecureBlob (to_string(), char_data()) till it converges with -// SecureVector. -using SecureVector = std::vector<uint8_t, SecureAllocator<uint8_t>>; +using SecureVector = std::vector<uint8_t>; // Conversion of Blob to/from std::string, where the string holds raw byte // contents. @@ -32,11 +29,10 @@ BRILLO_EXPORT Blob CombineBlobs(const std::initializer_list<Blob>& blobs); // SecureBlob erases the contents on destruction. It does not guarantee erasure // on resize, assign, etc. -class BRILLO_EXPORT SecureBlob : public SecureVector { +class BRILLO_EXPORT SecureBlob : public Blob { public: SecureBlob() = default; - // Inherit standard constructors from SecureVector. - using SecureVector::vector; + using Blob::vector; // Inherit standard constructors from vector. explicit SecureBlob(const Blob& blob); explicit SecureBlob(const std::string& data); ~SecureBlob(); |