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

Unified Diff: secure_blob.cc

Issue 3048029: Initial version of tpm_init, a library for taking ownership of the TPM. (Closed) Base URL: ssh://git@chromiumos-git/tpm_init.git
Patch Set: Minor fix to the error code check from TakeOwnership. Created 10 years, 5 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') | tpm.h » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..8802c709d426ed0ce399b9b62c11518d981c309d
--- /dev/null
+++ b/secure_blob.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "secure_blob.h"
+
+namespace tpm_init {
+
+SecureBlob::SecureBlob()
+ : chromeos::Blob() {
+}
+
+SecureBlob::SecureBlob(chromeos::Blob::const_iterator begin,
+ chromeos::Blob::const_iterator end)
+ : chromeos::Blob(begin, end) {
+}
+
+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(), 0, this->capacity());
+}
+
+void SecureBlob::resize(size_type sz) {
+ if(sz < size()) {
+ 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), 0, size() - sz);
+ }
+ chromeos::Blob::resize(sz, x);
+}
+
+void SecureBlob::clear_contents() {
+ chromeos::SecureMemset(this->data(), 0, size());
+}
+
+void* SecureBlob::data() {
+ return &(this->front());
+}
+
+const void* SecureBlob::const_data() const {
+ return &(this->front());
+}
+
+} // namespace tpm_init
« no previous file with comments | « secure_blob.h ('k') | tpm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698