From cdcfee48b9720d589a4e2cd43725e8229ca336f9 Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Wed, 27 Feb 2013 21:11:26 -0500 Subject: use md5.c for computation of md5sums create a framework for computing digests and reading digests in TWRP add space for backwards compatibility with bb md5sum Change-Id: Ia18e3f430eed5eba22e5052d39b9b8d88ecd4536 --- partition.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'partition.cpp') diff --git a/partition.cpp b/partition.cpp index e158e0ab8..346c298b2 100644 --- a/partition.cpp +++ b/partition.cpp @@ -41,6 +41,7 @@ #include "partitions.hpp" #include "data.hpp" #include "twrp-functions.hpp" +#include "twrpDigest.hpp" #include "twrpTar.hpp" extern "C" { #include "mtdutils/mtdutils.h" @@ -943,13 +944,15 @@ bool TWPartition::Check_MD5(string restore_folder) { string Full_Filename; char split_filename[512]; int index = 0; + twrpDigest md5sum; Full_Filename = restore_folder + "/" + Backup_FileName; if (!TWFunc::Path_Exists(Full_Filename)) { // This is a split archive, we presume sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index); while (index < 1000 && TWFunc::Path_Exists(split_filename)) { - if (TWFunc::Check_MD5(split_filename) == 0) { + md5sum.setfn(split_filename); + if (md5sum.verify_md5digest() != 0) { LOGE("MD5 failed to match on '%s'.\n", split_filename); return false; } @@ -959,7 +962,8 @@ bool TWPartition::Check_MD5(string restore_folder) { return true; } else { // Single file archive - if (TWFunc::Check_MD5(Full_Filename) == 0) { + md5sum.setfn(Full_Filename); + if (md5sum.verify_md5digest() != 0) { LOGE("MD5 failed to match on '%s'.\n", split_filename); return false; } else @@ -1269,7 +1273,7 @@ bool TWPartition::Backup_Tar(string backup_folder) { unsigned long long total_bsize = 0, file_size; twrpTar tar; vector files; - + if (!Mount(true)) return false; -- cgit v1.2.3