From 16430c43b2ebe933f5991887f0ff77dd0056b78f Mon Sep 17 00:00:00 2001 From: Qijiang Fan Date: Tue, 30 Jun 2020 22:46:47 +0900 Subject: Revert "libbrillo: break SecureAllocator dependence on std::vector" This reverts commit 10f3dc438da6f8ade5c0eb90f9cf894e449fe997. Change-Id: I5231fe6bf31640da9b7dce9d5bf76ae2529ebd2f --- brillo/secure_blob.cc | 9 +++++---- 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 #include -#include namespace brillo { +// TODO(sarthakkukreti): remove temp. SecureVector once we break SecureBlob's +// dependence on std::vector using Blob = std::vector; -// 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>; +using SecureVector = std::vector; // 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& 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(); -- cgit v1.2.3