]> git.saurik.com Git - apt.git/commitdiff
add sha512 support in the client now as well
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 25 Feb 2011 12:47:09 +0000 (13:47 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 25 Feb 2011 12:47:09 +0000 (13:47 +0100)
1  2 
apt-pkg/acquire-item.cc
apt-pkg/acquire-method.cc
apt-pkg/acquire-method.h
apt-pkg/contrib/hashes.cc
apt-pkg/contrib/hashes.h
apt-pkg/deb/debrecords.cc
apt-pkg/deb/debrecords.h
apt-pkg/pkgrecords.h
apt-pkg/tagfile.cc
cmdline/apt-get.cc

index d4df31e85bc067f8267c340a48e929bac176ff46,d4df31e85bc067f8267c340a48e929bac176ff46..05e2f28a472ca8f696d3a65e5182a5d36a8d3dac
@@@ -1665,6 -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)
        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);
index 17d52cf518b6c4f81c42706e8d30873dd7854946,17d52cf518b6c4f81c42706e8d30873dd7854946..bf3beafa25aebfb81d15e4d1ac226b0424eb7c11
@@@ -187,6 -187,6 +187,8 @@@ void pkgAcqMethod::URIDone(FetchResult 
        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)
        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 -500,5 +505,6 @@@ void pkgAcqMethod::FetchResult::TakeHas
     MD5Sum = Hash.MD5.Result();
     SHA1Sum = Hash.SHA1.Result();
     SHA256Sum = Hash.SHA256.Result();
++   SHA512Sum = Hash.SHA512.Result();
  }
                                                                        /*}}}*/
index 03851e8239657451abab188a9f883282395e2bab,03851e8239657451abab188a9f883282395e2bab..f6bf83842fe42414e0bae968de855935f51957ad
@@@ -45,6 -45,6 +45,7 @@@ class pkgAcqMetho
        string MD5Sum;
        string SHA1Sum;
        string SHA256Sum;
++      string SHA512Sum;
        vector<string> GPGVOutput;
        time_t LastModified;
        bool IMSHit;
index 985d89d903ea502c448d28aa2bb819c121d8eb64,985d89d903ea502c448d28aa2bb819c121d8eb64..66ae33146403b44bfd71ffc73af02ec741674843
@@@ -23,7 -23,7 +23,7 @@@
  
  const char* HashString::_SupportedHashes[] = 
  {
--   "SHA256", "SHA1", "MD5Sum", NULL
++   "SHA512", "SHA256", "SHA1", "MD5Sum", NULL
  };
  
  HashString::HashString()
@@@ -57,6 -57,6 +57,7 @@@ bool HashString::VerifyFile(string file
     MD5Summation MD5;
     SHA1Summation SHA1;
     SHA256Summation SHA256;
++   SHA256Summation SHA512;
     string fileHash;
  
     FileFd Fd(filename, FileFd::ReadOnly);
        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 -119,6 +125,7 @@@ bool Hashes::AddFD(int Fd,unsigned lon
        MD5.Add(Buf,Res);
        SHA1.Add(Buf,Res);
        SHA256.Add(Buf,Res);
++      SHA512.Add(Buf,Res);
     }
     return true;
  }
index 264f7fe904434d2cd2dd995311405cda3d6f9291,264f7fe904434d2cd2dd995311405cda3d6f9291..b3587e02a59f264bdd4d678614538280d8dfaf2b
@@@ -17,6 -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 -60,10 +61,11 @@@ class Hashe
     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);
index ec9e395ef9d1e636d5456affc2e28941fea55257,ec9e395ef9d1e636d5456affc2e28941fea55257..1ca9ae1d2d602d83c6aedfe4c1b73f0cd8ffdff6
@@@ -77,7 -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()
     return Section.FindS("SHA256");
  }
                                                                        /*}}}*/
++// RecordParser::SHA512Hash - Return the archive hash                 /*{{{*/
++// ---------------------------------------------------------------------
++/* */
++string debRecordParser::SHA512Hash()
++{
++   return Section.FindS("SHA512");
++}
++                                                                      /*}}}*/
  // RecordParser::Maintainer - Return the maintainer email             /*{{{*/
  // ---------------------------------------------------------------------
  /* */
index 6f358abfa3225b5a2034fbb88ea1de20a63a689d,6f358abfa3225b5a2034fbb88ea1de20a63a689d..05159ea1eaae1caa78d6a015d382dc410863c5b4
@@@ -36,6 -36,6 +36,7 @@@ class debRecordParser : public pkgRecor
     virtual string MD5Hash();
     virtual string SHA1Hash();
     virtual string SHA256Hash();
++   virtual string SHA512Hash();
     virtual string SourcePkg();
     virtual string SourceVer();
     
index c2c98188a7e12fce76b512c767e56f1c9b256c21,c2c98188a7e12fce76b512c767e56f1c9b256c21..2d994211db38ae1f7c1306d03f0af43d3b5cfd6e
@@@ -58,6 -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();};
  
index 4a2f3f7e6ed76e3063f64142bb88ff0d1d6320bf,4a2f3f7e6ed76e3063f64142bb88ff0d1d6320bf..b7245073d3152237d22f36e95fea31244d797316
@@@ -457,6 -457,6 +457,7 @@@ static const char *iTFRewritePackageOrd
                            "MD5Sum",
                            "SHA1",
                            "SHA256",
++                          "SHA512",
                             "MSDOS-Filename",   // Obsolete
                            "Description",
                            0};
index e93d12c2b908b9b43e986d9e779f9a60884bbf8b,e93d12c2b908b9b43e986d9e779f9a60884bbf8b..61efa5601e42c0adab34710853749b2ec303b2c9
@@@ -2239,6 -2239,6 +2239,8 @@@ bool DoDownload(CommandLine &CmdL
        strprintf(descr, _("Downloading %s %s"), Pkg.Name(), Ver.VerStr());
        // get the most appropriate hash
        HashString hash;
++      if (rec.SHA512Hash() != "")
++         hash = HashString("sha512", rec.SHA512Hash());
        if (rec.SHA256Hash() != "")
           hash = HashString("sha256", rec.SHA256Hash());
        else if (rec.SHA1Hash() != "")