Refactor: make makeGen local
No need for KeyUtil to know how to make a KeyGeneration, it's cleaner
if each module handles it separately. Also, create a CryptoOptions
structure to track metadata encryption options, and simplify legacy
cipher/option handling.
Test: Treehugger
Bug: 147814592
Change-Id: I740063882914097329ff72348d0c0855c26c7aab
diff --git a/FsCrypt.cpp b/FsCrypt.cpp
index c0ec3eb..a01ed5e 100644
--- a/FsCrypt.cpp
+++ b/FsCrypt.cpp
@@ -64,7 +64,7 @@
using android::vold::BuildDataPath;
using android::vold::kEmptyAuthentication;
using android::vold::KeyBuffer;
-using android::vold::makeGen;
+using android::vold::KeyGeneration;
using android::vold::retrieveKey;
using android::vold::retrieveOrGenerateKey;
using android::vold::writeStringToFile;
@@ -94,6 +94,11 @@
} // namespace
+// Returns KeyGeneration suitable for key as described in EncryptionOptions
+static KeyGeneration makeGen(const EncryptionOptions& options) {
+ return KeyGeneration{FSCRYPT_MAX_KEY_SIZE, true, options.use_hw_wrapped_key};
+}
+
static bool fscrypt_is_emulated() {
return property_get_bool("persist.sys.emulate_fbe", false);
}