Refactor key generation to handle both normal and metadata encryption.

Bug: 147733587
Test: Treehugger
Change-Id: Iee176037dec2621c84da325c2627f988fcebbc8d
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 530d78e..4487d3b 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -77,6 +77,7 @@
 using android::fs_mgr::GetEntryForMountPoint;
 using android::vold::CryptoType;
 using android::vold::KeyBuffer;
+using android::vold::KeyGeneration;
 using namespace android::dm;
 using namespace std::chrono_literals;
 
@@ -323,6 +324,10 @@
     return crypto_type;
 }
 
+const KeyGeneration cryptfs_get_keygen() {
+    return makeGen(get_crypto_type());
+}
+
 /* Should we use keymaster? */
 static int keymaster_check_compatibility() {
     return keymaster_compatibility_cryptfs_scrypt();
@@ -472,10 +477,6 @@
     ftr->p_factor = pf;
 }
 
-size_t cryptfs_get_keysize() {
-    return get_crypto_type().get_keysize();
-}
-
 static uint64_t get_fs_size(const char* dev) {
     int fd, block_size;
     struct ext4_super_block sb;