OLD | NEW |
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "login_manager/owner_key.h" | 5 #include "login_manager/owner_key.h" |
6 | 6 |
7 #include <base/crypto/rsa_private_key.h> | 7 #include <base/crypto/rsa_private_key.h> |
8 #include <base/file_path.h> | 8 #include <base/file_path.h> |
9 #include <base/file_util.h> | 9 #include <base/file_util.h> |
10 #include <base/logging.h> | 10 #include <base/logging.h> |
(...skipping 26 matching lines...) Expand all Loading... |
37 bool OwnerKey::Equals(const std::string& key_der) const { | 37 bool OwnerKey::Equals(const std::string& key_der) const { |
38 return VEquals(std::vector<uint8>(key_der.c_str(), | 38 return VEquals(std::vector<uint8>(key_der.c_str(), |
39 key_der.c_str() + key_der.length())); | 39 key_der.c_str() + key_der.length())); |
40 } | 40 } |
41 | 41 |
42 bool OwnerKey::VEquals(const std::vector<uint8>& key_der) const { | 42 bool OwnerKey::VEquals(const std::vector<uint8>& key_der) const { |
43 return ((key_.empty() == key_der.empty()) && | 43 return ((key_.empty() == key_der.empty()) && |
44 memcmp(&key_der[0], &key_[0], key_.size()) == 0); | 44 memcmp(&key_der[0], &key_[0], key_.size()) == 0); |
45 } | 45 } |
46 | 46 |
47 bool OwnerKey::HaveCheckedDisk() { return have_checked_disk_; } | 47 bool OwnerKey::HaveCheckedDisk() const { return have_checked_disk_; } |
48 | 48 |
49 bool OwnerKey::IsPopulated() { return !key_.empty(); } | 49 bool OwnerKey::IsPopulated() const { return !key_.empty(); } |
50 | 50 |
51 bool OwnerKey::PopulateFromDiskIfPossible() { | 51 bool OwnerKey::PopulateFromDiskIfPossible() { |
52 have_checked_disk_ = true; | 52 have_checked_disk_ = true; |
53 if (!file_util::PathExists(key_file_)) { | 53 if (!file_util::PathExists(key_file_)) { |
54 LOG(INFO) << "No owner key on disk."; | 54 LOG(INFO) << "No owner key on disk."; |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 int32 safe_file_size = 0; | 58 int32 safe_file_size = 0; |
59 if (!utils_->EnsureAndReturnSafeFileSize(key_file_, &safe_file_size)) { | 59 if (!utils_->EnsureAndReturnSafeFileSize(key_file_, &safe_file_size)) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 int OwnerKey::StartGeneration(ChildJobInterface* generator) { | 179 int OwnerKey::StartGeneration(ChildJobInterface* generator) { |
180 int pid = fork(); | 180 int pid = fork(); |
181 if (pid == 0) { | 181 if (pid == 0) { |
182 generator->Run(); | 182 generator->Run(); |
183 exit(1); // Run() is not supposed to return. | 183 exit(1); // Run() is not supposed to return. |
184 } | 184 } |
185 return pid; | 185 return pid; |
186 } | 186 } |
187 | 187 |
188 } // namespace login_manager | 188 } // namespace login_manager |
OLD | NEW |