| 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 "remoting/host/host_key_pair.h" | 5 #include "remoting/host/host_key_pair.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 std::vector<uint8> key_buf(key_str.begin(), key_str.end()); | 37 std::vector<uint8> key_buf(key_str.begin(), key_str.end()); |
| 38 key_.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_buf)); | 38 key_.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_buf)); |
| 39 if (key_.get() == NULL) { | 39 if (key_.get() == NULL) { |
| 40 LOG(ERROR) << "Invalid private key."; | 40 LOG(ERROR) << "Invalid private key."; |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 | 43 |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool HostKeyPair::Load(HostConfig* host_config) { | 47 bool HostKeyPair::Load(const HostConfig& host_config) { |
| 48 std::string key_base64; | 48 std::string key_base64; |
| 49 if (!host_config->GetString(kPrivateKeyConfigPath, &key_base64)) { | 49 if (!host_config.GetString(kPrivateKeyConfigPath, &key_base64)) { |
| 50 LOG(ERROR) << "Private key wasn't found in the config file."; | 50 LOG(ERROR) << "Private key wasn't found in the config file."; |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 return LoadFromString(key_base64); | 53 return LoadFromString(key_base64); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void HostKeyPair::Save(MutableHostConfig* host_config) { | 56 void HostKeyPair::Save(MutableHostConfig* host_config) { |
| 57 host_config->SetString(kPrivateKeyConfigPath, GetAsString()); | 57 host_config->SetString(kPrivateKeyConfigPath, GetAsString()); |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 base::RandInt(1, std::numeric_limits<int>::max()), | 106 base::RandInt(1, std::numeric_limits<int>::max()), |
| 107 base::TimeDelta::FromDays(1)); | 107 base::TimeDelta::FromDays(1)); |
| 108 std::string encoded; | 108 std::string encoded; |
| 109 bool result = net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), | 109 bool result = net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), |
| 110 &encoded); | 110 &encoded); |
| 111 CHECK(result); | 111 CHECK(result); |
| 112 return encoded; | 112 return encoded; |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace remoting | 115 } // namespace remoting |
| OLD | NEW |