Create disk encryption keys only when FBE enabled
Our code for creating disk encryption keys doesn't work everywhere,
and it doesn't need to; only on platforms that support FBE. Don't
create them elsewhere.
Bug: 26842807
Change-Id: I686d0ffd7cb3adbddfce661c22ce18f66acb1aba
diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
index 7dbdc2a..fb66a6b 100644
--- a/Ext4Crypt.cpp
+++ b/Ext4Crypt.cpp
@@ -615,6 +615,9 @@
int e4crypt_vold_create_user_key(userid_t user_id, int serial, bool ephemeral) {
LOG(DEBUG) << "e4crypt_vold_create_user_key for " << user_id << " serial " << serial;
+ if (!e4crypt_is_native()) {
+ return 0;
+ }
std::string key;
if (read_user_key(user_id, key)) {
LOG(ERROR) << "Already exists, can't e4crypt_vold_create_user_key for "
@@ -649,6 +652,9 @@
int e4crypt_destroy_user_key(userid_t user_id) {
LOG(DEBUG) << "e4crypt_destroy_user_key(" << user_id << ")";
+ if (!e4crypt_is_native()) {
+ return 0;
+ }
// TODO: destroy second key for user_de data
bool evict_success = evict_user_key(user_id);
auto key_path = get_key_path(user_id);