From 79ae093c82ec6f714719ccdc97b03e1c184bdc01 Mon Sep 17 00:00:00 2001 From: James Christopher Adduono Date: Tue, 25 Oct 2016 02:18:32 -0400 Subject: MD5 verification sanity We can use switches and enums to make things more understandable and work with results in a more sensible manner. PS2: Move file MD5 verification and error handling into a separate function to reduce code. PS3: Default to false in Check_Restore_File_MD5 function Change-Id: Id3ee0bb444cf13be67bb5dec2c43f7c26a86b954 (cherry picked from commit 5c3950716e5c7c6279efd5f3f338d6d22e5215e2) --- twrpDigest.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'twrpDigest.hpp') diff --git a/twrpDigest.hpp b/twrpDigest.hpp index 7ec25edad..ec4a65f75 100644 --- a/twrpDigest.hpp +++ b/twrpDigest.hpp @@ -20,6 +20,14 @@ extern "C" { #include "digest/md5.h" } +/* verify_md5digest return codes */ +enum { + MD5_MATCH_FAIL = -2, // -2: md5 did not match + MD5_NOT_FOUND, // -1: no md5 file found + MD5_OK, // 0: md5 matches + MD5_FILE_UNREADABLE // 1: md5 file unreadable +}; + using namespace std; class twrpDigest -- cgit v1.2.3