twrpDigest refactor
This patch is to refactor twrpDigest using polymorphism and inheritance to use the same call patterns for creating and reading a digest. Now a library. Use SHA2 from libcrypto. SHA2 is default if device has libcrypto. Change string MD5 everywhere to use digest or Digest instead. Updated string tags to digest. Translation will be required. Switch out digest code into a driver class from partitionmanager. SHA2 is better for digest creation due to decreased collision space compared to MD5 and SHA1. See https://en.wikipedia.org/wiki/SHA-2 Change-Id: I74b5546789990b12aa4ce2e389d25f80a3fe213f
This commit is contained in:
committed by
Ethan Yonker
parent
92e2531dca
commit
56cf564658
@@ -194,7 +194,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
// Restore
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@restore}"));
|
||||
PartitionManager.Mount_All_Storage();
|
||||
DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_DIGEST_CHECK_VAR, 0);
|
||||
char folder_path[512], partitions[512];
|
||||
|
||||
string val = value, restore_folder, restore_partitions;
|
||||
@@ -277,8 +277,8 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
Restore_List += "/sd-ext;";
|
||||
gui_msg("sdext=SD-EXT");
|
||||
} else if (value2[i] == 'M' || value2[i] == 'm') {
|
||||
DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 1);
|
||||
gui_msg("md5_check_skip=MD5 check skip is on");
|
||||
DataManager::SetValue(TW_SKIP_DIGEST_CHECK_VAR, 1);
|
||||
gui_msg("digest_check_skip=Digest check skip is on");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ int OpenRecoveryScript::Backup_ADB_Command(std::string Options) {
|
||||
args = TWFunc::Split_String(Options, " ");
|
||||
|
||||
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_DIGEST_GENERATE_VAR, 0);
|
||||
|
||||
if (args[1].compare("--twrp") != 0) {
|
||||
gui_err("twrp_adbbu_option=--twrp option is required to enable twrp adb backup");
|
||||
@@ -608,7 +608,7 @@ int OpenRecoveryScript::Backup_Command(string Options) {
|
||||
strcpy(value1, Options.c_str());
|
||||
|
||||
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_DIGEST_GENERATE_VAR, 0);
|
||||
|
||||
gui_msg("select_backup_opt=Setting backup options:");
|
||||
line_len = Options.size();
|
||||
@@ -644,8 +644,8 @@ int OpenRecoveryScript::Backup_Command(string Options) {
|
||||
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 1);
|
||||
gui_msg("compression_on=Compression is on");
|
||||
} else if (Options.substr(i, 1) == "M" || Options.substr(i, 1) == "m") {
|
||||
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 1);
|
||||
gui_msg("md5_off=MD5 Generation is off");
|
||||
DataManager::SetValue(TW_SKIP_DIGEST_GENERATE_VAR, 1);
|
||||
gui_msg("digest_off=Digest Generation is off");
|
||||
}
|
||||
}
|
||||
DataManager::SetValue("tw_backup_list", Backup_List);
|
||||
@@ -756,7 +756,7 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) {
|
||||
part_settings.total_restore_size = 0;
|
||||
|
||||
PartitionManager.Mount_All_Storage();
|
||||
DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_DIGEST_CHECK_VAR, 0);
|
||||
|
||||
LOGINFO("opening TW_ADB_BU_CONTROL\n");
|
||||
adb_control_bu_fd = open(TW_ADB_BU_CONTROL, O_WRONLY | O_NONBLOCK);
|
||||
|
||||
Reference in New Issue
Block a user