Decrypt FBE on 9.0 (backwards compatible)

Building in 9.0 may require you to add a flag to your twrp fstab
with the fileencryption details like:
fileencryption=ice:aes-256-heh

Verify this against your device's stock fstab of course.

Change-Id: If9286f5d5787280814daca9fbc8f5191ff26a839
This commit is contained in:
Ethan Yonker
2018-08-30 15:16:27 -05:00
parent 58f2132bc3
commit e9afc3de0f
46 changed files with 2643 additions and 47 deletions
+20
View File
@@ -130,6 +130,7 @@ enum TW_FSTAB_FLAGS {
TWFLAG_CANENCRYPTBACKUP,
TWFLAG_DISPLAY,
TWFLAG_ENCRYPTABLE,
TWFLAG_FILEENCRYPTION,
TWFLAG_FLASHIMG,
TWFLAG_FORCEENCRYPT,
TWFLAG_FSFLAGS,
@@ -172,6 +173,7 @@ const struct flag_list tw_flags[] = {
{ "defaults", TWFLAG_DEFAULTS },
{ "display=", TWFLAG_DISPLAY },
{ "encryptable=", TWFLAG_ENCRYPTABLE },
{ "fileencryption=", TWFLAG_FILEENCRYPTION },
{ "flashimg", TWFLAG_FLASHIMG },
{ "forceencrypt=", TWFLAG_FORCEENCRYPT },
{ "fsflags=", TWFLAG_FSFLAGS },
@@ -822,6 +824,24 @@ void TWPartition::Apply_TW_Flag(const unsigned flag, const char* str, const bool
case TWFLAG_FORCEENCRYPT:
Crypto_Key_Location = str;
break;
case TWFLAG_FILEENCRYPTION:
// This flag isn't used by TWRP but is needed in 9.0 FBE decrypt
// fileencryption=ice:aes-256-heh
{
std::string FBE = str;
std::string FBE_contents, FBE_filenames;
size_t colon_loc = FBE.find(":");
if (colon_loc == std::string::npos) {
LOGINFO("Invalid fileencryption fstab flag: '%s'\n", str);
break;
}
FBE_contents = FBE.substr(0, colon_loc);
FBE_filenames = FBE.substr(colon_loc + 1);
property_set("fbe.contents", FBE_contents.c_str());
property_set("fbe.filenames", FBE_filenames.c_str());
LOGINFO("FBE contents '%s', filenames '%s'\n", FBE_contents.c_str(), FBE_filenames.c_str());
}
break;
case TWFLAG_FLASHIMG:
Can_Flash_Img = val;
break;