FsCrypt update: support fscrypt policies v1 and v2
This patchset introduces support decryption for Android 11.
In this update we deprecate ext4crypt. To specify the
policy version to use, use TW_USE_FSCRYPT_POLICY := 1 or
TW_USE_FSCRYPT_POLICY := 2. By default policy version will
be set to 2 if this variable is omitted.
Change-Id: I62a29c1bef36c259ec4b11259f71be613d20a112
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index a4652c6..284fe2b 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -92,12 +92,10 @@
#include "gui/rapidxml.hpp"
#include "gui/pages.hpp"
#ifdef TW_INCLUDE_FBE
-#include "crypto/ext4crypt/Decrypt.h"
+#include "Decrypt.h"
#ifdef TW_INCLUDE_FBE_METADATA_DECRYPT
#ifdef USE_FSCRYPT
- #include "crypto/fscrypt/MetadataCrypt.h"
- #else
- #include "crypto/ext4crypt/MetadataCrypt.h"
+ #include "MetadataCrypt.h"
#endif
#endif
#endif
@@ -404,13 +402,9 @@
#ifdef TW_INCLUDE_FBE_METADATA_DECRYPT
#ifdef USE_FSCRYPT
if (fscrypt_mount_metadata_encrypted(Decrypt_Data->Actual_Block_Device, Decrypt_Data->Mount_Point, false)) {
- std::string crypto_blkdev =android::base::GetProperty("ro.crypto.fs_crypto_blkdev", "error");
+ std::string crypto_blkdev = android::base::GetProperty("ro.crypto.fs_crypto_blkdev", "error");
Decrypt_Data->Decrypted_Block_Device = crypto_blkdev;
LOGINFO("Successfully decrypted metadata encrypted data partition with new block device: '%s'\n", crypto_blkdev.c_str());
-#else
- if (e4crypt_mount_metadata_encrypted(Decrypt_Data->Mount_Point, false, Decrypt_Data->Key_Directory, Decrypt_Data->Actual_Block_Device, &Decrypt_Data->Decrypted_Block_Device)) {
- LOGINFO("Successfully decrypted metadata encrypted data partition with new block device: '%s'\n",
- Decrypt_Data->Decrypted_Block_Device.c_str());
#endif
Decrypt_Data->Is_Decrypted = true; // Needed to make the mount function work correctly
int retry_count = 10;
@@ -1768,12 +1762,10 @@
dat->Symlink_Path = dat->Storage_Path;
DataManager::SetValue("tw_storage_path", "/data/media/0");
DataManager::SetValue("tw_settings_path", "/data/media/0");
- dat->UnMount(false);
}
DataManager::LoadTWRPFolderInfo();
Update_System_Details();
Output_Partition(dat);
- UnMount_Main_Partitions();
} else
LOGERR("Unable to locate data partition.\n");
}
@@ -1794,8 +1786,9 @@
// Attempt to get name of user. Fallback to user ID if this fails.
char* userFile = PageManager::LoadFileToBuffer("/data/system/users/" + to_string(userId) + ".xml", NULL);
- if (userFile == NULL)
+ if (userFile == NULL) {
user.userName = to_string(userId);
+ }
else {
xml_document<> *userXml = new xml_document<>();
userXml->parse<0>(userFile);