Add support for multi-user decryption
* Add CLI support using the command "twrp decrypt <PASSWORD> [USER ID]"
* Add GUI support using the menu Advanced --> Decrypt User
Change-Id: Id2681bc2b1012a0571417f7a6e0b980b1b25c61c
diff --git a/partitions.hpp b/partitions.hpp
index 5a52fa3..424e7dd 100755
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -300,6 +300,13 @@
friend class PageManager;
};
+struct users_struct {
+ std::string userId;
+ std::string userName;
+ int type;
+ bool isDecrypted;
+};
+
class TWPartitionManager
{
public:
@@ -336,7 +343,8 @@
int Repair_By_Path(string Path, bool Display_Error); // Repairs a partition based on path
int Resize_By_Path(string Path, bool Display_Error); // Resizes a partition based on path
void Update_System_Details(); // Updates fstab, file systems, sizes, etc.
- int Decrypt_Device(string Password); // Attempt to decrypt any encrypted partitions
+ int Decrypt_Device(string Password, int user_id = 0); // Attempt to decrypt any encrypted partitions
+ void Parse_Users(); // Parse FBE users
int usb_storage_enable(void); // Enable USB storage mode
int usb_storage_disable(void); // Disable USB storage mode
void Mount_All_Storage(void); // Mounts all storage locations
@@ -382,6 +390,7 @@
bool Prepare_Repack(TWPartition* Part, const std::string& Temp_Folder_Destination, const bool Create_Backup, const std::string& Backup_Name); // Prepares an image for repacking by unpacking it to the temp folder destination
bool Prepare_Repack(const std::string& Source_Path, const std::string& Temp_Folder_Destination, const bool Copy_Source, const bool Create_Destination = true); // Prepares an image for repacking by unpacking it to the temp folder destination
bool Repack_Images(const std::string& Target_Image, const struct Repack_Options_struct& Repack_Options); // Repacks the boot image with a new kernel or a new ramdisk
+ std::vector<users_struct>* Get_Users_List(); // Returns pointer to list of users
private:
void Setup_Settings_Storage_Partition(TWPartition* Part); // Sets up settings storage
@@ -400,10 +409,13 @@
int mtp_write_fd;
pid_t tar_fork_pid; // PID of twrpTar fork
Backup_Method_enum Backup_Method; // Method used for backup
+ void Mark_User_Decrypted(int userID); // Marks given user ID in Users_List as decrypted
+ void Check_Users_Decryption_Status(); // Checks to see if all users are decrypted
private:
std::vector<TWPartition*> Partitions; // Vector list of all partitions
string Active_Slot_Display; // Current Active Slot (A or B) for display purposes
+ std::vector<users_struct> Users_List; // List of FBE users
};
extern TWPartitionManager PartitionManager;