OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return false; | 48 return false; |
49 } | 49 } |
50 return LoadFromString(key_base64); | 50 return LoadFromString(key_base64); |
51 } | 51 } |
52 | 52 |
53 void HostKeyPair::Save(MutableHostConfig* host_config) { | 53 void HostKeyPair::Save(MutableHostConfig* host_config) { |
54 // Check that the key initialized. | 54 // Check that the key initialized. |
55 DCHECK(key_.get() != NULL); | 55 DCHECK(key_.get() != NULL); |
56 | 56 |
57 host_config->Update( | 57 host_config->Update( |
58 NewRunnableMethod(this, | 58 NewRunnableMethod(this, &HostKeyPair::DoSave, host_config)); |
59 &HostKeyPair::DoSave, | |
60 make_scoped_refptr(host_config))); | |
61 } | 59 } |
62 | 60 |
63 void HostKeyPair::DoSave(MutableHostConfig* host_config) const { | 61 void HostKeyPair::DoSave(MutableHostConfig* host_config) const { |
64 std::vector<uint8> key_buf; | 62 std::vector<uint8> key_buf; |
65 key_->ExportPrivateKey(&key_buf); | 63 key_->ExportPrivateKey(&key_buf); |
66 std::string key_str(key_buf.begin(), key_buf.end()); | 64 std::string key_str(key_buf.begin(), key_buf.end()); |
67 std::string key_base64; | 65 std::string key_base64; |
68 base::Base64Encode(key_str, &key_base64); | 66 base::Base64Encode(key_str, &key_base64); |
69 host_config->SetString(kPrivateKeyConfigPath, key_base64); | 67 host_config->SetString(kPrivateKeyConfigPath, key_base64); |
70 } | 68 } |
(...skipping 14 matching lines...) Expand all Loading... |
85 message.length()); | 83 message.length()); |
86 std::vector<uint8> signature_buf; | 84 std::vector<uint8> signature_buf; |
87 signature_creator->Final(&signature_buf); | 85 signature_creator->Final(&signature_buf); |
88 std::string signature_str(signature_buf.begin(), signature_buf.end()); | 86 std::string signature_str(signature_buf.begin(), signature_buf.end()); |
89 std::string signature_base64; | 87 std::string signature_base64; |
90 base::Base64Encode(signature_str, &signature_base64); | 88 base::Base64Encode(signature_str, &signature_base64); |
91 return signature_base64; | 89 return signature_base64; |
92 } | 90 } |
93 | 91 |
94 } // namespace remoting | 92 } // namespace remoting |
OLD | NEW |