path: root/utils/nwztools/upgtools/mg.cpp
diff options
authorAmaury Pouly <>2020-08-10 23:09:46 +0200
committerAmaury Pouly <>2020-10-11 13:08:03 +0200
commit8ce60c54f762b2f1392bee586dc8292170c87696 (patch)
treed979e6ebe4a54b07c57a9995cf2973118504e799 /utils/nwztools/upgtools/mg.cpp
parent7cba59910669062b320eb57d831f3a9c50efb364 (diff)
nwztools/upgtool: add support for MD5
When compressing, it is possible to tell the tool to add an entry to the MD5 file (index 1), it is still necessary to give an empty file for that index. To do so, pass the option "-z idx,name" insteas of "-z idx". This will create an entry of the form "size md5 name". For instance "-z 6,system.img". When decompressing, if one passes "-z idx,name" instead of "-z idx", the tool will decompress and check against the value in the MD5 file. Change-Id: Ifb945f6121644ae9105265d2d83ce6067301c5b2
Diffstat (limited to 'utils/nwztools/upgtools/mg.cpp')
1 files changed, 18 insertions, 0 deletions
diff --git a/utils/nwztools/upgtools/mg.cpp b/utils/nwztools/upgtools/mg.cpp
index df2dbbfd4f..a4d06cd77f 100644
--- a/utils/nwztools/upgtools/mg.cpp
+++ b/utils/nwztools/upgtools/mg.cpp
@@ -215,6 +215,24 @@ void MD5_CalculateDigest(void *digest, const void *input, size_t length)
MD5().CalculateDigest((byte *)digest, (const byte *)input, length);
+void *md5_start()
+ return new MD5;
+void md5_update(void *md5_obj, const void *input, size_t length)
+ MD5 *md5 = reinterpret_cast<MD5 *>(md5_obj);
+ md5->Update(reinterpret_cast<const uint8_t *>(input), length);
+void md5_final(void *md5_obj, void *digest)
+ MD5 *md5 = reinterpret_cast<MD5 *>(md5_obj);
+ md5->Final(reinterpret_cast<uint8_t *>(digest));
+ delete md5;
void mg_decrypt_fw(void *in, int size, void *out, uint8_t *key)
ECB_Mode< DES >::Decryption dec;