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

Side by Side 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, 4 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 unified diff | Download patch
« no previous file with comments | « secure_blob.h ('k') | tpm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "secure_blob.h"
6
7 namespace tpm_init {
8
9 SecureBlob::SecureBlob()
10 : chromeos::Blob() {
11 }
12
13 SecureBlob::SecureBlob(chromeos::Blob::const_iterator begin,
14 chromeos::Blob::const_iterator end)
15 : chromeos::Blob(begin, end) {
16 }
17
18 SecureBlob::SecureBlob(int size)
19 : chromeos::Blob(size) {
20 }
21
22 SecureBlob::SecureBlob(const unsigned char* from, int from_length)
23 : chromeos::Blob(from_length) {
24 memcpy(data(), from, from_length);
25 }
26
27 SecureBlob::SecureBlob(const char* from, int from_length)
28 : chromeos::Blob(from_length) {
29 memcpy(data(), from, from_length);
30 }
31
32 SecureBlob::~SecureBlob() {
33 chromeos::SecureMemset(&this->front(), 0, this->capacity());
34 }
35
36 void SecureBlob::resize(size_type sz) {
37 if(sz < size()) {
38 chromeos::SecureMemset(&this->at(sz), 0, size() - sz);
39 }
40 chromeos::Blob::resize(sz);
41 }
42
43 void SecureBlob::resize(size_type sz, const SecureBlobElement& x) {
44 if(sz < size()) {
45 chromeos::SecureMemset(&this->at(sz), 0, size() - sz);
46 }
47 chromeos::Blob::resize(sz, x);
48 }
49
50 void SecureBlob::clear_contents() {
51 chromeos::SecureMemset(this->data(), 0, size());
52 }
53
54 void* SecureBlob::data() {
55 return &(this->front());
56 }
57
58 const void* SecureBlob::const_data() const {
59 return &(this->front());
60 }
61
62 } // namespace tpm_init
OLDNEW
« 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