summaryrefslogtreecommitdiffstats
path: root/partitionmanager.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2018-11-01 21:25:31 +0100
committerEthan Yonker <dees_troy@teamw.in>2019-01-17 21:14:59 +0100
commit933828251d862bc24b888d247a1cb13573e7232b (patch)
tree08fee8a565dc27130b8e998deeb78660083b219f /partitionmanager.cpp
parentlibminuitwrp updates for Pixel 3 devices (diff)
downloadandroid_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.tar
android_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.tar.gz
android_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.tar.bz2
android_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.tar.lz
android_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.tar.xz
android_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.tar.zst
android_bootable_recovery-933828251d862bc24b888d247a1cb13573e7232b.zip
Diffstat (limited to 'partitionmanager.cpp')
-rw-r--r--partitionmanager.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index da407fa69..45460d1dc 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -71,6 +71,9 @@ extern "C" {
#include "gui/pages.hpp"
#ifdef TW_INCLUDE_FBE
#include "crypto/ext4crypt/Decrypt.h"
+ #ifdef TW_INCLUDE_FBE_METADATA_DECRYPT
+ #include "crypto/ext4crypt/MetadataCrypt.h"
+ #endif
#endif
#ifdef TW_CRYPTO_USE_SYSTEM_VOLD
#include "crypto/vold_decrypt/vold_decrypt.h"
@@ -277,6 +280,27 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error)
#ifdef TW_INCLUDE_CRYPTO
TWPartition* Decrypt_Data = Find_Partition_By_Path("/data");
if (Decrypt_Data && Decrypt_Data->Is_Encrypted && !Decrypt_Data->Is_Decrypted) {
+ if (!Decrypt_Data->Key_Directory.empty() && Mount_By_Path(Decrypt_Data->Key_Directory, false)) {
+#ifdef TW_INCLUDE_FBE_METADATA_DECRYPT
+ 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());
+ property_set("ro.crypto.state", "encrypted");
+ Decrypt_Data->Is_Decrypted = true; // Needed to make the mount function work correctly
+ int retry_count = 10;
+ while (!Decrypt_Data->Mount(false) && --retry_count)
+ usleep(500);
+ if (Decrypt_Data->Mount(false)) {
+ Decrypt_Data->Decrypt_FBE_DE();
+ } else {
+ LOGINFO("Failed to mount data after metadata decrypt\n");
+ }
+ } else {
+ LOGINFO("Unable to decrypt metadata encryption\n");
+ }
+#else
+ LOGERR("Metadata FBE decrypt support not present in this TWRP\n");
+#endif
+ }
if (Decrypt_Data->Is_FBE) {
if (DataManager::GetIntValue(TW_CRYPTO_PWTYPE) == 0) {
if (Decrypt_Device("!") == 0) {
@@ -467,6 +491,8 @@ void TWPartitionManager::Output_Partition(TWPartition* Part) {
printf(" Mount_Flags: %i, Mount_Options: %s\n", Part->Mount_Flags, Part->Mount_Options.c_str());
if (Part->MTP_Storage_ID)
printf(" MTP_Storage_ID: %i\n", Part->MTP_Storage_ID);
+ if (!Part->Key_Directory.empty())
+ printf(" Metadata Key Directory: %s\n", Part->Key_Directory.c_str());
printf("\n");
}