Add get() function to CryptHandle class

This commit modifies the CryptHandle class so that the crypt_device
struct is managed internally. This way, the caller does not need to
provide it's own crypt_device pointer. The caller can use the new get()
function when it needs access to the crypt_device struct.

Signed-off-by: John Wedig <johnwedig@google.com>
Change-Id: I82c2f96d74cc2714de5a656432cbaa2f6ee1244a
diff --git a/include/cryptsetupInterface.hpp b/include/cryptsetupInterface.hpp
index 9e26da9..25c69d0 100644
--- a/include/cryptsetupInterface.hpp
+++ b/include/cryptsetupInterface.hpp
@@ -154,27 +154,32 @@
   public:
     /** @brief Constructor for CryptHandle
      *
-     *  @param[out] cd - pointer to crypt_device*, to be allocated
      *  @param[in] device - path to device file
      */
-    CryptHandle(struct crypt_device** cd, const char* device) :
-        handle(init(cd, device))
+    explicit CryptHandle(const char* device) : handle(init(device))
     {}
 
+    /** @brief Get a pointer to the crypt_device struct. */
+    struct crypt_device* get()
+    {
+        return *handle;
+    }
+
+  private:
     /** @brief Allocate and initialize the crypt_device struct
      *
-     *  @param[out] cd - pointer to crypt_device*, to be allocated
      *  @param[in] device - path to device file
      */
-    struct crypt_device* init(struct crypt_device** cd, const char* device)
+    struct crypt_device* init(const char* device)
     {
-        int retval = crypt_init(cd, device);
+        struct crypt_device* cryptDev;
+        int retval = crypt_init(&cryptDev, device);
         if (retval < 0)
         {
             return nullptr;
         }
 
-        return *cd;
+        return cryptDev;
     }
 
     /** @brief Free the crypt_device struct