Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: chromeos/dbus/cryptohome_client.cc

Issue 26407002: Add support for the Pkcs11GetTpmTokenInfoForUser cryptohome call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/cryptohome_client.h ('k') | chromeos/dbus/fake_cryptohome_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/cryptohome_client.cc
diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc
index cd027e3e6249f3b87329ff5fcff342934f8dc176..86133aea627567cc6da48079400878bb8d489708 100644
--- a/chromeos/dbus/cryptohome_client.cc
+++ b/chromeos/dbus/cryptohome_client.cc
@@ -330,6 +330,23 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
+ virtual void Pkcs11GetTpmTokenInfoForUser(
+ const std::string& user_email,
+ const Pkcs11GetTpmTokenInfoCallback& callback) OVERRIDE {
+ dbus::MethodCall method_call(
+ cryptohome::kCryptohomeInterface,
+ cryptohome::kCryptohomePkcs11GetTpmTokenInfoForUser);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendString(user_email);
+ proxy_->CallMethod(
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(
+ &CryptohomeClientImpl::OnPkcs11GetTpmTokenInfoForUser,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+ }
+
+ // CryptohomeClient override.
virtual bool InstallAttributesGet(const std::string& name,
std::vector<uint8>* value,
bool* successful) OVERRIDE {
@@ -729,6 +746,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
bool result = false;
if (!reader.PopBool(&result)) {
callback.Run(DBUS_METHOD_CALL_FAILURE, false);
+ LOG(ERROR) << "Invalid response: " << response->ToString();
return;
}
callback.Run(DBUS_METHOD_CALL_SUCCESS, result);
@@ -770,21 +788,44 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback.Run(DBUS_METHOD_CALL_SUCCESS, result, data);
}
- // Handles responses for Pkcs11GetTpmtTokenInfo.
+ // Handles responses for Pkcs11GetTpmTokenInfo.
void OnPkcs11GetTpmTokenInfo(const Pkcs11GetTpmTokenInfoCallback& callback,
dbus::Response* response) {
if (!response) {
- callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string());
+ callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string(), -1);
return;
}
dbus::MessageReader reader(response);
std::string label;
std::string user_pin;
if (!reader.PopString(&label) || !reader.PopString(&user_pin)) {
- callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string());
+ callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string(), -1);
+ LOG(ERROR) << "Invalid response: " << response->ToString();
+ return;
+ }
+ const int kDefaultSlot = 0;
+ callback.Run(DBUS_METHOD_CALL_SUCCESS, label, user_pin, kDefaultSlot);
+ }
+
+ // Handles responses for Pkcs11GetTpmTokenInfoForUser.
+ void OnPkcs11GetTpmTokenInfoForUser(
+ const Pkcs11GetTpmTokenInfoCallback& callback,
+ dbus::Response* response) {
+ if (!response) {
+ callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string(), -1);
+ return;
+ }
+ dbus::MessageReader reader(response);
+ std::string label;
+ std::string user_pin;
+ int slot = 0;
+ if (!reader.PopString(&label) || !reader.PopString(&user_pin) ||
+ !reader.PopInt32(&slot)) {
+ callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string(), -1);
+ LOG(ERROR) << "Invalid response: " << response->ToString();
return;
}
- callback.Run(DBUS_METHOD_CALL_SUCCESS, label, user_pin);
+ callback.Run(DBUS_METHOD_CALL_SUCCESS, label, user_pin, slot);
}
// Handles AsyncCallStatus signal.
« no previous file with comments | « chromeos/dbus/cryptohome_client.h ('k') | chromeos/dbus/fake_cryptohome_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698