Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/login/owner_key_utils.h" | 5 #include "chrome/browser/chromeos/login/owner_key_utils.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 if (file_size > static_cast<int64>(std::numeric_limits<int>::max())) { | 118 if (file_size > static_cast<int64>(std::numeric_limits<int>::max())) { |
| 119 LOG(ERROR) << key_file.value() << "is " | 119 LOG(ERROR) << key_file.value() << "is " |
| 120 << file_size << "bytes!!! Too big!"; | 120 << file_size << "bytes!!! Too big!"; |
| 121 return false; | 121 return false; |
| 122 } | 122 } |
| 123 int32 safe_file_size = static_cast<int32>(file_size); | 123 int32 safe_file_size = static_cast<int32>(file_size); |
| 124 | 124 |
| 125 output->resize(safe_file_size); | 125 output->resize(safe_file_size); |
| 126 | |
| 127 if (safe_file_size == 0) { | |
| 128 LOG(WARNING) << "Public key file is empty. This seems wrong."; | |
|
Mattias Nissler (ping if slow)
2012/05/21 16:30:34
nit: Remove "This seems wrong.", it is redundant.
| |
| 129 return false; | |
| 130 } | |
| 131 | |
| 126 // Get the key data off of disk | 132 // Get the key data off of disk |
| 127 int data_read = file_util::ReadFile(key_file, | 133 int data_read = file_util::ReadFile(key_file, |
| 128 reinterpret_cast<char*>(&(output->at(0))), | 134 reinterpret_cast<char*>(&(output->at(0))), |
| 129 safe_file_size); | 135 safe_file_size); |
| 130 return data_read == safe_file_size; | 136 return data_read == safe_file_size; |
| 131 } | 137 } |
| 132 | 138 |
| 133 bool OwnerKeyUtilsImpl::Verify(const std::string& data, | 139 bool OwnerKeyUtilsImpl::Verify(const std::string& data, |
| 134 const std::vector<uint8> signature, | 140 const std::vector<uint8> signature, |
| 135 const std::vector<uint8> public_key) { | 141 const std::vector<uint8> public_key) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 160 crypto::RSAPrivateKey* OwnerKeyUtilsImpl::FindPrivateKey( | 166 crypto::RSAPrivateKey* OwnerKeyUtilsImpl::FindPrivateKey( |
| 161 const std::vector<uint8>& key) { | 167 const std::vector<uint8>& key) { |
| 162 return crypto::RSAPrivateKey::FindFromPublicKeyInfo(key); | 168 return crypto::RSAPrivateKey::FindFromPublicKeyInfo(key); |
| 163 } | 169 } |
| 164 | 170 |
| 165 FilePath OwnerKeyUtilsImpl::GetOwnerKeyFilePath() { | 171 FilePath OwnerKeyUtilsImpl::GetOwnerKeyFilePath() { |
| 166 return FilePath(OwnerKeyUtilsImpl::kOwnerKeyFile); | 172 return FilePath(OwnerKeyUtilsImpl::kOwnerKeyFile); |
| 167 } | 173 } |
| 168 | 174 |
| 169 } // namespace chromeos | 175 } // namespace chromeos |
| OLD | NEW |