summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/cryptohome_client.cc
diff options
context:
space:
mode:
authordkrahn@google.com <dkrahn@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-11 20:13:13 +0000
committerdkrahn@google.com <dkrahn@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-11 20:13:13 +0000
commit81b4dfdc41e5286e15eaef932e19084fc8b6c1b0 (patch)
tree6e3890c074c60133031b5d077271ca576da3a392 /chromeos/dbus/cryptohome_client.cc
parentb219b366186f0d0c7f4451a211d7a6089bbea6fd (diff)
downloadchromium_src-81b4dfdc41e5286e15eaef932e19084fc8b6c1b0.zip
chromium_src-81b4dfdc41e5286e15eaef932e19084fc8b6c1b0.tar.gz
chromium_src-81b4dfdc41e5286e15eaef932e19084fc8b6c1b0.tar.bz2
Added dbus bindings for new cryptohomed attestation APIs.
The new APIs add support for associating arbitrary payloads with keys. Also fixed type mismatches for other recently added attestation APIs. BUG=chromium:219959 TEST=unit Review URL: https://chromiumcodereview.appspot.com/13818032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/cryptohome_client.cc')
-rw-r--r--chromeos/dbus/cryptohome_client.cc76
1 files changed, 67 insertions, 9 deletions
diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc
index 27e8af0..7bcbc4a 100644
--- a/chromeos/dbus/cryptohome_client.cc
+++ b/chromeos/dbus/cryptohome_client.cc
@@ -530,10 +530,12 @@ class CryptohomeClientImpl : public CryptohomeClient {
writer.AppendBool(is_user_specific);
writer.AppendString(key_name);
writer.AppendString(domain);
- writer.AppendString(device_id);
+ writer.AppendArrayOfBytes(reinterpret_cast<const uint8*>(device_id.data()),
+ device_id.size());
bool include_signed_public_key = (options & INCLUDE_SIGNED_PUBLIC_KEY);
writer.AppendBool(include_signed_public_key);
- writer.AppendString(challenge);
+ writer.AppendArrayOfBytes(reinterpret_cast<const uint8*>(challenge.data()),
+ challenge.size());
proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(),
@@ -553,13 +555,50 @@ class CryptohomeClientImpl : public CryptohomeClient {
bool is_user_specific = (key_type == USER_KEY);
writer.AppendBool(is_user_specific);
writer.AppendString(key_name);
- writer.AppendString(challenge);
+ writer.AppendArrayOfBytes(reinterpret_cast<const uint8*>(challenge.data()),
+ challenge.size());
proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(),
callback));
}
+ // CryptohomeClient override.
+ virtual void TpmAttestationGetKeyPayload(
+ AttestationKeyType key_type,
+ const std::string& key_name,
+ const DataMethodCallback& callback) OVERRIDE {
+ dbus::MethodCall method_call(
+ cryptohome::kCryptohomeInterface,
+ cryptohome::kCryptohomeTpmAttestationGetKeyPayload);
+ dbus::MessageWriter writer(&method_call);
+ bool is_user_specific = (key_type == USER_KEY);
+ writer.AppendBool(is_user_specific);
+ writer.AppendString(key_name);
+ proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&CryptohomeClientImpl::OnDataMethod,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+ }
+
+ // CryptohomeClient override.
+ virtual void TpmAttestationSetKeyPayload(
+ AttestationKeyType key_type,
+ const std::string& key_name,
+ const std::string& payload,
+ const BoolDBusMethodCallback& callback) OVERRIDE {
+ dbus::MethodCall method_call(
+ cryptohome::kCryptohomeInterface,
+ cryptohome::kCryptohomeTpmAttestationSetKeyPayload);
+ dbus::MessageWriter writer(&method_call);
+ bool is_user_specific = (key_type == USER_KEY);
+ writer.AppendBool(is_user_specific);
+ writer.AppendString(key_name);
+ writer.AppendArrayOfBytes(reinterpret_cast<const uint8*>(payload.data()),
+ payload.size());
+ CallBoolMethod(&method_call, callback);
+ }
+
private:
// Handles the result of AsyncXXX methods.
void OnAsyncMethodCall(const AsyncMethodCallback& callback,
@@ -654,16 +693,15 @@ class CryptohomeClientImpl : public CryptohomeClient {
return;
}
dbus::MessageReader reader(response);
+ uint8* data_buffer = NULL;
+ size_t data_length = 0;
bool result = false;
- if (!reader.PopBool(&result)) {
- callback.Run(DBUS_METHOD_CALL_FAILURE, false, std::string());
- return;
- }
- std::string data;
- if (!reader.PopString(&data)) {
+ if (!reader.PopArrayOfBytes(&data_buffer, &data_length) ||
+ !reader.PopBool(&result)) {
callback.Run(DBUS_METHOD_CALL_FAILURE, false, std::string());
return;
}
+ std::string data(reinterpret_cast<char*>(data_buffer), data_length);
callback.Run(DBUS_METHOD_CALL_SUCCESS, result, data);
}
@@ -1070,6 +1108,26 @@ class CryptohomeClientStubImpl : public CryptohomeClient {
ReturnAsyncMethodResult(callback, true);
}
+ virtual void TpmAttestationGetKeyPayload(
+ AttestationKeyType key_type,
+ const std::string& key_name,
+ const DataMethodCallback& callback) OVERRIDE {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string()));
+ }
+
+ virtual void TpmAttestationSetKeyPayload(
+ AttestationKeyType key_type,
+ const std::string& key_name,
+ const std::string& payload,
+ const BoolDBusMethodCallback& callback) OVERRIDE {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false));
+ }
+
+
private:
// Posts tasks which return fake results to the UI thread.
void ReturnAsyncMethodResult(const AsyncMethodCallback& callback,