diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 6 | ||||
-rw-r--r-- | apt-pkg/acquire-method.cc | 8 | ||||
-rw-r--r-- | apt-pkg/acquire-method.h | 1 | ||||
-rw-r--r-- | apt-pkg/contrib/hashes.cc | 9 | ||||
-rw-r--r-- | apt-pkg/contrib/hashes.h | 4 | ||||
-rw-r--r-- | apt-pkg/deb/debrecords.cc | 10 | ||||
-rw-r--r-- | apt-pkg/deb/debrecords.h | 1 | ||||
-rw-r--r-- | apt-pkg/pkgrecords.h | 1 | ||||
-rw-r--r-- | apt-pkg/tagfile.cc | 1 |
9 files changed, 36 insertions, 5 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index d4df31e85..05e2f28a4 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1665,6 +1665,8 @@ bool pkgAcqArchive::QueueNext() string PkgFile = Parse.FileName(); if (ForceHash.empty() == false) { + if(stringcasecmp(ForceHash, "sha512") == 0) + ExpectedHash = HashString("SHA512", Parse.SHA512Hash()); if(stringcasecmp(ForceHash, "sha256") == 0) ExpectedHash = HashString("SHA256", Parse.SHA256Hash()); else if (stringcasecmp(ForceHash, "sha1") == 0) @@ -1675,7 +1677,9 @@ bool pkgAcqArchive::QueueNext() else { string Hash; - if ((Hash = Parse.SHA256Hash()).empty() == false) + if ((Hash = Parse.SHA512Hash()).empty() == false) + ExpectedHash = HashString("SHA512", Hash); + else if ((Hash = Parse.SHA256Hash()).empty() == false) ExpectedHash = HashString("SHA256", Hash); else if ((Hash = Parse.SHA1Hash()).empty() == false) ExpectedHash = HashString("SHA1", Hash); diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 17d52cf51..bf3beafa2 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -187,6 +187,8 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt) End += snprintf(End,sizeof(S)-50 - (End - S),"SHA1-Hash: %s\n",Res.SHA1Sum.c_str()); if (Res.SHA256Sum.empty() == false) End += snprintf(End,sizeof(S)-50 - (End - S),"SHA256-Hash: %s\n",Res.SHA256Sum.c_str()); + if (Res.SHA512Sum.empty() == false) + End += snprintf(End,sizeof(S)-50 - (End - S),"SHA512-Hash: %s\n",Res.SHA512Sum.c_str()); if (UsedMirror.empty() == false) End += snprintf(End,sizeof(S)-50 - (End - S),"UsedMirror: %s\n",UsedMirror.c_str()); if (Res.GPGVOutput.size() > 0) @@ -224,7 +226,10 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt) if (Alt->SHA256Sum.empty() == false) End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-SHA256-Hash: %s\n", Alt->SHA256Sum.c_str()); - + if (Alt->SHA512Sum.empty() == false) + End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-SHA512-Hash: %s\n", + Alt->SHA512Sum.c_str()); + if (Alt->IMSHit == true) strcat(End,"Alt-IMS-Hit: true\n"); } @@ -500,5 +505,6 @@ void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash) MD5Sum = Hash.MD5.Result(); SHA1Sum = Hash.SHA1.Result(); SHA256Sum = Hash.SHA256.Result(); + SHA512Sum = Hash.SHA512.Result(); } /*}}}*/ diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 03851e823..f6bf83842 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -45,6 +45,7 @@ class pkgAcqMethod string MD5Sum; string SHA1Sum; string SHA256Sum; + string SHA512Sum; vector<string> GPGVOutput; time_t LastModified; bool IMSHit; diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 985d89d90..66ae33146 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -23,7 +23,7 @@ const char* HashString::_SupportedHashes[] = { - "SHA256", "SHA1", "MD5Sum", NULL + "SHA512", "SHA256", "SHA1", "MD5Sum", NULL }; HashString::HashString() @@ -57,6 +57,7 @@ bool HashString::VerifyFile(string filename) const /*{{{*/ MD5Summation MD5; SHA1Summation SHA1; SHA256Summation SHA256; + SHA256Summation SHA512; string fileHash; FileFd Fd(filename, FileFd::ReadOnly); @@ -75,6 +76,11 @@ bool HashString::VerifyFile(string filename) const /*{{{*/ SHA256.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA256.Result(); } + else if (Type == "SHA512") + { + SHA512.AddFD(Fd.Fd(), Fd.Size()); + fileHash = (string)SHA512.Result(); + } Fd.Close(); if(_config->FindB("Debug::Hashes",false) == true) @@ -119,6 +125,7 @@ bool Hashes::AddFD(int Fd,unsigned long Size) MD5.Add(Buf,Res); SHA1.Add(Buf,Res); SHA256.Add(Buf,Res); + SHA512.Add(Buf,Res); } return true; } diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 264f7fe90..b3587e02a 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -17,6 +17,7 @@ #include <apt-pkg/md5.h> #include <apt-pkg/sha1.h> #include <apt-pkg/sha256.h> +#include <apt-pkg/sha512.h> #include <algorithm> #include <vector> @@ -60,10 +61,11 @@ class Hashes MD5Summation MD5; SHA1Summation SHA1; SHA256Summation SHA256; + SHA512Summation SHA512; inline bool Add(const unsigned char *Data,unsigned long Size) { - return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size); + return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size); }; inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; bool AddFD(int Fd,unsigned long Size); diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index ec9e395ef..1ca9ae1d2 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -77,7 +77,7 @@ string debRecordParser::SHA1Hash() return Section.FindS("SHA1"); } /*}}}*/ -// RecordParser::SHA1Hash - Return the archive hash /*{{{*/ +// RecordParser::SHA256Hash - Return the archive hash /*{{{*/ // --------------------------------------------------------------------- /* */ string debRecordParser::SHA256Hash() @@ -85,6 +85,14 @@ string debRecordParser::SHA256Hash() return Section.FindS("SHA256"); } /*}}}*/ +// RecordParser::SHA512Hash - Return the archive hash /*{{{*/ +// --------------------------------------------------------------------- +/* */ +string debRecordParser::SHA512Hash() +{ + return Section.FindS("SHA512"); +} + /*}}}*/ // RecordParser::Maintainer - Return the maintainer email /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index 6f358abfa..05159ea1e 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -36,6 +36,7 @@ class debRecordParser : public pkgRecords::Parser virtual string MD5Hash(); virtual string SHA1Hash(); virtual string SHA256Hash(); + virtual string SHA512Hash(); virtual string SourcePkg(); virtual string SourceVer(); diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index c2c98188a..2d994211d 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -58,6 +58,7 @@ class pkgRecords::Parser /*{{{*/ virtual string MD5Hash() {return string();}; virtual string SHA1Hash() {return string();}; virtual string SHA256Hash() {return string();}; + virtual string SHA512Hash() {return string();}; virtual string SourcePkg() {return string();}; virtual string SourceVer() {return string();}; diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 4a2f3f7e6..b7245073d 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -457,6 +457,7 @@ static const char *iTFRewritePackageOrder[] = { "MD5Sum", "SHA1", "SHA256", + "SHA512", "MSDOS-Filename", // Obsolete "Description", 0}; |