std::cerr << " Expected Hash: " << ExpectedHash.toStr() << std::endl;
}
- if (!ExpectedHash.empty() && !ExpectedHash.VerifyFile(DestFile))
+ if (!ExpectedHash.empty() && ExpectedHash.toStr() != Hash)
{
Status = StatAuthError;
ErrorText = _("Hash Sum mismatch");
string PkgFile = Parse.FileName();
if(Parse.SHA256Hash() != "")
- hash = HashString("SHA256", Parse.SHA256Hash());
+ ExpectedHash = HashString("SHA256", Parse.SHA256Hash());
else if (Parse.SHA1Hash() != "")
- hash = HashString("SHA1", Parse.SHA1Hash());
+ ExpectedHash = HashString("SHA1", Parse.SHA1Hash());
else
- hash = HashString("MD5Sum", Parse.MD5Hash());
+ ExpectedHash = HashString("MD5Sum", Parse.MD5Hash());
if (PkgFile.empty() == true)
return _error->Error(_("The package index files are corrupted. No Filename: "
"field for package %s."),
}
// Check the hash
- if(!hash.VerifyFile(DestFile))
+ if(ExpectedHash.toStr() != CalcHash)
{
Status = StatError;
ErrorText = _("Hash Sum mismatch");
// AcqFile::pkgAcqFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The file is added to the queue */
-pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
+pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
unsigned long Size,string Dsc,string ShortDesc,
const string &DestDir, const string &DestFilename) :
- Item(Owner), hash(MD5)
+ Item(Owner), ExpectedHash(Hash)
{
Retries = _config->FindI("Acquire::Retries",0);
{
Item::Done(Message,Size,CalcHash,Cnf);
- // Check the md5
- if(!hash.VerifyFile(DestFile))
+ // Check the hash
+ if(ExpectedHash.toStr() != CalcHash)
{
Status = StatError;
ErrorText = "Hash Sum mismatch";
pkgAcquire::MethodConfig *Cnf);
virtual string Custom600Headers();
virtual string DescURI() {return RealURI + CompressionExtension;};
+ virtual string HashSum() {return ExpectedHash.toStr(); };
/** \brief Create a pkgAcqIndex.
*
pkgRecords *Recs;
/** \brief The hashsum of this package. */
- HashString hash;
+ HashString ExpectedHash;
/** \brief A location in which the actual filename of the package
* should be stored.
virtual string DescURI() {return Desc.URI;};
virtual string ShortDesc() {return Desc.ShortDesc;};
virtual void Finished();
- virtual string HashSum() {return hash.toStr(); };
+ virtual string HashSum() {return ExpectedHash.toStr(); };
virtual bool IsTrusted();
/** \brief Create a new pkgAcqArchive.
pkgAcquire::ItemDesc Desc;
/** \brief The hashsum of the file to download, if it is known. */
- HashString hash;
+ HashString ExpectedHash;
/** \brief How many times to retry the download, set from
* Acquire::Retries.
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(string Message,unsigned long Size,string CalcHash,
pkgAcquire::MethodConfig *Cnf);
- virtual string HashSum() {return hash.toStr(); };
virtual string DescURI() {return Desc.URI;};
+ virtual string HashSum() {return ExpectedHash.toStr(); };
/** \brief Create a new pkgAcqFile object.
*
TimeRFC1123(Res.LastModified).c_str());
if (Res.MD5Sum.empty() == false)
+ {
End += snprintf(End,sizeof(S)-50 - (End - S),"MD5-Hash: %s\n",Res.MD5Sum.c_str());
+ End += snprintf(End,sizeof(S)-50 - (End - S),"MD5Sum-Hash: %s\n",Res.MD5Sum.c_str());
+ }
if (Res.SHA1Sum.empty() == false)
End += snprintf(End,sizeof(S)-50 - (End - S),"SHA1-Hash: %s\n",Res.SHA1Sum.c_str());
if (Res.SHA256Sum.empty() == false)
_error->Warning("Bizarre Error - File size is not what the server reported %s %lu",
LookupTag(Message,"Size","0").c_str(),TotalSize);
+ // see if there is a hash to verify
+ string RecivedHash;
+ HashString expectedHash(Owner->HashSum());
+ if(!expectedHash.empty())
+ {
+ string hashTag = expectedHash.HashType()+"-Hash";
+ RecivedHash = expectedHash.HashType() + ":" + LookupTag(Message, hashTag.c_str());
+ if(_config->FindB("Debug::pkgAcquire::Auth", false) == true)
+ {
+ clog << "201 URI Done: " << Owner->DescURI() << endl
+ << "RecivedHash: " << RecivedHash << endl
+ << "ExpectedHash: " << expectedHash.toStr()
+ << endl << endl;
+ }
+ }
Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
- LookupTag(Message,"MD5-Hash"),Config);
+ RecivedHash.c_str(), Config);
ItemDone();
// Log that we are done
return;
}
string::size_type pos = StringedHash.find(":");
- Type = StringedHash.substr(0,pos-1);
+ Type = StringedHash.substr(0,pos);
Hash = StringedHash.substr(pos+1, StringedHash.size() - pos);
if(_config->FindB("Debug::Hashes",false) == true)
HashString(string StringedHashString); // init from str as "type:hash"
HashString();
+ // get hash type used
+ string HashType() { return Type; };
+
// verify the given filename against the currently loaded hash
bool VerifyFile(string filename) const;
// See the makefile
#define APT_PKG_MAJOR 4
-#define APT_PKG_MINOR 4
+#define APT_PKG_MINOR 5
#define APT_PKG_RELEASE 0
extern const char *pkgVersion;
# methods/makefile - FIXME
LIBRARY=apt-pkg
LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
-MAJOR=4.4
+MAJOR=4.5
MINOR=0
SLIBS=$(PTHREADLIB) $(INTLLIBS)
APT_DOMAIN:=libapt-pkg$(MAJOR)
BIN := $(BIN)/methods
# FIXME..
-LIB_APT_PKG_MAJOR = 4.4
+LIB_APT_PKG_MAJOR = 4.5
APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR)
# The file method