OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "chrome/browser/chromeos/settings/owner_key_util.h" | 5 #include "chrome/browser/chromeos/settings/owner_key_util.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/sys_info.h" |
13 #include "chromeos/chromeos_paths.h" | 14 #include "chromeos/chromeos_paths.h" |
14 #include "crypto/rsa_private_key.h" | 15 #include "crypto/rsa_private_key.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 /////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////// |
19 // PublicKey | 20 // PublicKey |
20 | 21 |
21 PublicKey::PublicKey() { | 22 PublicKey::PublicKey() { |
22 } | 23 } |
(...skipping 28 matching lines...) Expand all Loading... |
51 | 52 |
52 OwnerKeyUtilImpl::OwnerKeyUtilImpl(const base::FilePath& key_file) | 53 OwnerKeyUtilImpl::OwnerKeyUtilImpl(const base::FilePath& key_file) |
53 : key_file_(key_file) {} | 54 : key_file_(key_file) {} |
54 | 55 |
55 OwnerKeyUtilImpl::~OwnerKeyUtilImpl() {} | 56 OwnerKeyUtilImpl::~OwnerKeyUtilImpl() {} |
56 | 57 |
57 bool OwnerKeyUtilImpl::ImportPublicKey(std::vector<uint8>* output) { | 58 bool OwnerKeyUtilImpl::ImportPublicKey(std::vector<uint8>* output) { |
58 // Get the file size (must fit in a 32 bit int for NSS). | 59 // Get the file size (must fit in a 32 bit int for NSS). |
59 int64 file_size; | 60 int64 file_size; |
60 if (!base::GetFileSize(key_file_, &file_size)) { | 61 if (!base::GetFileSize(key_file_, &file_size)) { |
61 LOG(ERROR) << "Could not get size of " << key_file_.value(); | 62 LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS()) |
| 63 << "Could not get size of " << key_file_.value(); |
62 return false; | 64 return false; |
63 } | 65 } |
64 if (file_size > static_cast<int64>(std::numeric_limits<int>::max())) { | 66 if (file_size > static_cast<int64>(std::numeric_limits<int>::max())) { |
65 LOG(ERROR) << key_file_.value() << "is " | 67 LOG(ERROR) << key_file_.value() << "is " |
66 << file_size << "bytes!!! Too big!"; | 68 << file_size << "bytes!!! Too big!"; |
67 return false; | 69 return false; |
68 } | 70 } |
69 int32 safe_file_size = static_cast<int32>(file_size); | 71 int32 safe_file_size = static_cast<int32>(file_size); |
70 | 72 |
71 output->resize(safe_file_size); | 73 output->resize(safe_file_size); |
(...skipping 15 matching lines...) Expand all Loading... |
87 const std::vector<uint8>& key, | 89 const std::vector<uint8>& key, |
88 PK11SlotInfo* slot) { | 90 PK11SlotInfo* slot) { |
89 return crypto::RSAPrivateKey::FindFromPublicKeyInfoInSlot(key, slot); | 91 return crypto::RSAPrivateKey::FindFromPublicKeyInfoInSlot(key, slot); |
90 } | 92 } |
91 | 93 |
92 bool OwnerKeyUtilImpl::IsPublicKeyPresent() { | 94 bool OwnerKeyUtilImpl::IsPublicKeyPresent() { |
93 return base::PathExists(key_file_); | 95 return base::PathExists(key_file_); |
94 } | 96 } |
95 | 97 |
96 } // namespace chromeos | 98 } // namespace chromeos |
OLD | NEW |