Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1566)

Unified Diff: secure_blob.cc

Issue 2645008: Update on feedback, update dbus API, add unit tests. TEST=manual,unit,BVT BUG=3628 323 (Closed) Base URL: ssh://git@chromiumos-git/cryptohome.git
Patch Set: Address second round of feedback. Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « secure_blob.h ('k') | secure_blob_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: secure_blob.cc
diff --git a/secure_blob.cc b/secure_blob.cc
index 4f30d1f6b4fb958584ebed303f9ff8da411e6c1c..cb9d3d6a48f97ba86b359f400d71ef8fce1b6dd8 100644
--- a/secure_blob.cc
+++ b/secure_blob.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cryptohome/secure_blob.h"
+#include "secure_blob.h"
namespace cryptohome {
@@ -19,22 +19,40 @@ SecureBlob::SecureBlob(int size)
: chromeos::Blob(size) {
}
+SecureBlob::SecureBlob(const unsigned char* from, int from_length)
+ : chromeos::Blob(from_length) {
+ memcpy(data(), from, from_length);
+}
+
+SecureBlob::SecureBlob(const char* from, int from_length)
+ : chromeos::Blob(from_length) {
+ memcpy(data(), from, from_length);
+}
+
SecureBlob::~SecureBlob() {
- chromeos::SecureMemset(&this->front(), this->capacity(), 0);
+ chromeos::SecureMemset(&this->front(), 0, this->capacity());
}
void SecureBlob::resize(size_type sz) {
if(sz < size()) {
- chromeos::SecureMemset(&this->at(sz), size() - sz, 0);
+ chromeos::SecureMemset(&this->at(sz), 0, size() - sz);
}
chromeos::Blob::resize(sz);
}
void SecureBlob::resize(size_type sz, const SecureBlobElement& x) {
if(sz < size()) {
- chromeos::SecureMemset(&this->at(sz), size() - sz, 0);
+ chromeos::SecureMemset(&this->at(sz), 0, size() - sz);
}
chromeos::Blob::resize(sz, x);
}
-} // cryptohome
+void* SecureBlob::data() {
+ return &(this->front());
+}
+
+const void* SecureBlob::const_data() const {
+ return &(this->front());
+}
+
+} // namespace cryptohome
« no previous file with comments | « secure_blob.h ('k') | secure_blob_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698