tpm_manager: Break up the D-Bus interface

This CL breaks up the monolithic TpmManager Dbus interface into
a TpmOwnershipInterface and a TpmNvramInterface. In the future if
we want to refactor, we can simply remove one of these interface files
and associated code.

Bug: 24659038
TEST=compile and run on DUT.

Change-Id: I52433d9fbb4ff890fe4653bd6001f9a0b4a0982f
diff --git a/client/main.cc b/client/main.cc
index 124d88d..98df149 100644
--- a/client/main.cc
+++ b/client/main.cc
@@ -29,8 +29,10 @@
 #include <chromeos/syslog_logging.h>
 
 #include "tpm_manager/client/dbus_proxy.h"
-#include "tpm_manager/common/dbus_interface.pb.h"
-#include "tpm_manager/common/print_dbus_interface_proto.h"
+#include "tpm_manager/common/print_tpm_ownership_interface_proto.h"
+#include "tpm_manager/common/print_tpm_nvram_interface_proto.h"
+#include "tpm_manager/common/tpm_ownership_interface.pb.h"
+#include "tpm_manager/common/tpm_nvram_interface.pb.h"
 
 namespace tpm_manager {
 
diff --git a/common/dbus_interface.proto b/common/dbus_interface.proto
deleted file mode 100644
index a875565..0000000
--- a/common/dbus_interface.proto
+++ /dev/null
@@ -1,120 +0,0 @@
-option optimize_for = LITE_RUNTIME;
-package tpm_manager;
-
-import "local_data.proto";
-
-// The messages in this file correspond to the TpmManager D-Bus interface.
-
-enum TpmManagerStatus {
-  STATUS_SUCCESS = 0;
-  STATUS_UNEXPECTED_DEVICE_ERROR = 1;
-  STATUS_NOT_AVAILABLE = 2;
-}
-
-// Input for the GetTpmStatus method.
-message GetTpmStatusRequest {
-}
-
-// Output from the GetTpmStatus method.
-message GetTpmStatusReply {
-  optional TpmManagerStatus status = 1;
-  // Whether a TPM is enabled on the system.
-  optional bool enabled = 2;
-  // Whether the TPM has been owned.
-  optional bool owned = 3;
-  // Local TPM management data (including the owner password if available).
-  optional LocalData local_data = 4;
-  // The current dictionary attack counter value.
-  optional int32 dictionary_attack_counter = 5;
-  // The current dictionary attack counter threshold.
-  optional int32 dictionary_attack_threshold = 6;
-  // Whether the TPM is in some form of dictionary attack lockout.
-  optional bool dictionary_attack_lockout_in_effect = 7;
-  // The number of seconds remaining in the lockout.
-  optional int32 dictionary_attack_lockout_seconds_remaining = 8;
-}
-
-// Input for the TakeOwnership method.
-message TakeOwnershipRequest {
-}
-
-// Output from the TakeOwnership method.
-message TakeOwnershipReply {
-  optional TpmManagerStatus status = 1;
-}
-
-// Input for the DefineNvram method.
-message DefineNvramRequest {
-  optional int32 index = 1;
-  optional int32 length = 2;
-}
-
-// Output for the DefineNvram method.
-message DefineNvramReply {
-  optional TpmManagerStatus status = 1;
-}
-
-// Input for the DestroyNvram method.
-message DestroyNvramRequest {
-  optional int32 index = 1;
-}
-
-// Output for the DestroyNvram method.
-message DestroyNvramReply {
-  optional TpmManagerStatus status = 1;
-}
-
-// Input for the WriteNvram method.
-message WriteNvramRequest {
-  optional int32 index = 1;
-  optional bytes data = 2;
-}
-
-// Output for the WriteNvram method.
-message WriteNvramReply {
-  optional TpmManagerStatus status = 1;
-}
-
-// Input for the ReadNvram method.
-message ReadNvramRequest {
-  optional int32 index = 1;
-}
-
-// Output for the ReadNvram method.
-message ReadNvramReply {
-  optional TpmManagerStatus status = 1;
-  optional bytes data = 2;
-}
-
-// Input for the IsNvramDefined method.
-message IsNvramDefinedRequest {
-  optional int32 index = 1;
-}
-
-// Output for the IsNvramDefined method.
-message IsNvramDefinedReply {
-  optional TpmManagerStatus status = 1;
-  optional bool is_defined = 2;
-}
-
-// Input for the IsNvramLocked method.
-message IsNvramLockedRequest {
-  optional int32 index = 1;
-}
-
-// Output for the IsNvramLocked method.
-message IsNvramLockedReply {
-  optional TpmManagerStatus status = 1;
-  optional bool is_locked = 2;
-}
-
-// Input for the GetNvramSize method.
-message GetNvramSizeRequest {
-  optional int32 index = 1;
-}
-
-// Output for the GetNvramSize method.
-message GetNvramSizeReply {
-  optional TpmManagerStatus status = 1;
-  optional int32 size = 2;
-}
diff --git a/common/print_tpm_manager_status_proto.cc b/common/print_tpm_manager_status_proto.cc
new file mode 100644
index 0000000..e51e370
--- /dev/null
+++ b/common/print_tpm_manager_status_proto.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// THIS CODE IS GENERATED.
+
+#include "tpm_manager/common/print_tpm_manager_status_proto.h"
+
+#include <string>
+
+#include <base/strings/string_number_conversions.h>
+#include <base/strings/stringprintf.h>
+
+namespace tpm_manager {
+
+std::string GetProtoDebugString(TpmManagerStatus value) {
+  return GetProtoDebugStringWithIndent(value, 0);
+}
+
+std::string GetProtoDebugStringWithIndent(TpmManagerStatus value,
+                                          int indent_size) {
+  if (value == STATUS_SUCCESS) {
+    return "STATUS_SUCCESS";
+  }
+  if (value == STATUS_UNEXPECTED_DEVICE_ERROR) {
+    return "STATUS_UNEXPECTED_DEVICE_ERROR";
+  }
+  if (value == STATUS_NOT_AVAILABLE) {
+    return "STATUS_NOT_AVAILABLE";
+  }
+  return "<unknown>";
+}
+
+}  // namespace tpm_manager
diff --git a/common/print_tpm_manager_status_proto.h b/common/print_tpm_manager_status_proto.h
new file mode 100644
index 0000000..3a23778
--- /dev/null
+++ b/common/print_tpm_manager_status_proto.h
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// THIS CODE IS GENERATED.
+
+#ifndef TPM_MANAGER_COMMON_PRINT_TPM_MANAGER_STATUS_PROTO_H_
+#define TPM_MANAGER_COMMON_PRINT_TPM_MANAGER_STATUS_PROTO_H_
+
+#include <string>
+
+#include "tpm_manager/common/tpm_manager_status.pb.h"
+
+namespace tpm_manager {
+
+std::string GetProtoDebugStringWithIndent(TpmManagerStatus value,
+                                          int indent_size);
+std::string GetProtoDebugString(TpmManagerStatus value);
+
+}  // namespace tpm_manager
+
+#endif  // TPM_MANAGER_COMMON_PRINT_TPM_MANAGER_STATUS_PROTO_H_
diff --git a/common/print_dbus_interface_proto.cc b/common/print_tpm_nvram_interface_proto.cc
similarity index 70%
rename from common/print_dbus_interface_proto.cc
rename to common/print_tpm_nvram_interface_proto.cc
index 3138b7a..2e46900 100644
--- a/common/print_dbus_interface_proto.cc
+++ b/common/print_tpm_nvram_interface_proto.cc
@@ -16,145 +16,17 @@
 
 // THIS CODE IS GENERATED.
 
-#include "tpm_manager/common/print_dbus_interface_proto.h"
+#include "tpm_manager/common/print_tpm_nvram_interface_proto.h"
 
 #include <string>
 
 #include <base/strings/string_number_conversions.h>
 #include <base/strings/stringprintf.h>
 
-#include "tpm_manager/common/print_local_data_proto.h"
+#include "tpm_manager/common/print_tpm_manager_status_proto.h"
 
 namespace tpm_manager {
 
-std::string GetProtoDebugString(TpmManagerStatus value) {
-  return GetProtoDebugStringWithIndent(value, 0);
-}
-
-std::string GetProtoDebugStringWithIndent(TpmManagerStatus value,
-                                          int indent_size) {
-  if (value == STATUS_SUCCESS) {
-    return "STATUS_SUCCESS";
-  }
-  if (value == STATUS_UNEXPECTED_DEVICE_ERROR) {
-    return "STATUS_UNEXPECTED_DEVICE_ERROR";
-  }
-  if (value == STATUS_NOT_AVAILABLE) {
-    return "STATUS_NOT_AVAILABLE";
-  }
-  return "<unknown>";
-}
-
-std::string GetProtoDebugString(const GetTpmStatusRequest& value) {
-  return GetProtoDebugStringWithIndent(value, 0);
-}
-
-std::string GetProtoDebugStringWithIndent(const GetTpmStatusRequest& value,
-                                          int indent_size) {
-  std::string indent(indent_size, ' ');
-  std::string output =
-      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
-
-  output += indent + "}\n";
-  return output;
-}
-
-std::string GetProtoDebugString(const GetTpmStatusReply& value) {
-  return GetProtoDebugStringWithIndent(value, 0);
-}
-
-std::string GetProtoDebugStringWithIndent(const GetTpmStatusReply& value,
-                                          int indent_size) {
-  std::string indent(indent_size, ' ');
-  std::string output =
-      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
-
-  if (value.has_status()) {
-    output += indent + "  status: ";
-    base::StringAppendF(
-        &output, "%s",
-        GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str());
-    output += "\n";
-  }
-  if (value.has_enabled()) {
-    output += indent + "  enabled: ";
-    base::StringAppendF(&output, "%s", value.enabled() ? "true" : "false");
-    output += "\n";
-  }
-  if (value.has_owned()) {
-    output += indent + "  owned: ";
-    base::StringAppendF(&output, "%s", value.owned() ? "true" : "false");
-    output += "\n";
-  }
-  if (value.has_local_data()) {
-    output += indent + "  local_data: ";
-    base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
-                                           value.local_data(), indent_size + 2)
-                                           .c_str());
-    output += "\n";
-  }
-  if (value.has_dictionary_attack_counter()) {
-    output += indent + "  dictionary_attack_counter: ";
-    base::StringAppendF(&output, "%d", value.dictionary_attack_counter());
-    output += "\n";
-  }
-  if (value.has_dictionary_attack_threshold()) {
-    output += indent + "  dictionary_attack_threshold: ";
-    base::StringAppendF(&output, "%d", value.dictionary_attack_threshold());
-    output += "\n";
-  }
-  if (value.has_dictionary_attack_lockout_in_effect()) {
-    output += indent + "  dictionary_attack_lockout_in_effect: ";
-    base::StringAppendF(
-        &output, "%s",
-        value.dictionary_attack_lockout_in_effect() ? "true" : "false");
-    output += "\n";
-  }
-  if (value.has_dictionary_attack_lockout_seconds_remaining()) {
-    output += indent + "  dictionary_attack_lockout_seconds_remaining: ";
-    base::StringAppendF(&output, "%d",
-                        value.dictionary_attack_lockout_seconds_remaining());
-    output += "\n";
-  }
-  output += indent + "}\n";
-  return output;
-}
-
-std::string GetProtoDebugString(const TakeOwnershipRequest& value) {
-  return GetProtoDebugStringWithIndent(value, 0);
-}
-
-std::string GetProtoDebugStringWithIndent(const TakeOwnershipRequest& value,
-                                          int indent_size) {
-  std::string indent(indent_size, ' ');
-  std::string output =
-      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
-
-  output += indent + "}\n";
-  return output;
-}
-
-std::string GetProtoDebugString(const TakeOwnershipReply& value) {
-  return GetProtoDebugStringWithIndent(value, 0);
-}
-
-std::string GetProtoDebugStringWithIndent(const TakeOwnershipReply& value,
-                                          int indent_size) {
-  std::string indent(indent_size, ' ');
-  std::string output =
-      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
-
-  if (value.has_status()) {
-    output += indent + "  status: ";
-    base::StringAppendF(
-        &output, "%s",
-        GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str());
-    output += "\n";
-  }
-  output += indent + "}\n";
-  return output;
-}
-
 std::string GetProtoDebugString(const DefineNvramRequest& value) {
   return GetProtoDebugStringWithIndent(value, 0);
 }
