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