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

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