OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/dbus/easy_unlock_client.h" | 5 #include "chromeos/dbus/easy_unlock_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 easy_unlock::kEasyUnlockServiceInterface, | 67 easy_unlock::kEasyUnlockServiceInterface, |
68 easy_unlock::kGenerateEcP256KeyPairMethod); | 68 easy_unlock::kGenerateEcP256KeyPairMethod); |
69 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 69 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
70 base::Bind(&EasyUnlockClientImpl::OnKeyPair, | 70 base::Bind(&EasyUnlockClientImpl::OnKeyPair, |
71 weak_ptr_factory_.GetWeakPtr(), | 71 weak_ptr_factory_.GetWeakPtr(), |
72 callback)); | 72 callback)); |
73 } | 73 } |
74 | 74 |
75 // EasyUnlockClient override. | 75 // EasyUnlockClient override. |
76 virtual void CreateSecureMessage(const std::string& payload, | 76 virtual void CreateSecureMessage(const std::string& payload, |
77 const CreateSecureMessageOptions& options, | 77 const std::string& secret_key, |
| 78 const std::string& associated_data, |
| 79 const std::string& public_metadata, |
| 80 const std::string& verification_key_id, |
| 81 const std::string& decryption_key_id, |
| 82 const std::string& encryption_type, |
| 83 const std::string& signature_type, |
78 const DataCallback& callback) OVERRIDE { | 84 const DataCallback& callback) OVERRIDE { |
79 dbus::MethodCall method_call( | 85 dbus::MethodCall method_call( |
80 easy_unlock::kEasyUnlockServiceInterface, | 86 easy_unlock::kEasyUnlockServiceInterface, |
81 easy_unlock::kCreateSecureMessageMethod); | 87 easy_unlock::kCreateSecureMessageMethod); |
82 dbus::MessageWriter writer(&method_call); | 88 dbus::MessageWriter writer(&method_call); |
83 // NOTE: DBus expects that data sent as string is UTF-8 encoded. This is | 89 // NOTE: DBus expects that data sent as string is UTF-8 encoded. This is |
84 // not guaranteed here, so the method uses byte arrays. | 90 // not guaranteed here, so the method uses byte arrays. |
85 AppendStringAsByteArray(payload, &writer); | 91 AppendStringAsByteArray(payload, &writer); |
86 AppendStringAsByteArray(options.key, &writer); | 92 AppendStringAsByteArray(secret_key, &writer); |
87 AppendStringAsByteArray(options.associated_data, &writer); | 93 AppendStringAsByteArray(associated_data, &writer); |
88 AppendStringAsByteArray(options.public_metadata, &writer); | 94 AppendStringAsByteArray(public_metadata, &writer); |
89 AppendStringAsByteArray(options.verification_key_id, &writer); | 95 AppendStringAsByteArray(verification_key_id, &writer); |
90 AppendStringAsByteArray(options.decryption_key_id, &writer); | 96 AppendStringAsByteArray(decryption_key_id, &writer); |
91 writer.AppendString(options.encryption_type); | 97 writer.AppendString(encryption_type); |
92 writer.AppendString(options.signature_type); | 98 writer.AppendString(signature_type); |
93 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 99 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
94 base::Bind(&EasyUnlockClientImpl::OnData, | 100 base::Bind(&EasyUnlockClientImpl::OnData, |
95 weak_ptr_factory_.GetWeakPtr(), | 101 weak_ptr_factory_.GetWeakPtr(), |
96 callback)); | 102 callback)); |
97 } | 103 } |
98 | 104 |
99 // EasyUnlockClient override. | 105 // EasyUnlockClient override. |
100 virtual void UnwrapSecureMessage(const std::string& message, | 106 virtual void UnwrapSecureMessage(const std::string& message, |
101 const UnwrapSecureMessageOptions& options, | 107 const std::string& secret_key, |
| 108 const std::string& associated_data, |
| 109 const std::string& encryption_type, |
| 110 const std::string& signature_type, |
102 const DataCallback& callback) OVERRIDE { | 111 const DataCallback& callback) OVERRIDE { |
103 dbus::MethodCall method_call( | 112 dbus::MethodCall method_call( |
104 easy_unlock::kEasyUnlockServiceInterface, | 113 easy_unlock::kEasyUnlockServiceInterface, |
105 easy_unlock::kUnwrapSecureMessageMethod); | 114 easy_unlock::kUnwrapSecureMessageMethod); |
106 dbus::MessageWriter writer(&method_call); | 115 dbus::MessageWriter writer(&method_call); |
107 // NOTE: DBus expects that data sent as string is UTF-8 encoded. This is | 116 // NOTE: DBus expects that data sent as string is UTF-8 encoded. This is |
108 // not guaranteed here, so the method uses byte arrays. | 117 // not guaranteed here, so the method uses byte arrays. |
109 AppendStringAsByteArray(message, &writer); | 118 AppendStringAsByteArray(message, &writer); |
110 AppendStringAsByteArray(options.key, &writer); | 119 AppendStringAsByteArray(secret_key, &writer); |
111 AppendStringAsByteArray(options.associated_data, &writer); | 120 AppendStringAsByteArray(associated_data, &writer); |
112 writer.AppendString(options.encryption_type); | 121 writer.AppendString(encryption_type); |
113 writer.AppendString(options.signature_type); | 122 writer.AppendString(signature_type); |
114 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 123 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
115 base::Bind(&EasyUnlockClientImpl::OnData, | 124 base::Bind(&EasyUnlockClientImpl::OnData, |
116 weak_ptr_factory_.GetWeakPtr(), | 125 weak_ptr_factory_.GetWeakPtr(), |
117 callback)); | 126 callback)); |
118 } | 127 } |
119 | 128 |
120 protected: | 129 protected: |
121 virtual void Init(dbus::Bus* bus) OVERRIDE { | 130 virtual void Init(dbus::Bus* bus) OVERRIDE { |
122 proxy_ = | 131 proxy_ = |
123 bus->GetObjectProxy( | 132 bus->GetObjectProxy( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 167 |
159 // Note: This should remain the last member so it'll be destroyed and | 168 // Note: This should remain the last member so it'll be destroyed and |
160 // invalidate its weak pointers before any other members are destroyed. | 169 // invalidate its weak pointers before any other members are destroyed. |
161 base::WeakPtrFactory<EasyUnlockClientImpl> weak_ptr_factory_; | 170 base::WeakPtrFactory<EasyUnlockClientImpl> weak_ptr_factory_; |
162 | 171 |
163 DISALLOW_COPY_AND_ASSIGN(EasyUnlockClientImpl); | 172 DISALLOW_COPY_AND_ASSIGN(EasyUnlockClientImpl); |
164 }; | 173 }; |
165 | 174 |
166 } // namespace | 175 } // namespace |
167 | 176 |
168 EasyUnlockClient::CreateSecureMessageOptions::CreateSecureMessageOptions() {} | |
169 | |
170 EasyUnlockClient::CreateSecureMessageOptions::~CreateSecureMessageOptions() {} | |
171 | |
172 EasyUnlockClient::UnwrapSecureMessageOptions::UnwrapSecureMessageOptions() {} | |
173 | |
174 EasyUnlockClient::UnwrapSecureMessageOptions::~UnwrapSecureMessageOptions() {} | |
175 | |
176 EasyUnlockClient::EasyUnlockClient() { | 177 EasyUnlockClient::EasyUnlockClient() { |
177 } | 178 } |
178 | 179 |
179 EasyUnlockClient::~EasyUnlockClient() { | 180 EasyUnlockClient::~EasyUnlockClient() { |
180 } | 181 } |
181 | 182 |
182 // static | 183 // static |
183 EasyUnlockClient* EasyUnlockClient::Create() { | 184 EasyUnlockClient* EasyUnlockClient::Create() { |
184 return new EasyUnlockClientImpl(); | 185 return new EasyUnlockClientImpl(); |
185 } | 186 } |
186 | 187 |
187 } // namespace chromeos | 188 } // namespace chromeos |
OLD | NEW |