summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostyantyn Ovechko <fastinetserver@gmail.com>2010-06-27 19:49:48 +0300
committerKostyantyn Ovechko <fastinetserver@gmail.com>2010-06-27 19:49:48 +0300
commit4e33ccd81a8d481a26241b63055bc60e0261ac8f (patch)
treefd545394f19ce506e78486b5d558c9bb84206cd4
parentFailprove pkg.cpp and log errors to error.log (diff)
downloadidfetch-4e33ccd81a8d481a26241b63055bc60e0261ac8f.tar.gz
idfetch-4e33ccd81a8d481a26241b63055bc60e0261ac8f.tar.bz2
idfetch-4e33ccd81a8d481a26241b63055bc60e0261ac8f.zip
Failprove checksum.cpp and log errors to error.log
-rw-r--r--segget/checksum.cpp173
1 files changed, 104 insertions, 69 deletions
diff --git a/segget/checksum.cpp b/segget/checksum.cpp
index c09cd87..34f5fd3 100644
--- a/segget/checksum.cpp
+++ b/segget/checksum.cpp
@@ -14,93 +14,128 @@
#include "str.cpp"
bool rmd160_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::RIPEMD160 hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::RIPEMD160 hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : rmd160_ok()");
return false;
+ }
}
bool sha1_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::SHA1 hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
-// debug("SHA1:"+noupper(digest));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::SHA1 hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+// debug("SHA1:"+noupper(digest));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : sha1_ok()");
return false;
+ }
}
bool sha256_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::SHA256 hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
-// debug("SHA256:"+noupper(digest));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::SHA256 hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+// debug("SHA256:"+noupper(digest));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : sha256_ok()");
return false;
+ }
}
bool sha512_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::SHA512 hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
-// debug("SHA256:"+noupper(digest));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::SHA512 hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+// debug("SHA256:"+noupper(digest));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : sha512_ok()");
return false;
+ }
}
bool whirlpool_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::Whirlpool hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
-// debug("SHA256:"+noupper(digest));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::Whirlpool hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+// debug("SHA256:"+noupper(digest));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : whirlpool_ok()");
return false;
+ }
}
bool md5_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::Weak::MD5 hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
-// debug("SHA256:"+noupper(digest));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::Weak::MD5 hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+// debug("SHA256:"+noupper(digest));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : md5_ok()");
return false;
+ }
}
bool crc32_ok(string distfile_filename, string portage_hash){
- std::string digest;
- CryptoPP::CRC32 hash;
- CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
- new CryptoPP::HashFilter(hash,
- new CryptoPP::HexEncoder(
- new CryptoPP::StringSink(digest))));
-// debug("SHA256:"+noupper(digest));
- if (portage_hash==noupper(digest))
- return true;
- else
+ try{
+ std::string digest;
+ CryptoPP::CRC32 hash;
+ CryptoPP::FileSource distfile_to_hash(distfile_filename.c_str(), true,
+ new CryptoPP::HashFilter(hash,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink(digest))));
+// debug("SHA256:"+noupper(digest));
+ if (portage_hash==noupper(digest))
+ return true;
+ else
+ return false;
+ }catch(...){
+ error_log("Error in checksum.cpp : crc32_ok()");
return false;
+ }
}
#endif \ No newline at end of file