From 2dcf7b8f9b9e037901339ddef7d94a6a2bab90db Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 14 Jul 2011 01:44:35 +0200 Subject: fix sha512 calculation in Hashes::VerifyFiles() --- apt-pkg/contrib/hashes.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'apt-pkg/contrib/hashes.cc') diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index d217747df..4407574fa 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -53,31 +53,30 @@ HashString::HashString(string StringedHash) /*{{{*/ /*}}}*/ bool HashString::VerifyFile(string filename) const /*{{{*/ { - FileFd fd; - MD5Summation MD5; - SHA1Summation SHA1; - SHA256Summation SHA256; - SHA256Summation SHA512; string fileHash; FileFd Fd(filename, FileFd::ReadOnly); - if(Type == "MD5Sum") + if(Type == "MD5Sum") { + MD5Summation MD5; MD5.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)MD5.Result(); - } + } else if (Type == "SHA1") { + SHA1Summation SHA1; SHA1.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA1.Result(); - } - else if (Type == "SHA256") + } + else if (Type == "SHA256") { + SHA256Summation SHA256; SHA256.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA256.Result(); } - else if (Type == "SHA512") + else if (Type == "SHA512") { + SHA512Summation SHA512; SHA512.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA512.Result(); } -- cgit v1.2.3