summaryrefslogtreecommitdiffstats
path: root/twrpDigestDriver.cpp
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2019-03-29 00:46:56 +0100
committerDees Troy <dees_troy@teamw.in>2019-04-02 05:42:47 +0200
commit718ab39bc5a6016c5d062e06d3cae34f7b710611 (patch)
tree785b783a64b2e01348ea431beb4ff8394fe09fb1 /twrpDigestDriver.cpp
parentCorrect return case for context check in /cache/recovery (diff)
downloadandroid_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.tar
android_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.tar.gz
android_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.tar.bz2
android_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.tar.lz
android_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.tar.xz
android_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.tar.zst
android_bootable_recovery-718ab39bc5a6016c5d062e06d3cae34f7b710611.zip
Diffstat (limited to 'twrpDigestDriver.cpp')
-rwxr-xr-x[-rw-r--r--]twrpDigestDriver.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/twrpDigestDriver.cpp b/twrpDigestDriver.cpp
index c27545c8d..079d0b8f5 100644..100755
--- a/twrpDigestDriver.cpp
+++ b/twrpDigestDriver.cpp
@@ -33,7 +33,7 @@
#include "twrpDigest/twrpSHA.hpp"
-bool twrpDigestDriver::Check_Restore_File_Digest(const string& Filename) {
+bool twrpDigestDriver::Check_File_Digest(const string& Filename) {
twrpDigest *digest;
string digestfile = Filename, file_name = Filename;
string digest_str;
@@ -47,18 +47,31 @@ bool twrpDigestDriver::Check_Restore_File_Digest(const string& Filename) {
use_sha2 = true;
}
else {
- digest = new twrpMD5();
- digestfile = Filename + ".md5";
-
+ digestfile = Filename + ".sha256";
+ if (TWFunc::Path_Exists(digestfile)) {
+ digest = new twrpSHA256();
+ use_sha2 = true;
+ } else {
+ digest = new twrpMD5();
+ digestfile = Filename + ".md5";
+ if (!TWFunc::Path_Exists(digestfile)) {
+ digestfile = Filename + ".md5sum";
+ }
+ }
}
#else
digest = new twrpMD5();
digestfile = Filename + ".md5";
+ if (!TWFunc::Path_Exists(digestfile)) {
+ digestfile = Filename + ".md5sum";
+ }
#endif
if (!TWFunc::Path_Exists(digestfile)) {
- gui_msg(Msg(msg::kError, "no_digest_found=No digest file found for '{1}'. Please unselect Enable Digest verification to restore.")(Filename));
+ if (Filename.find(".zip") == std::string::npos) {
+ gui_msg(Msg(msg::kError, "no_digest_found=No digest file found for '{1}'. Please unselect Enable Digest verification to restore.")(Filename));
+ }
delete digest;
return false;
}
@@ -80,6 +93,7 @@ bool twrpDigestDriver::Check_Restore_File_Digest(const string& Filename) {
LOGINFO("SHA2 Digest: %s %s\n", digest_str.c_str(), TWFunc::Get_Filename(Filename).c_str());
else
LOGINFO("MD5 Digest: %s %s\n", digest_str.c_str(), TWFunc::Get_Filename(Filename).c_str());
+ gui_msg(Msg("digest_matched=Digest matched for '{1}'.")(Filename));
delete digest;
return true;
}
@@ -87,7 +101,6 @@ bool twrpDigestDriver::Check_Restore_File_Digest(const string& Filename) {
gui_msg(Msg(msg::kError, "digest_fail_match=Digest failed to match on '{1}'.")(Filename));
delete digest;
return false;
-
}
bool twrpDigestDriver::Check_Digest(string Full_Filename) {
@@ -103,13 +116,13 @@ bool twrpDigestDriver::Check_Digest(string Full_Filename) {
if (!TWFunc::Path_Exists(split_filename))
break;
LOGINFO("split_filename: %s\n", split_filename);
- if (!Check_Restore_File_Digest(split_filename))
+ if (!Check_File_Digest(split_filename))
return false;
index++;
}
return true;
}
- return Check_Restore_File_Digest(Full_Filename); // Single file archive
+ return Check_File_Digest(Full_Filename); // Single file archive
}
bool twrpDigestDriver::Write_Digest(string Full_Filename) {