diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-01-07 20:36:53 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-01-14 13:10:36 +0100 |
commit | 79de3008ebfc6b4a5dd32e9de1d19788da0b885d (patch) | |
tree | 277129f384746a11c25a08d1b0b879c41fe207ad /ftparchive | |
parent | b350560e34a369ef7610f9fceeffb00660209390 (diff) |
Convert users of {MD5,SHA1,SHA256,SHA512}Summation to use Hashes
This makes use of the a function GetHashString() that returns
the specific hash string. We also need to implement another overload
of Add() for signed chars with sizes, so the existing users do not
require reinterpret_cast everywhere.
Diffstat (limited to 'ftparchive')
-rw-r--r-- | ftparchive/multicompress.cc | 9 | ||||
-rw-r--r-- | ftparchive/writer.cc | 4 |
2 files changed, 6 insertions, 7 deletions
diff --git a/ftparchive/multicompress.cc b/ftparchive/multicompress.cc index f5fe14164..cdaa7a60a 100644 --- a/ftparchive/multicompress.cc +++ b/ftparchive/multicompress.cc @@ -18,8 +18,7 @@ #include <apt-pkg/aptconfiguration.h> #include <apt-pkg/error.h> #include <apt-pkg/fileutl.h> -#include <apt-pkg/hashsum_template.h> -#include <apt-pkg/md5.h> +#include <apt-pkg/hashes.h> #include <apt-pkg/strutl.h> #include <ctype.h> @@ -267,7 +266,7 @@ bool MultiCompress::Child(int const &FD) SetNonBlock(FD,false); unsigned char Buffer[32*1024]; unsigned long long FileSize = 0; - MD5Summation MD5; + Hashes MD5(Hashes::MD5SUM); while (1) { WaitFd(FD,false); @@ -315,7 +314,7 @@ bool MultiCompress::Child(int const &FD) } // Compute the hash - MD5Summation OldMD5; + Hashes OldMD5(Hashes::MD5SUM); unsigned long long NewFileSize = 0; while (1) { @@ -330,7 +329,7 @@ bool MultiCompress::Child(int const &FD) CompFd.Close(); // Check the hash - if (OldMD5.Result() == MD5.Result() && + if (OldMD5.GetHashString(Hashes::MD5SUM) == MD5.GetHashString(Hashes::MD5SUM) && FileSize == NewFileSize) { for (Files *I = Outputs; I != 0; I = I->Next) diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 078638c41..edf548f3a 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -493,9 +493,9 @@ bool PackagesWriter::DoPackage(string FileName) string DescriptionMd5; if (LongDescription == false) { - MD5Summation descmd5; + Hashes descmd5(Hashes::MD5SUM); descmd5.Add(desc.c_str()); - DescriptionMd5 = descmd5.Result().Value(); + DescriptionMd5 = descmd5.GetHashString(Hashes::MD5SUM).HashValue(); Changes.push_back(pkgTagSection::Tag::Rewrite("Description-md5", DescriptionMd5)); if (TransWriter != NULL) TransWriter->DoPackage(Package, desc, DescriptionMd5); |