diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-02-25 13:47:09 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-02-25 13:47:09 +0100 |
commit | d9b9e9e2495fa4cfd9f555cd51a394bad2f98894 (patch) | |
tree | 99b415b32f88e35e3aae398d5ad1890f861a1097 /apt-pkg/contrib | |
parent | 54ce88fd2669a729c89c940be3abc9456d19d542 (diff) | |
parent | 9a961efc5cedeb2b7439114df18e8d0201c83fcf (diff) |
add sha512 support in the client now as well
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r-- | apt-pkg/contrib/hashes.cc | 9 | ||||
-rw-r--r-- | apt-pkg/contrib/hashes.h | 4 |
2 files changed, 11 insertions, 2 deletions
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); |