diff --git a/common/print_dbus_interface_proto.h b/common/print_tpm_nvram_interface_proto.h
similarity index 74%
rename from common/print_dbus_interface_proto.h
rename to common/print_tpm_nvram_interface_proto.h
index f5a394a..3db43f6 100644
--- a/common/print_dbus_interface_proto.h
+++ b/common/print_tpm_nvram_interface_proto.h
@@ -16,30 +16,15 @@
 
 // THIS CODE IS GENERATED.
 
-#ifndef TPM_MANAGER_COMMON_PRINT_DBUS_INTERFACE_PROTO_H_
-#define TPM_MANAGER_COMMON_PRINT_DBUS_INTERFACE_PROTO_H_
+#ifndef TPM_MANAGER_COMMON_PRINT_TPM_NVRAM_INTERFACE_PROTO_H_
+#define TPM_MANAGER_COMMON_PRINT_TPM_NVRAM_INTERFACE_PROTO_H_
 
 #include <string>
 
-#include "tpm_manager/common/dbus_interface.pb.h"
+#include "tpm_manager/common/tpm_nvram_interface.pb.h"
 
 namespace tpm_manager {
 
-std::string GetProtoDebugStringWithIndent(TpmManagerStatus value,
-                                          int indent_size);
-std::string GetProtoDebugString(TpmManagerStatus value);
-std::string GetProtoDebugStringWithIndent(const GetTpmStatusRequest& value,
-                                          int indent_size);
-std::string GetProtoDebugString(const GetTpmStatusRequest& value);
-std::string GetProtoDebugStringWithIndent(const GetTpmStatusReply& value,
-                                          int indent_size);
-std::string GetProtoDebugString(const GetTpmStatusReply& value);
-std::string GetProtoDebugStringWithIndent(const TakeOwnershipRequest& value,
-                                          int indent_size);
-std::string GetProtoDebugString(const TakeOwnershipRequest& value);
-std::string GetProtoDebugStringWithIndent(const TakeOwnershipReply& value,
-                                          int indent_size);
-std::string GetProtoDebugString(const TakeOwnershipReply& value);
 std::string GetProtoDebugStringWithIndent(const DefineNvramRequest& value,
                                           int indent_size);
 std::string GetProtoDebugString(const DefineNvramRequest& value);
@@ -85,4 +70,4 @@
 
 }  // namespace tpm_manager
 
