aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQijiang Fan <fqj@google.com>2020-06-30 22:46:47 +0900
committerQijiang Fan <fqj@google.com>2020-06-30 23:20:54 +0900
commit16430c43b2ebe933f5991887f0ff77dd0056b78f (patch)
treeb0f18c5048804eb8187de0a3d0a69effbe293b63
parent690d8d51a6aa5a1c71bfb2f8cb5a957c13be302e (diff)
downloadplatform_external_libbrillo-16430c43b2ebe933f5991887f0ff77dd0056b78f.tar.gz
platform_external_libbrillo-16430c43b2ebe933f5991887f0ff77dd0056b78f.tar.bz2
platform_external_libbrillo-16430c43b2ebe933f5991887f0ff77dd0056b78f.zip
Revert "libbrillo: break SecureAllocator dependence on std::vector<uint8_t>"android-r-beta-3android-r-beta-2
This reverts commit 10f3dc438da6f8ade5c0eb90f9cf894e449fe997. Change-Id: I5231fe6bf31640da9b7dce9d5bf76ae2529ebd2f
-rw-r--r--brillo/secure_blob.cc9
-rw-r--r--brillo/secure_blob.h14
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();