OLD | NEW |
(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 |
OLD | NEW |