-#endif  // TPM_MANAGER_COMMON_PRINT_DBUS_INTERFACE_PROTO_H_
+#endif  // TPM_MANAGER_COMMON_PRINT_TPM_NVRAM_INTERFACE_PROTO_H_
diff --git a/common/print_tpm_ownership_interface_proto.cc b/common/print_tpm_ownership_interface_proto.cc
new file mode 100644
index 0000000..45163b1
--- /dev/null
+++ b/common/print_tpm_ownership_interface_proto.cc
@@ -0,0 +1,141 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// THIS CODE IS GENERATED.
+
+#include "tpm_manager/common/print_tpm_ownership_interface_proto.h"
+
+#include <string>
+
+#include <base/strings/string_number_conversions.h>
+#include <base/strings/stringprintf.h>
+
+#include "tpm_manager/common/print_local_data_proto.h"
+#include "tpm_manager/common/print_tpm_manager_status_proto.h"
+
+namespace tpm_manager {
+
+std::string GetProtoDebugString(const GetTpmStatusRequest& value) {
+  return GetProtoDebugStringWithIndent(value, 0);
+}
+
+std::string GetProtoDebugStringWithIndent(const GetTpmStatusRequest& value,
+                                          int indent_size) {
+  std::string indent(indent_size, ' ');
+  std::string output =
+      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
+
+  output += indent + "}\n";
+  return output;
+}
+
+std::string GetProtoDebugString(const GetTpmStatusReply& value) {
+  return GetProtoDebugStringWithIndent(value, 0);
+}
+
+std::string GetProtoDebugStringWithIndent(const GetTpmStatusReply& value,
+                                          int indent_size) {
+  std::string indent(indent_size, ' ');
+  std::string output =
+      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
+
+  if (value.has_status()) {
+    output += indent + "  status: ";
+    base::StringAppendF(
+        &output, "%s",
+        GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str());
+    output += "\n";
+  }
+  if (value.has_enabled()) {
+    output += indent + "  enabled: ";
+    base::StringAppendF(&output, "%s", value.enabled() ? "true" : "false");
+    output += "\n";
+  }
+  if (value.has_owned()) {
+    output += indent + "  owned: ";
+    base::StringAppendF(&output, "%s", value.owned() ? "true" : "false");
+    output += "\n";
+  }
+  if (value.has_local_data()) {
+    output += indent + "  local_data: ";
+    base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent(
+                                           value.local_data(), indent_size + 2)
+                                           .c_str());
+    output += "\n";
+  }
+  if (value.has_dictionary_attack_counter()) {
+    output += indent + "  dictionary_attack_counter: ";
+    base::StringAppendF(&output, "%d", value.dictionary_attack_counter());
+    output += "\n";
+  }
+  if (value.has_dictionary_attack_threshold()) {
+    output += indent + "  dictionary_attack_threshold: ";
+    base::StringAppendF(&output, "%d", value.dictionary_attack_threshold());
+    output += "\n";
+  }
+  if (value.has_dictionary_attack_lockout_in_effect()) {
+    output += indent + "  dictionary_attack_lockout_in_effect: ";
+    base::StringAppendF(
+        &output, "%s",
+        value.dictionary_attack_lockout_in_effect() ? "true" : "false");
+    output += "\n";
+  }
+  if (value.has_dictionary_attack_lockout_seconds_remaining()) {
+    output += indent + "  dictionary_attack_lockout_seconds_remaining: ";
+    base::StringAppendF(&output, "%d",
+                        value.dictionary_attack_lockout_seconds_remaining());
+    output += "\n";
+  }
+  output += indent + "}\n";
+  return output;
+}
+
+std::string GetProtoDebugString(const TakeOwnershipRequest& value) {
+  return GetProtoDebugStringWithIndent(value, 0);
+}
+
+std::string GetProtoDebugStringWithIndent(const TakeOwnershipRequest& value,
+                                          int indent_size) {
+  std::string indent(indent_size, ' ');
+  std::string output =
+      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
+
+  output += indent + "}\n";
+  return output;
+}
+
+std::string GetProtoDebugString(const TakeOwnershipReply& value) {
+  return GetProtoDebugStringWithIndent(value, 0);
+}
+
+std::string GetProtoDebugStringWithIndent(const TakeOwnershipReply& value,
+                                          int indent_size) {
+  std::string indent(indent_size, ' ');
+  std::string output =
+      base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
+
+  if (value.has_status()) {
+    output += indent + "  status: ";
+    base::StringAppendF(
+        &output, "%s",
+        GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str());
+    output += "\n";
+  }
+  output += indent + "}\n";
+  return output;
+}
+
+}  // namespace tpm_manager
diff --git a/common/print_tpm_ownership_interface_proto.h b/common/print_tpm_ownership_interface_proto.h
new file mode 100644
index 0000000..e6d532d
--- /dev/null
+++ b/common/print_tpm_ownership_interface_proto.h
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// THIS CODE IS GENERATED.
+
+#ifndef TPM_MANAGER_COMMON_PRINT_TPM_OWNERSHIP_INTERFACE_PROTO_H_
+#define TPM_MANAGER_COMMON_PRINT_TPM_OWNERSHIP_INTERFACE_PROTO_H_
+
+#include <string>
+
+#include "tpm_manager/common/tpm_ownership_interface.pb.h"
+
+namespace tpm_manager {
+
+std::string GetProtoDebugStringWithIndent(const GetTpmStatusRequest& value,
+                                          int indent_size);
+std::string GetProtoDebugString(const GetTpmStatusRequest& value);
+std::string GetProtoDebugStringWithIndent(const GetTpmStatusReply& value,
+                                          int indent_size);
+std::string GetProtoDebugString(const GetTpmStatusReply& value);
+std::string GetProtoDebugStringWithIndent(const TakeOwnershipRequest& value,
+                                          int indent_size);
+std::string GetProtoDebugString(const TakeOwnershipRequest& value);
+std::string GetProtoDebugStringWithIndent(const TakeOwnershipReply& value,
+                                          int indent_size);
+std::string GetProtoDebugString(const TakeOwnershipReply& value);
+
+}  // namespace tpm_manager
+
+#endif  // TPM_MANAGER_COMMON_PRINT_TPM_OWNERSHIP_INTERFACE_PROTO_H_
diff --git a/common/tpm_manager_interface.h b/common/tpm_manager_interface.h
index f16ec93..531bdb9 100644
--- a/common/tpm_manager_interface.h
+++ b/common/tpm_manager_interface.h
@@ -19,15 +19,18 @@
 
 #include <base/callback.h>
 
