diff options
author | Qijiang Fan <fqj@google.com> | 2020-07-01 03:07:01 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-07-01 03:07:01 +0000 |
commit | 6d64bb179eb63eef9a0b8b45b8e48aa16c91b3d7 (patch) | |
tree | b0f18c5048804eb8187de0a3d0a69effbe293b63 | |
parent | 7a76d80e7f7dd8b9b2784f9adb3bae7e834e4828 (diff) | |
parent | 16430c43b2ebe933f5991887f0ff77dd0056b78f (diff) | |
download | libbrillo-6d64bb179eb63eef9a0b8b45b8e48aa16c91b3d7.tar.gz |
Revert "libbrillo: break SecureAllocator dependence on std::vector<uint8_t>" am: 16430c43b2
Original change: https://android-review.googlesource.com/c/platform/external/libbrillo/+/1353564
Change-Id: Id071ec07cf52b71d1de6a54b3e07dcb9a81ebe92
-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(); |