Break out password_handle_t into its own file

Change-Id: Id3069a8bb3a90b7c01c45c2740b9ff618b76086b
diff --git a/gatekeeper.cpp b/gatekeeper.cpp
index b8e51e7..9f81163 100644
--- a/gatekeeper.cpp
+++ b/gatekeeper.cpp
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 #include <UniquePtr.h>
-
 #include <gatekeeper/gatekeeper.h>
 
 namespace gatekeeper {
@@ -109,9 +108,9 @@
     password_handle->authenticator_id = authenticator_id;
 
     uint32_t metadata_length = sizeof(user_id) /* user id */
-        + sizeof(authenticator_id) /* auth id */ + sizeof(uint8_t) /* version */;
+        + sizeof(authenticator_id) /* auth id */ + sizeof(HANDLE_VERSION) /* version */;
     uint8_t to_sign[password_length + metadata_length];
-    memcpy(to_sign, &password_handle->version, metadata_length);
+    memcpy(to_sign, password_handle, metadata_length);
     memcpy(to_sign + metadata_length, password, password_length);
 
     const uint8_t *password_key = NULL;
diff --git a/include/gatekeeper/gatekeeper.h b/include/gatekeeper/gatekeeper.h
index 9fb9661..1cd302f 100644
--- a/include/gatekeeper/gatekeeper.h
+++ b/include/gatekeeper/gatekeeper.h
@@ -22,30 +22,10 @@
 #include <hardware/hw_auth_token.h>
 
 #include "gatekeeper_messages.h"
+#include "password_handle.h"
 
 namespace gatekeeper {
 
-typedef uint64_t secure_id_t;
-typedef uint64_t salt_t;
-
-/**
- * Internal only structure for easy serialization
- * and deserialization of password handles.
- *
- * Visible for testing.
- */
-static const uint8_t HANDLE_VERSION = 0;
-struct __attribute__ ((__packed__)) password_handle_t {
-    // fields included in signature
-    uint8_t version;
-    secure_id_t user_id;
-    secure_id_t authenticator_id;
-
-    // fields not included in signature
-    salt_t salt;
-    uint8_t signature[32];
-};
-
 /**
  * Base class for gatekeeper implementations. Provides all functionality except
  * the ability to create/access keys and compute signatures. These are left up
diff --git a/include/gatekeeper/password_handle.h b/include/gatekeeper/password_handle.h
new file mode 100644
index 0000000..9bf4cb2
--- /dev/null
+++ b/include/gatekeeper/password_handle.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 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 GATEKEEPER_PASSWORD_HANDLE_H_
+#define GATEKEEPER_PASSWORD_HANDLE_H_
+
+namespace gatekeeper {
+
+typedef uint64_t secure_id_t;
+typedef uint64_t salt_t;
+/**
+ * structure for easy serialization
+ * and deserialization of password handles.
+ */
+static const uint8_t HANDLE_VERSION = 0;
+struct __attribute__ ((__packed__)) password_handle_t {
+    // fields included in signature
+    uint8_t version;
+    secure_id_t user_id;
+    secure_id_t authenticator_id;
+
+    // fields not included in signature
+    salt_t salt;
+    uint8_t signature[32];
+};
+}
+
+
+#endif // GATEKEEPER_PASSWORD_HANDLE_H_