-#include "tpm_manager/common/dbus_interface.pb.h"
 #include "tpm_manager/common/export.h"
+#include "tpm_manager/common/tpm_nvram_interface.h"
+#include "tpm_manager/common/tpm_ownership_interface.h"
 
 namespace tpm_manager {
 
 // This is the main TpmManager interface that is implemented by the proxies
 // and services.
-// TODO(usanghi): Break up the DBus interface (b/24659038).
-class TPM_MANAGER_EXPORT TpmManagerInterface {
+// TODO(usanghi): Move this class into server/ since the client side will
+// implement each interface seperately.
+class TPM_MANAGER_EXPORT TpmManagerInterface : public TpmNvramInterface,
+                                               public TpmOwnershipInterface {
  public:
   virtual ~TpmManagerInterface() = default;
 
@@ -35,49 +38,25 @@
   // any other method on this interface.
   virtual bool Initialize() = 0;
 
-  // Processes a GetTpmStatusRequest and responds with a GetTpmStatusReply.
-  using GetTpmStatusCallback = base::Callback<void(const GetTpmStatusReply&)>;
+  // TpmOwnershipInterface methods.
   virtual void GetTpmStatus(const GetTpmStatusRequest& request,
                             const GetTpmStatusCallback& callback) = 0;
-
-  // Processes a TakeOwnershipRequest and responds with a TakeOwnershipReply.
-  using TakeOwnershipCallback = base::Callback<void(const TakeOwnershipReply&)>;
   virtual void TakeOwnership(const TakeOwnershipRequest& request,
                              const TakeOwnershipCallback& callback) = 0;
 
-  // Processes a DefineNvramRequest and responds with a DefineNvramReply.
-  using DefineNvramCallback = base::Callback<void(const DefineNvramReply&)>;
+  // TpmNvramInterface methods.
   virtual void DefineNvram(const DefineNvramRequest& request,
                            const DefineNvramCallback& callback) = 0;
-
-  // Processes a DestroyNvramRequest and responds with a DestroyNvramReply.
-  using DestroyNvramCallback = base::Callback<void(const DestroyNvramReply&)>;
   virtual void DestroyNvram(const DestroyNvramRequest& request,
                             const DestroyNvramCallback& callback) = 0;
-
-  // Processes a WriteNvramRequest and responds with a WriteNvramReply.
-  using WriteNvramCallback = base::Callback<void(const WriteNvramReply&)>;
   virtual void WriteNvram(const WriteNvramRequest& request,
                           const WriteNvramCallback& callback) = 0;
-
-  // Processes a ReadNvramRequest and responds with a ReadNvramReply.
-  using ReadNvramCallback = base::Callback<void(const ReadNvramReply&)>;
   virtual void ReadNvram(const ReadNvramRequest& request,
                          const ReadNvramCallback& callback) = 0;
-
-  // Processes a IsNvramDefinedRequest and responds with a IsNvramDefinedReply.
-  using IsNvramDefinedCallback =
-      base::Callback<void(const IsNvramDefinedReply&)>;
   virtual void IsNvramDefined(const IsNvramDefinedRequest& request,
                               const IsNvramDefinedCallback& callback) = 0;
-
-  // Processes a IsNvramLockedRequest and responds with a IsNvramLockedReply.
-  using IsNvramLockedCallback = base::Callback<void(const IsNvramLockedReply&)>;
   virtual void IsNvramLocked(const IsNvramLockedRequest& request,
                              const IsNvramLockedCallback& callback) = 0;
-
-  // Processes a GetNvramSizeRequest and responds with a GetNvramSizeReply.
-  using GetNvramSizeCallback = base::Callback<void(const GetNvramSizeReply&)>;
   virtual void GetNvramSize(const GetNvramSizeRequest& request,
                             const GetNvramSizeCallback& callback) = 0;
 };
diff --git a/common/tpm_manager_status.proto b/common/tpm_manager_status.proto
new file mode 100644
index 0000000..4008d38
--- /dev/null
+++ b/common/tpm_manager_status.proto
@@ -0,0 +1,24 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+option optimize_for = LITE_RUNTIME;
+package tpm_manager;
+
+enum TpmManagerStatus {
+  STATUS_SUCCESS = 0;
+  STATUS_UNEXPECTED_DEVICE_ERROR = 1;
+  STATUS_NOT_AVAILABLE = 2;
+}
diff --git a/common/tpm_nvram_interface.h b/common/tpm_nvram_interface.h
new file mode 100644
index 0000000..a78ff87
--- /dev/null
+++ b/common/tpm_nvram_interface.h
@@ -0,0 +1,72 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef TPM_MANAGER_COMMON_TPM_NVRAM_INTERFACE_H_
+#define TPM_MANAGER_COMMON_TPM_NVRAM_INTERFACE_H_
+
+#include <base/callback.h>
+
+#include "tpm_manager/common/export.h"
+#include "tpm_manager/common/tpm_nvram_interface.pb.h"
+
+namespace tpm_manager {
+
+// This is the interface to access the nvram subsystem of the Tpm. It is
+// extended by TpmManagerInterface.
+class TPM_MANAGER_EXPORT TpmNvramInterface {
+ public:
+  virtual ~TpmNvramInterface() = default;
+
+  // Processes a DefineNvramRequest and responds with a DefineNvramReply.
+  using DefineNvramCallback = base::Callback<void(const DefineNvramReply&)>;
+  virtual void DefineNvram(const DefineNvramRequest& request,
+                           const DefineNvramCallback& callback) = 0;
+
+  // Processes a DestroyNvramRequest and responds with a DestroyNvramReply.
+  using DestroyNvramCallback = base::Callback<void(const DestroyNvramReply&)>;
+  virtual void DestroyNvram(const DestroyNvramRequest& request,
+                            const DestroyNvramCallback& callback) = 0;
+
+  // Processes a WriteNvramRequest and responds with a WriteNvramReply.
+  using WriteNvramCallback = base::Callback<void(const WriteNvramReply&)>;
+  virtual void WriteNvram(const WriteNvramRequest& request,
+                          const WriteNvramCallback& callback) = 0;
+
+  // Processes a ReadNvramRequest and responds with a ReadNvramReply.
+  using ReadNvramCallback = base::Callback<void(const ReadNvramReply&)>;
+  virtual void ReadNvram(const ReadNvramRequest& request,
+                         const ReadNvramCallback& callback) = 0;
+
+  // Processes a IsNvramDefinedRequest and responds with a IsNvramDefinedReply.
+  using IsNvramDefinedCallback =
+      base::Callback<void(const IsNvramDefinedReply&)>;
+  virtual void IsNvramDefined(const IsNvramDefinedRequest& request,
+                              const IsNvramDefinedCallback& callback) = 0;
+
+  // Processes a IsNvramLockedRequest and responds with a IsNvramLockedReply.
+  using IsNvramLockedCallback = base::Callback<void(const IsNvramLockedReply&)>;
+  virtual void IsNvramLocked(const IsNvramLockedRequest& request,
+                             const IsNvramLockedCallback& callback) = 0;
+
+  // Processes a GetNvramSizeRequest and responds with a GetNvramSizeReply.
+  using GetNvramSizeCallback = base::Callback<void(const GetNvramSizeReply&)>;
+  virtual void GetNvramSize(const GetNvramSizeRequest& request,
+                            const GetNvramSizeCallback& callback) = 0;
+};
+
+}  // namespace tpm_manager
+
+#endif  // TPM_MANAGER_COMMON_TPM_NVRAM_INTERFACE_H_
diff --git a/common/tpm_nvram_interface.proto b/common/tpm_nvram_interface.proto
new file mode 100644
index 0000000..cecf8dc
--- /dev/null
+++ b/common/tpm_nvram_interface.proto
@@ -0,0 +1,99 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+option optimize_for = LITE_RUNTIME;
+package tpm_manager;
+
+import "tpm_manager_status.proto";
+
+// The messages in this file correspond to the D-Bus interface for accessing
+// Tpm backed Nvram.
+
+// Input for the DefineNvram method.
+message DefineNvramRequest {
+  optional int32 index = 1;
+  optional int32 length = 2;
+}
+
+// Output for the DefineNvram method.
+message DefineNvramReply {
+  optional TpmManagerStatus status = 1;
+}
+
+// Input for the DestroyNvram method.
+message DestroyNvramRequest {
+  optional int32 index = 1;
+}
+
+// Output for the DestroyNvram method.
+message DestroyNvramReply {
+  optional TpmManagerStatus status = 1;
+}
+
+// Input for the WriteNvram method.
+message WriteNvramRequest {
+  optional int32 index = 1;
+  optional bytes data = 2;
+}
+
+// Output for the WriteNvram method.
+message WriteNvramReply {
+  optional TpmManagerStatus status = 1;
+}
+
+// Input for the ReadNvram method.
+message ReadNvramRequest {
+  optional int32 index = 1;
+}
+
+// Output for the ReadNvram method.
+message ReadNvramReply {
+  optional TpmManagerStatus status = 1;
+  optional bytes data = 2;
+}
+
+// Input for the IsNvramDefined method.
+message IsNvramDefinedRequest {
+  optional int32 index = 1;
+}
+
+// Output for the IsNvramDefined method.
+message IsNvramDefinedReply {
+  optional TpmManagerStatus status = 1;
+  optional bool is_defined = 2;
+}
+
+// Input for the IsNvramLocked method.
+message IsNvramLockedRequest {
+  optional int32 index = 1;
+}
+
+// Output for the IsNvramLocked method.
+message IsNvramLockedReply {
+  optional TpmManagerStatus status = 1;
+  optional bool is_locked = 2;
+}
+
+// Input for the GetNvramSize method.
+message GetNvramSizeRequest {
+  optional int32 index = 1;
+}
+
+// Output for the GetNvramSize method.
+message GetNvramSizeReply {
+  optional TpmManagerStatus status = 1;
+  optional int32 size = 2;
+}
diff --git a/common/tpm_ownership_interface.h b/common/tpm_ownership_interface.h
new file mode 100644
index 0000000..145d41b
--- /dev/null
+++ b/common/tpm_ownership_interface.h
@@ -0,0 +1,47 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef TPM_MANAGER_COMMON_TPM_OWNERSHIP_INTERFACE_H_
+#define TPM_MANAGER_COMMON_TPM_OWNERSHIP_INTERFACE_H_
+
+#include <base/callback.h>
+
+#include "tpm_manager/common/export.h"
+#include "tpm_manager/common/tpm_ownership_interface.pb.h"
+
+namespace tpm_manager {
+
+// This is the interface to access the ownership subsystem of the Tpm. It is
+// extended by TpmManagerInterface.
+class TPM_MANAGER_EXPORT TpmOwnershipInterface {
+ public:
+  virtual ~TpmOwnershipInterface() = default;
+
+  // Processes a GetTpmStatusRequest and responds with a GetTpmStatusReply.
+  using GetTpmStatusCallback = base::Callback<void(const GetTpmStatusReply&)>;
+  virtual void GetTpmStatus(const GetTpmStatusRequest& request,
+                            const GetTpmStatusCallback& callback) = 0;
+
+  // Processes a TakeOwnershipRequest and responds with a TakeOwnershipReply.
+  using TakeOwnershipCallback = base::Callback<void(const TakeOwnershipReply&)>;
+  virtual void TakeOwnership(const TakeOwnershipRequest& request,
+                             const TakeOwnershipCallback& callback) = 0;
+
+};
+
+}  // namespace tpm_manager
+
+#endif  // TPM_MANAGER_COMMON_TPM_OWNERSHIP_INTERFACE_H_
diff --git a/common/tpm_ownership_interface.proto b/common/tpm_ownership_interface.proto
new file mode 100644
index 0000000..f1aa4c2
--- /dev/null
+++ b/common/tpm_ownership_interface.proto
@@ -0,0 +1,56 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+option optimize_for = LITE_RUNTIME;
+package tpm_manager;
+
+import "local_data.proto";
+import "tpm_manager_status.proto";
+
+// The messages in this file correspond to the D-Bus interface to handle
+// ownership of the Tpm.
+
+// Input for the GetTpmStatus method.
+message GetTpmStatusRequest {
+}
+
+// Output from the GetTpmStatus method.
+message GetTpmStatusReply {
+  optional TpmManagerStatus status = 1;
+  // Whether a TPM is enabled on the system.
+  optional bool enabled = 2;
+  // Whether the TPM has been owned.
+  optional bool owned = 3;
+  // Local TPM management data (including the owner password if available).
+  optional LocalData local_data = 4;
+  // The current dictionary attack counter value.
+  optional int32 dictionary_attack_counter = 5;
+  // The current dictionary attack counter threshold.
+  optional int32 dictionary_attack_threshold = 6;
+  // Whether the TPM is in some form of dictionary attack lockout.
+  optional bool dictionary_attack_lockout_in_effect = 7;
+  // The number of seconds remaining in the lockout.
+  optional int32 dictionary_attack_lockout_seconds_remaining = 8;
+}
+
+// Input for the TakeOwnership method.
+message TakeOwnershipRequest {
+}
+
+// Output from the TakeOwnership method.
+message TakeOwnershipReply {
+  optional TpmManagerStatus status = 1;
+}
diff --git a/tpm_manager.gyp b/tpm_manager.gyp
index 01f715f..b7e740f 100644
--- a/tpm_manager.gyp
+++ b/tpm_manager.gyp
@@ -42,10 +42,14 @@
         'proto_out_dir': 'include/tpm_manager/common',
       },
       'sources': [
-        '<(proto_in_dir)/dbus_interface.proto',
         '<(proto_in_dir)/local_data.proto',
-        'common/print_dbus_interface_proto.cc',
+        '<(proto_in_dir)/tpm_manager_status.proto',
+        '<(proto_in_dir)/tpm_nvram_interface.proto',
+        '<(proto_in_dir)/tpm_ownership_interface.proto',
         'common/print_local_data_proto.cc',
+        'common/print_tpm_manager_status_proto.cc',
+        'common/print_tpm_nvram_interface_proto.cc',
+        'common/print_tpm_ownership_interface_proto.cc',
       ],
       'includes': ['../../../platform2/common-mk/protoc.gypi'],
     },