#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
#include <apt-pkg/sha256.h>
+#include <apt-pkg/sha512.h>
#include <apt-pkg/deblistparser.h>
#include <sys/types.h>
DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
+ DoSHA256 = _config->FindB("APT::FTPArchive::SHA512",true);
DoAlwaysStat = _config->FindB("APT::FTPArchive::AlwaysStat", false);
DoContents = _config->FindB("APT::FTPArchive::Contents",true);
NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
bool PackagesWriter::DoPackage(string FileName)
{
// Pull all the data we need form the DB
- if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoAlwaysStat)
+ if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoSHA512, DoAlwaysStat)
== false)
{
return false;
SetTFRewriteData(Changes[End++], "MD5sum", Db.MD5Res.c_str());
SetTFRewriteData(Changes[End++], "SHA1", Db.SHA1Res.c_str());
SetTFRewriteData(Changes[End++], "SHA256", Db.SHA256Res.c_str());
+ SetTFRewriteData(Changes[End++], "SHA512", Db.SHA512Res.c_str());
SetTFRewriteData(Changes[End++], "Filename", NewFileName.c_str());
SetTFRewriteData(Changes[End++], "Priority", OverItem->Priority.c_str());
SetTFRewriteData(Changes[End++], "Status", 0);
SHA1Summation SHA1;
SHA256Summation SHA256;
+ SHA512Summation SHA512;
SHA1.Add((unsigned char *)Start,BlkEnd - Start);
SHA256.Add((unsigned char *)Start,BlkEnd - Start);
+ SHA512.Add((unsigned char *)Start,BlkEnd - Start);
// Add an extra \n to the end, just in case
*BlkEnd++ = '\n';
<< strippedName << "\n " << Tags.FindS("Checksums-Sha256");
string const ChecksumsSha256 = ostreamSha256.str();
+ std::ostringstream ostreamSha512;
+ if (Tags.Exists("Checksums-Sha512"))
+ ostreamSha512 << "\n " << string(SHA512.Result()) << " " << St.st_size << " "
+ << strippedName << "\n " << Tags.FindS("Checksums-Sha512");
+ string const ChecksumsSha512 = ostreamSha512.str();
+
// Strip the DirStrip prefix from the FileName and add the PathPrefix
string NewFileName;
if (DirStrip.empty() == false &&
SetTFRewriteData(Changes[End++],"Files",Files.c_str());
SetTFRewriteData(Changes[End++],"Checksums-Sha1",ChecksumsSha1.c_str());
SetTFRewriteData(Changes[End++],"Checksums-Sha256",ChecksumsSha256.c_str());
+ SetTFRewriteData(Changes[End++],"Checksums-Sha512",ChecksumsSha512.c_str());
if (Directory != "./")
SetTFRewriteData(Changes[End++],"Directory",Directory.c_str());
SetTFRewriteData(Changes[End++],"Priority",BestPrio.c_str());
SHA256.AddFD(fd.Fd(), fd.Size());
CheckSums[NewFileName].SHA256 = SHA256.Result();
+ SHA256Summation SHA512;
+ SHA256.AddFD(fd.Fd(), fd.Size());
+ CheckSums[NewFileName].SHA512 = SHA512.Result();
+
fd.Close();
return true;
(*I).second.size,
(*I).first.c_str());
}
+
+ fprintf(Output, "SHA512:\n");
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
+ I != CheckSums.end();
+ ++I)
+ {
+ fprintf(Output, " %s %32ld %s\n",
+ (*I).second.SHA512.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
+
}