Remove ENABLE_MESSAGE_DIGEST, since we got the internal md, always

pull/220/merge
Nils Maier 2014-04-17 01:36:19 +02:00
parent befd799d17
commit 010131161e
55 changed files with 65 additions and 399 deletions

View File

@ -531,15 +531,6 @@ AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"])
if test "x$use_md" != "x"; then
AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
[Define to 1 if message digest support is enabled.])
AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
enable_message_digest=yes
else
AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
fi
if test "x$have_libgmp" = "xyes" ||
test "x$have_libgcrypt" = "xyes" ||
test "x$have_openssl" = "xyes"; then
@ -558,8 +549,7 @@ else
AM_CONDITIONAL([USE_INTERNAL_ARC4], true)
fi
if test "x$enable_bittorrent" = "xyes" &&
test "x$enable_message_digest" = "xyes"; then
if test "x$enable_bittorrent" = "xyes"; then
AC_DEFINE([ENABLE_BITTORRENT], [1],
[Define to 1 if BitTorrent support is enabled.])
AM_CONDITIONAL([ENABLE_BITTORRENT], true)
@ -940,15 +930,13 @@ if test "x$have_option_const_name" = "xyes"; then
fi
AC_CONFIG_SUBDIRS([deps/wslay])
if test "x$enable_message_digest" = "xyes"; then
enable_websocket=yes
AC_DEFINE([ENABLE_WEBSOCKET], [1],
[Define 1 if WebSocket support is enabled.])
WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
AC_SUBST([WSLAY_LIBS])
# $(top_srcdir) for `make distcheck`
CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
fi
enable_websocket=yes
AC_DEFINE([ENABLE_WEBSOCKET], [1],
[Define 1 if WebSocket support is enabled.])
WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
AC_SUBST([WSLAY_LIBS])
# $(top_srcdir) for `make distcheck`
CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])

View File

@ -66,13 +66,11 @@
#include "FileEntry.h"
#include "error_code.h"
#include "SocketRecvBuffer.h"
#include "ChecksumCheckIntegrityEntry.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
#include "AsyncNameResolverMan.h"
#endif // ENABLE_ASYNC_DNS
#ifdef ENABLE_MESSAGE_DIGEST
# include "ChecksumCheckIntegrityEntry.h"
#endif // ENABLE_MESSAGE_DIGEST
namespace aria2 {

View File

@ -359,7 +359,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
}
}
}
#ifdef ENABLE_MESSAGE_DIGEST
{
auto& entry = e->getCheckIntegrityMan()->getPickedEntry();
if(entry) {
@ -378,7 +377,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
}
}
}
#endif // ENABLE_MESSAGE_DIGEST
if(isTTY_) {
if (truncate_) {
auto str = o.str(color, cols);

View File

@ -66,6 +66,7 @@
#include "fmt.h"
#include "console.h"
#include "UriListParser.h"
#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
@ -73,9 +74,6 @@
# include "metalink_helper.h"
# include "MetalinkEntry.h"
#endif // ENABLE_METALINK
#ifdef ENABLE_MESSAGE_DIGEST
# include "message_digest_helper.h"
#endif // ENABLE_MESSAGE_DIGEST
extern char* optarg;
extern int optind, opterr, optopt;

View File

@ -347,13 +347,8 @@ void DefaultBtProgressInfoFile::load()
((size_t)bitfieldLength);
READ_CHECK(fp, pieceBitfield.get(), bitfieldLength);
piece->setBitfield(pieceBitfield.get(), bitfieldLength);
#ifdef ENABLE_MESSAGE_DIGEST
piece->setHashType(dctx_->getPieceHashType());
#endif // ENABLE_MESSAGE_DIGEST
inFlightPieces.push_back(piece);
}
pieceStorage_->addInFlightPiece(inFlightPieces);

View File

@ -113,12 +113,8 @@ std::shared_ptr<Piece> DefaultPieceStorage::checkOutPiece
std::shared_ptr<Piece> piece = findUsedPiece(index);
if(!piece) {
piece.reset(new Piece(index, bitfieldMan_->getBlockLength(index)));
#ifdef ENABLE_MESSAGE_DIGEST
piece->setHashType(downloadContext_->getPieceHashType());
#endif // ENABLE_MESSAGE_DIGEST
addUsedPiece(piece);
}
piece->addUser(cuid);
@ -780,12 +776,8 @@ void DefaultPieceStorage::markPiecesDone(int64_t length)
p->completeBlock(i);
}
#ifdef ENABLE_MESSAGE_DIGEST
p->setHashType(downloadContext_->getPieceHashType());
#endif // ENABLE_MESSAGE_DIGEST
addUsedPiece(p);
}
}

View File

@ -65,10 +65,8 @@
#include "Piece.h"
#include "WrDiskCacheEntry.h"
#include "DownloadFailureException.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
# include "message_digest_helper.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
@ -86,7 +84,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid,
lowestDownloadSpeedLimit_(0),
pieceHashValidationEnabled_(false)
{
#ifdef ENABLE_MESSAGE_DIGEST
{
if(getOption()->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM)) {
const std::string& algo = getDownloadContext()->getPieceHashType();
@ -96,7 +93,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid,
}
}
}
#endif // ENABLE_MESSAGE_DIGEST
peerStat_ = req->initPeerStat();
peerStat_->downloadStart();
@ -236,8 +232,6 @@ bool DownloadCommand::executeInternal() {
A2_LOG_INFO(fmt(MSG_SEGMENT_DOWNLOAD_COMPLETED,
getCuid()));
#ifdef ENABLE_MESSAGE_DIGEST
{
const std::string& expectedPieceHash =
getDownloadContext()->getPieceHash(segment->getIndex());
@ -270,9 +264,6 @@ bool DownloadCommand::executeInternal() {
}
}
#else // !ENABLE_MESSAGE_DIGEST
completeSegment(getCuid(), segment);
#endif // !ENABLE_MESSAGE_DIGEST
} else {
// If segment is not canceled here, in the next pipelining
// request, aria2 requests bad range
@ -319,7 +310,6 @@ bool DownloadCommand::prepareForNextSegment() {
getFileEntry()->setLength(getPieceStorage()->getCompletedLength());
}
}
#ifdef ENABLE_MESSAGE_DIGEST
if(getDownloadContext()->getPieceHashType().empty()) {
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
if(entry->isValidationReady()) {
@ -329,7 +319,6 @@ bool DownloadCommand::prepareForNextSegment() {
(std::move(entry));
}
}
#endif // ENABLE_MESSAGE_DIGEST
// Following 2lines are needed for DownloadEngine to detect
// completed RequestGroups without 1sec delay.
getDownloadEngine()->setNoWait(true);
@ -370,8 +359,6 @@ bool DownloadCommand::prepareForNextSegment() {
}
}
#ifdef ENABLE_MESSAGE_DIGEST
void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
const std::string& expectedHash,
const std::string& actualHash)
@ -393,8 +380,6 @@ void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
}
}
#endif // ENABLE_MESSAGE_DIGEST
void DownloadCommand::completeSegment(cuid_t cuid,
const std::shared_ptr<Segment>& segment)
{

View File

@ -43,9 +43,7 @@ namespace aria2 {
class PeerStat;
class StreamFilter;
#ifdef ENABLE_MESSAGE_DIGEST
class MessageDigest;
#endif // ENABLE_MESSAGE_DIGEST
class DownloadCommand : public AbstractCommand {
private:
@ -53,9 +51,7 @@ private:
std::unique_ptr<StreamFilter> streamFilter_;
#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<MessageDigest> messageDigest_;
#endif // ENABLE_MESSAGE_DIGEST
time_t startupIdleTime_;

View File

@ -43,9 +43,7 @@
#include "FileAllocationMan.h"
#include "CheckIntegrityMan.h"
#include "CheckIntegrityEntry.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "CheckIntegrityDispatcherCommand.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "CheckIntegrityDispatcherCommand.h"
#include "prefs.h"
#include "FillRequestGroupCommand.h"
#include "FileAllocationDispatcherCommand.h"
@ -157,19 +155,15 @@ DownloadEngineFactory::newDownloadEngine
e->setRequestGroupMan(std::move(requestGroupMan));
}
e->setFileAllocationMan(make_unique<FileAllocationMan>());
#ifdef ENABLE_MESSAGE_DIGEST
e->setCheckIntegrityMan(make_unique<CheckIntegrityMan>());
#endif // ENABLE_MESSAGE_DIGEST
e->addRoutineCommand(make_unique<FillRequestGroupCommand>
(e->newCUID(), e.get()));
e->addRoutineCommand(make_unique<FileAllocationDispatcherCommand>
(e->newCUID(), e->getFileAllocationMan().get(),
e.get()));
#ifdef ENABLE_MESSAGE_DIGEST
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
(e->newCUID(), e->getCheckIntegrityMan().get(),
e.get()));
#endif // ENABLE_MESSAGE_DIGEST
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
e->addRoutineCommand

View File

@ -141,11 +141,7 @@ const char* strSupportedFeature(int feature)
break;
case(FEATURE_MESSAGE_DIGEST):
#ifdef ENABLE_MESSAGE_DIGEST
return "Message Digest";
#else // !ENABLE_MESSAGE_DIGEST
return 0;
#endif // !ENABLE_MESSAGE_DIGEST
break;
case(FEATURE_METALINK):

View File

@ -75,9 +75,7 @@
#include "error_code.h"
#include "SocketRecvBuffer.h"
#include "NullProgressInfoFile.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "ChecksumCheckIntegrityEntry.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "ChecksumCheckIntegrityEntry.h"
namespace aria2 {
@ -386,7 +384,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
if(getDownloadContext()->knowsTotalLength() &&
getRequestGroup()->downloadFinishedByFileLength()) {
#ifdef ENABLE_MESSAGE_DIGEST
// TODO Known issue: if .aria2 file exists, it will not be
// deleted on successful verification, because .aria2 file is
// not loaded. See also
@ -401,9 +398,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
getDownloadEngine()->getCheckIntegrityMan()->pushEntry
(std::move(entry));
sequence_ = SEQ_EXIT;
} else
#endif // ENABLE_MESSAGE_DIGEST
{
}
else {
getPieceStorage()->markAllPiecesDone();
getDownloadContext()->setChecksumVerified(true);
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
@ -423,7 +419,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
if(getDownloadContext()->knowsTotalLength()) {
A2_LOG_DEBUG("File length becomes zero and it means download completed.");
#ifdef ENABLE_MESSAGE_DIGEST
// TODO Known issue: if .aria2 file exists, it will not be
// deleted on successful verification, because .aria2 file is
// not loaded. See also
@ -437,7 +432,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
(std::move(entry));
sequence_ = SEQ_EXIT;
} else
#endif // ENABLE_MESSAGE_DIGEST
{
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
getPieceStorage()->markAllPiecesDone();

View File

@ -50,15 +50,11 @@ void GrowSegment::updateWrittenLength(int32_t bytes)
piece_->setAllBlock();
}
#ifdef ENABLE_MESSAGE_DIGEST
std::string GrowSegment::getDigest()
{
return A2STR::NIL;
}
#endif // ENABLE_MESSAGE_DIGEST
void GrowSegment::clear(WrDiskCache* diskCache)
{
writtenLength_ = 0;

View File

@ -85,8 +85,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
#ifdef ENABLE_MESSAGE_DIGEST
virtual bool updateHash
(int32_t begin,
const unsigned char* data,
@ -102,8 +100,6 @@ public:
virtual std::string getDigest() CXX11_OVERRIDE;
#endif // ENABLE_MESSAGE_DIGEST
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;

View File

@ -59,9 +59,7 @@
#include "MetalinkHttpEntry.h"
#include "base64.h"
#include "array_fun.h"
#ifdef ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#ifdef HAVE_ZLIB
# include "GZipDecodingStreamFilter.h"
#endif // HAVE_ZLIB
@ -395,7 +393,6 @@ void HttpResponse::getMetalinKHttpEntries(
std::sort(result.begin(), result.end());
}
#ifdef ENABLE_MESSAGE_DIGEST
// Digest header field is defined by
// http://tools.ietf.org/html/rfc3230.
void HttpResponse::getDigest(std::vector<Checksum>& result) const
@ -445,6 +442,5 @@ void HttpResponse::getDigest(std::vector<Checksum>& result) const
}
std::swap(temp, result);
}
#endif // ENABLE_MESSAGE_DIGEST
} // namespace aria2

View File

@ -125,13 +125,11 @@ public:
void getMetalinKHttpEntries(std::vector<MetalinkHttpEntry>& result,
const std::shared_ptr<Option>& option) const;
#ifdef ENABLE_MESSAGE_DIGEST
// Returns all digests specified in Digest header field. Sort
// strong algorithm first. Strength is defined in MessageDigest. If
// several same digest algorithms are available, but they have
// different value, they are all ignored.
void getDigest(std::vector<Checksum>& result) const;
#endif // ENABLE_MESSAGE_DIGEST
};

View File

@ -75,10 +75,8 @@
#include "SocketRecvBuffer.h"
#include "MetalinkHttpEntry.h"
#include "NullProgressInfoFile.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "Checksum.h"
# include "ChecksumCheckIntegrityEntry.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "Checksum.h"
#include "ChecksumCheckIntegrityEntry.h"
#ifdef HAVE_ZLIB
# include "GZipDecodingStreamFilter.h"
#endif // HAVE_ZLIB
@ -210,7 +208,6 @@ bool HttpResponseCommand::executeInternal()
}
}
#ifdef ENABLE_MESSAGE_DIGEST
if (httpHeader->defined(HttpHeader::DIGEST)) {
std::vector<Checksum> checksums;
httpResponse->getDigest(checksums);
@ -228,7 +225,6 @@ bool HttpResponseCommand::executeInternal()
}
}
}
#endif // ENABLE_MESSAGE_DIGEST
}
if(statusCode >= 300) {
@ -280,7 +276,6 @@ bool HttpResponseCommand::executeInternal()
return handleDefaultEncoding(std::move(httpResponse));
}
#ifdef ENABLE_MESSAGE_DIGEST
if (!ctx->getHashType().empty() && httpHeader->defined(HttpHeader::DIGEST)) {
std::vector<Checksum> checksums;
httpResponse->getDigest(checksums);
@ -290,7 +285,6 @@ bool HttpResponseCommand::executeInternal()
}
}
}
#endif // ENABLE_MESSAGE_DIGEST
// validate totalsize
grp->validateTotalLength(fe->getLength(), httpResponse->getEntityLength());
@ -424,7 +418,6 @@ bool HttpResponseCommand::handleOtherEncoding(
getRequestGroup()->downloadFinishedByFileLength()) {
getRequestGroup()->initPieceStorage();
#ifdef ENABLE_MESSAGE_DIGEST
// TODO Known issue: if .aria2 file exists, it will not be deleted
// on successful verification, because .aria2 file is not loaded.
// See also FtpNegotiationCommand::onFileSizeDetermined()
@ -434,9 +427,8 @@ bool HttpResponseCommand::handleOtherEncoding(
entry->initValidator();
getPieceStorage()->getDiskAdaptor()->openExistingFile();
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
} else
#endif // ENABLE_MESSAGE_DIGEST
{
}
else {
getPieceStorage()->markAllPiecesDone();
getDownloadContext()->setChecksumVerified(true);
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
@ -459,14 +451,12 @@ bool HttpResponseCommand::handleOtherEncoding(
// TODO Known issue: if .aria2 file exists, it will not be deleted
// on successful verification, because .aria2 file is not loaded.
// See also FtpNegotiationCommand::onFileSizeDetermined()
#ifdef ENABLE_MESSAGE_DIGEST
if (getDownloadContext()->isChecksumVerificationNeeded()) {
A2_LOG_DEBUG("Verify checksum for zero-length file");
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
entry->initValidator();
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
} else
#endif // ENABLE_MESSAGE_DIGEST
{
getRequestGroup()->getPieceStorage()->markAllPiecesDone();
}
@ -572,7 +562,6 @@ void HttpResponseCommand::onDryRunFileFound()
poolConnection();
}
#ifdef ENABLE_MESSAGE_DIGEST
bool HttpResponseCommand::checkChecksum(
const std::shared_ptr<DownloadContext>& dctx, const Checksum& checksum)
{
@ -586,6 +575,5 @@ bool HttpResponseCommand::checkChecksum(
return false;
}
#endif // ENABLE_MESSAGE_DIGEST
} // namespace aria2

View File

@ -45,9 +45,7 @@ class HttpDownloadCommand;
class HttpResponse;
class SocketCore;
class StreamFilter;
#ifdef ENABLE_MESSAGE_DIGEST
class Checksum;
#endif // ENABLE_MESSAGE_DIGEST
// HttpResponseCommand receives HTTP response header from remote
// server. Because network I/O is non-blocking, execute() returns
@ -76,13 +74,11 @@ private:
void poolConnection();
void onDryRunFileFound();
#ifdef ENABLE_MESSAGE_DIGEST
// Returns true if dctx and checksum has same hash type and hash
// value. If they have same hash type but different hash value,
// throws exception. Otherwise returns false.
bool checkChecksum(const std::shared_ptr<DownloadContext>& dctx,
const Checksum& checksum);
#endif // ENABLE_MESSAGE_DIGEST
protected:
bool executeInternal() CXX11_OVERRIDE;

View File

@ -51,10 +51,8 @@
#include "fmt.h"
#include "SocketRecvBuffer.h"
#include "base64.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
# include "message_digest_helper.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#include "message_digest_helper.h"
#ifdef ENABLE_WEBSOCKET
# include "WebSocketResponseCommand.h"
#endif // ENABLE_WEBSOCKET

View File

@ -251,7 +251,18 @@ SRCS = option_processing.cc\
HttpProxyRequestConnectChain.h\
FtpNegotiationConnectChain.h\
FtpTunnelRequestConnectChain.h\
Lock.h
Lock.h \
IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
IteratableChecksumValidator.cc IteratableChecksumValidator.h\
CheckIntegrityDispatcherCommand.cc CheckIntegrityDispatcherCommand.h\
CheckIntegrityCommand.cc CheckIntegrityCommand.h\
ChecksumCheckIntegrityEntry.cc ChecksumCheckIntegrityEntry.h\
message_digest_helper.cc message_digest_helper.h\
Checksum.cc Checksum.h\
ChunkChecksum.cc ChunkChecksum.h\
MessageDigest.cc MessageDigest.h\
MessageDigestImpl.h\
HashFuncEntry.h
if ANDROID
SRCS += android/android.c
@ -403,20 +414,6 @@ SRCS += AsyncNameResolver.cc AsyncNameResolver.h\
AsyncNameResolverMan.cc AsyncNameResolverMan.h
endif # ENABLE_ASYNC_DNS
if ENABLE_MESSAGE_DIGEST
SRCS += IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
IteratableChecksumValidator.cc IteratableChecksumValidator.h\
CheckIntegrityDispatcherCommand.cc CheckIntegrityDispatcherCommand.h\
CheckIntegrityCommand.cc CheckIntegrityCommand.h\
ChecksumCheckIntegrityEntry.cc ChecksumCheckIntegrityEntry.h\
message_digest_helper.cc message_digest_helper.h\
Checksum.cc Checksum.h\
ChunkChecksum.cc ChunkChecksum.h\
MessageDigest.cc MessageDigest.h\
MessageDigestImpl.h\
HashFuncEntry.h
endif # ENABLE_MESSAGE_DIGEST
if ENABLE_BITTORRENT
SRCS += PeerAbstractCommand.cc PeerAbstractCommand.h\
PeerInitiateConnectionCommand.cc PeerInitiateConnectionCommand.h\

View File

@ -64,10 +64,8 @@
# include "BtDependency.h"
# include "download_helper.h"
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_MESSAGE_DIGEST
# include "Checksum.h"
# include "ChunkChecksum.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "Checksum.h"
#include "ChunkChecksum.h"
namespace aria2 {
@ -255,15 +253,11 @@ Metalink2RequestGroup::createRequestGroup
// If piece hash is specified in the metalink,
// make segment size equal to piece hash size.
int32_t pieceLength;
#ifdef ENABLE_MESSAGE_DIGEST
if(!entry->chunkChecksum) {
pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
} else {
pieceLength = entry->chunkChecksum->getPieceLength();
}
#else
pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
#endif // ENABLE_MESSAGE_DIGEST
dctx = std::make_shared<DownloadContext>
(pieceLength,
entry->getLength(),
@ -274,7 +268,6 @@ Metalink2RequestGroup::createRequestGroup
if(option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL)) {
dctx->getFirstFileEntry()->setUniqueProtocol(true);
}
#ifdef ENABLE_MESSAGE_DIGEST
if(entry->checksum) {
dctx->setDigest(entry->checksum->getHashType(),
entry->checksum->getDigest());
@ -285,7 +278,6 @@ Metalink2RequestGroup::createRequestGroup
std::begin(entry->chunkChecksum->getPieceHashes()),
std::end(entry->chunkChecksum->getPieceHashes()));
}
#endif // ENABLE_MESSAGE_DIGEST
dctx->setSignature(entry->popSignature());
rg->setNumConcurrentCommand
(entry->maxConnections < 0 ?

View File

@ -41,10 +41,8 @@
#include "FileEntry.h"
#include "util.h"
#include "a2functional.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "Checksum.h"
# include "ChunkChecksum.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "Checksum.h"
#include "ChunkChecksum.h"
#include "Signature.h"
#include "SimpleRandomizer.h"

View File

@ -46,10 +46,8 @@ namespace aria2 {
class MetalinkResource;
class MetalinkMetaurl;
class FileEntry;
#ifdef ENABLE_MESSAGE_DIGEST
class Checksum;
class ChunkChecksum;
#endif // ENABLE_MESSAGE_DIGEST
class Signature;
class MetalinkEntry {
@ -63,10 +61,9 @@ public:
std::vector<std::unique_ptr<MetalinkResource>> resources;
std::vector<std::unique_ptr<MetalinkMetaurl>> metaurls;
int maxConnections; // Metalink3Spec
#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<Checksum> checksum;
std::unique_ptr<ChunkChecksum> chunkChecksum;
#endif // ENABLE_MESSAGE_DIGEST
private:
std::unique_ptr<Signature> signature_;
public:

View File

@ -46,11 +46,9 @@
#include "uri.h"
#include "Signature.h"
#include "util.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "Checksum.h"
# include "ChunkChecksum.h"
# include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "Checksum.h"
#include "ChunkChecksum.h"
#include "MessageDigest.h"
#ifdef ENABLE_BITTORRENT
# include "magnet.h"
#endif // ENABLE_BITTORRENT
@ -78,11 +76,9 @@ void MetalinkParserController::newEntryTransaction()
tEntry_ = make_unique<MetalinkEntry>();
tResource_.reset();
tMetaurl_.reset();
#ifdef ENABLE_MESSAGE_DIGEST
tChecksum_.reset();
tChunkChecksumV4_.reset();
tChunkChecksum_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setFileNameOfEntry(std::string filename)
@ -263,17 +259,14 @@ void MetalinkParserController::cancelResourceTransaction()
void MetalinkParserController::newChecksumTransaction()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tEntry_) {
return;
}
tChecksum_ = make_unique<Checksum>();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setTypeOfChecksum(std::string type)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChecksum_) {
return;
}
@ -283,12 +276,10 @@ void MetalinkParserController::setTypeOfChecksum(std::string type)
} else {
cancelChecksumTransaction();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setHashOfChecksum(std::string md)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChecksum_) {
return;
}
@ -297,12 +288,10 @@ void MetalinkParserController::setHashOfChecksum(std::string md)
} else {
cancelChecksumTransaction();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::commitChecksumTransaction()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChecksum_) {
return;
}
@ -312,30 +301,24 @@ void MetalinkParserController::commitChecksumTransaction()
tEntry_->checksum = std::move(tChecksum_);
}
tChecksum_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::cancelChecksumTransaction()
{
#ifdef ENABLE_MESSAGE_DIGEST
tChecksum_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::newChunkChecksumTransactionV4()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tEntry_) {
return;
}
tChunkChecksumV4_ = make_unique<ChunkChecksum>();
tempChunkChecksumsV4_.clear();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@ -345,12 +328,10 @@ void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
} else {
cancelChunkChecksumTransactionV4();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@ -359,12 +340,10 @@ void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
} else {
cancelChunkChecksumTransactionV4();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@ -373,12 +352,10 @@ void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
} else {
cancelChunkChecksumTransactionV4();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::commitChunkChecksumTransactionV4()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@ -389,30 +366,24 @@ void MetalinkParserController::commitChunkChecksumTransactionV4()
tEntry_->chunkChecksum = std::move(tChunkChecksumV4_);
}
tChunkChecksumV4_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::cancelChunkChecksumTransactionV4()
{
#ifdef ENABLE_MESSAGE_DIGEST
tChunkChecksumV4_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::newChunkChecksumTransaction()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tEntry_) {
return;
}
tChunkChecksum_ = make_unique<ChunkChecksum>();
tempChunkChecksums_.clear();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@ -422,12 +393,10 @@ void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
} else {
cancelChunkChecksumTransaction();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@ -436,13 +405,11 @@ void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
} else {
cancelChunkChecksumTransaction();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::addHashOfChunkChecksum(size_t order,
std::string md)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@ -451,22 +418,18 @@ void MetalinkParserController::addHashOfChunkChecksum(size_t order,
} else {
cancelChunkChecksumTransaction();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::createNewHashOfChunkChecksum(size_t order)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
tempHashPair_.first = order;
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@ -475,22 +438,18 @@ void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
} else {
cancelChunkChecksumTransaction();
}
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::addHashOfChunkChecksum()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
tempChunkChecksums_.push_back(tempHashPair_);
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::commitChunkChecksumTransaction()
{
#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@ -508,14 +467,11 @@ void MetalinkParserController::commitChunkChecksumTransaction()
tEntry_->chunkChecksum = std::move(tChunkChecksum_);
}
tChunkChecksum_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::cancelChunkChecksumTransaction()
{
#ifdef ENABLE_MESSAGE_DIGEST
tChunkChecksum_.reset();
#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::newSignatureTransaction()

View File

@ -50,10 +50,8 @@ class MetalinkResource;
class MetalinkMetaurl;
class Signature;
#ifdef ENABLE_MESSAGE_DIGEST
class Checksum;
class ChunkChecksum;
#endif // ENABLE_MESSAGE_DIGEST
class MetalinkParserController {
private:
@ -64,7 +62,7 @@ private:
std::unique_ptr<MetalinkResource> tResource_;
std::unique_ptr<MetalinkMetaurl> tMetaurl_;
#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<Checksum> tChecksum_;
std::unique_ptr<ChunkChecksum> tChunkChecksumV4_; // Metalink4Spec
@ -77,8 +75,6 @@ private:
std::pair<size_t, std::string> tempHashPair_; // Metalink3Spec
#endif // ENABLE_MESSAGE_DIGEST
std::unique_ptr<Signature> tSignature_;
std::string baseUri_;
public:

View File

@ -194,7 +194,6 @@ void VerificationMetalinkParserState::beginElement
if(!checkNsUri(nsUri)) {
psm->setSkipTagState();
} else
#ifdef ENABLE_MESSAGE_DIGEST
if(strcmp(localname, "hash") == 0) {
psm->setHashState();
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
@ -231,7 +230,6 @@ void VerificationMetalinkParserState::beginElement
psm->setLengthOfChunkChecksum(length);
psm->setTypeOfChunkChecksum(type);
} else
#endif // ENABLE_MESSAGE_DIGEST
if(strcmp(localname, "signature") == 0) {
psm->setSignatureState();
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);

View File

@ -166,7 +166,6 @@ void FileMetalinkParserStateV4::beginElement
psm->setLocationOfResource(location);
psm->setPriorityOfResource(priority);
}
#ifdef ENABLE_MESSAGE_DIGEST
else if(strcmp(localname, "hash") == 0) {
psm->setHashStateV4();
auto itr = findAttr(attrs, "type", METALINK4_NAMESPACE_URI);
@ -203,7 +202,6 @@ void FileMetalinkParserStateV4::beginElement
psm->setLengthOfChunkChecksumV4(length);
psm->setTypeOfChunkChecksumV4(type);
}
#endif // ENABLE_MESSAGE_DIGEST
else if(strcmp(localname, "signature") == 0) {
psm->setSignatureStateV4();
auto itr = findAttr(attrs, "mediatype", METALINK4_NAMESPACE_URI);

View File

@ -140,7 +140,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_CHECK_INTEGRITY,
@ -158,7 +157,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_CONDITIONAL_GET,
@ -426,7 +424,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setInitialOption(true);
handlers.push_back(op);
}
#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_HASH_CHECK_ONLY,
@ -443,7 +440,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_HUMAN_READABLE,
@ -693,7 +689,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_REALTIME_CHUNK_CHECKSUM,
@ -707,7 +702,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_REMOVE_CONTROL_FILE,
@ -914,7 +908,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op);
}
// HTTP/FTP options
#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new ChecksumOptionHandler
(PREF_CHECKSUM,
@ -926,7 +919,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new NumberOptionHandler
(PREF_CONNECT_TIMEOUT,

View File

@ -61,9 +61,7 @@
#include "SegList.h"
#include "array_fun.h"
#include "help_tags.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
namespace aria2 {
@ -368,7 +366,6 @@ std::string IndexOutOptionHandler::createPossibleValuesString() const
return "INDEX=PATH";
}
#ifdef ENABLE_MESSAGE_DIGEST
ChecksumOptionHandler::ChecksumOptionHandler
(PrefPtr pref,
const char* description,
@ -397,7 +394,6 @@ std::string ChecksumOptionHandler::createPossibleValuesString() const
{
return "HASH_TYPE=HEX_DIGEST";
}
#endif // ENABLE_MESSAGE_DIGEST
ParameterOptionHandler::ParameterOptionHandler
(PrefPtr pref,

View File

@ -172,7 +172,6 @@ public:
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
};
#ifdef ENABLE_MESSAGE_DIGEST
class ChecksumOptionHandler : public AbstractOptionHandler {
public:
ChecksumOptionHandler(PrefPtr pref,
@ -183,7 +182,6 @@ public:
CXX11_OVERRIDE;
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
};
#endif // ENABLE_MESSAGE_DIGEST
class ParameterOptionHandler : public AbstractOptionHandler {
private:

View File

@ -46,9 +46,7 @@
#include "LogFactory.h"
#include "fmt.h"
#include "DiskAdaptor.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
namespace aria2 {
@ -58,9 +56,7 @@ Piece::Piece()
index_(0),
length_(0),
blockLength_(BLOCK_LENGTH),
#ifdef ENABLE_MESSAGE_DIGEST
nextBegin_(0),
#endif // ENABLE_MESSAGE_DIGEST
usedBySegment_(false)
{}
@ -70,9 +66,7 @@ Piece::Piece(size_t index, int32_t length, int32_t blockLength)
index_(index),
length_(length),
blockLength_(blockLength),
#ifdef ENABLE_MESSAGE_DIGEST
nextBegin_(0),
#endif // ENABLE_MESSAGE_DIGEST
nextBegin_(0),
usedBySegment_(false)
{}
@ -208,8 +202,6 @@ int32_t Piece::getCompletedLength()
return bitfield_->getCompletedLength();
}
#ifdef ENABLE_MESSAGE_DIGEST
void Piece::setHashType(const std::string& hashType)
{
hashType_ = hashType;
@ -304,8 +296,6 @@ void Piece::destroyHashContext()
nextBegin_ = 0;
}
#endif // ENABLE_MESSAGE_DIGEST
bool Piece::usedBy(cuid_t cuid) const
{
return std::find(users_.begin(), users_.end(), cuid) != users_.end();

View File

@ -50,32 +50,21 @@ class BitfieldMan;
class WrDiskCache;
class WrDiskCacheEntry;
class DiskAdaptor;
#ifdef ENABLE_MESSAGE_DIGEST
class MessageDigest;
#endif // ENABLE_MESSAGE_DIGEST
class Piece {
private:
BitfieldMan* bitfield_;
WrDiskCacheEntry* wrCache_;
#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<MessageDigest> mdctx_;
#endif // ENABLE_MESSAGE_DIGEST
std::vector<cuid_t> users_;
#ifdef ENABLE_MESSAGE_DIGEST
std::string hashType_;
#endif // ENABLE_MESSAGE_DIGEST
size_t index_;
int32_t length_;
int32_t blockLength_;
#ifdef ENABLE_MESSAGE_DIGEST
int32_t nextBegin_;
#endif // ENABLE_MESSAGE_DIGEST
bool usedBySegment_;
@ -158,8 +147,6 @@ public:
// Calculates completed length
int32_t getCompletedLength();
#ifdef ENABLE_MESSAGE_DIGEST
void setHashType(const std::string& hashType);
// Updates hash value. This function compares begin and private variable
@ -181,8 +168,6 @@ public:
// cached data and data on disk.
std::string getDigestWithWrCache(size_t pieceLength,
const std::shared_ptr<DiskAdaptor>& adaptor);
#endif // ENABLE_MESSAGE_DIGEST
/**
* Loses current bitfield state.
*/

View File

@ -58,13 +58,11 @@ bool PieceHashCheckIntegrityEntry::isValidationReady()
void PieceHashCheckIntegrityEntry::initValidator()
{
#ifdef ENABLE_MESSAGE_DIGEST
auto validator = make_unique<IteratableChunkChecksumValidator>
(getRequestGroup()->getDownloadContext(),
getRequestGroup()->getPieceStorage());
validator->init();
setValidator(std::move(validator));
#endif // ENABLE_MESSAGE_DIGEST
}
} // namespace aria2

View File

@ -90,8 +90,6 @@ void PiecedSegment::updateWrittenLength(int32_t bytes)
writtenLength_ = newWrittenLength;
}
#ifdef ENABLE_MESSAGE_DIGEST
bool PiecedSegment::updateHash
(int32_t begin,
const unsigned char* data,
@ -110,18 +108,12 @@ std::string PiecedSegment::getDigest()
return piece_->getDigest();
}
#endif // ENABLE_MESSAGE_DIGEST
void PiecedSegment::clear(WrDiskCache* diskCache)
{
writtenLength_ = 0;
piece_->clearAllBlock(diskCache);
#ifdef ENABLE_MESSAGE_DIGEST
piece_->destroyHashContext();
#endif // ENABLE_MESSAGE_DIGEST
}
std::shared_ptr<Piece> PiecedSegment::getPiece() const

View File

@ -76,8 +76,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
#ifdef ENABLE_MESSAGE_DIGEST
// `begin' is a offset inside this segment.
virtual bool updateHash
(int32_t begin,
@ -88,8 +86,6 @@ public:
virtual std::string getDigest() CXX11_OVERRIDE;
#endif // ENABLE_MESSAGE_DIGEST
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;

View File

@ -79,10 +79,8 @@
#include "Segment.h"
#include "SocketRecvBuffer.h"
#include "RequestGroupCriteria.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "CheckIntegrityCommand.h"
# include "ChecksumCheckIntegrityEntry.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "CheckIntegrityCommand.h"
#include "ChecksumCheckIntegrityEntry.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
# include "BtRegistry.h"
@ -240,14 +238,12 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
// issue checksum verification and download fails without it.
loadAndOpenFile(infoFile);
if(downloadFinished()) {
#ifdef ENABLE_MESSAGE_DIGEST
if(downloadContext_->isChecksumVerificationNeeded()) {
A2_LOG_INFO(MSG_HASH_CHECK_NOT_DONE);
auto tempEntry = make_unique<ChecksumCheckIntegrityEntry>(this);
tempEntry->setRedownload(true);
return std::move(tempEntry);
}
#endif // ENABLE_MESSAGE_DIGEST
downloadContext_->setChecksumVerified(true);
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
gid_->toHex().c_str(),
@ -257,7 +253,6 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
return make_unique<StreamCheckIntegrityEntry>(this);
}
#ifdef ENABLE_MESSAGE_DIGEST
if (downloadFinishedByFileLength() &&
downloadContext_->isChecksumVerificationAvailable()) {
pieceStorage_->markAllPiecesDone();
@ -266,7 +261,6 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
tempEntry->setRedownload(true);
return std::move(tempEntry);
}
#endif // ENABLE_MESSAGE_DIGEST
loadAndOpenFile(infoFile);
return make_unique<StreamCheckIntegrityEntry>(this);
@ -520,7 +514,6 @@ void RequestGroup::processCheckIntegrityEntry(
if(actualFileSize > downloadContext_->getTotalLength()) {
entry->cutTrailingGarbage();
}
#ifdef ENABLE_MESSAGE_DIGEST
if((option_->getAsBool(PREF_CHECK_INTEGRITY) ||
downloadContext_->isChecksumVerificationNeeded()) &&
entry->isValidationReady()) {
@ -535,7 +528,6 @@ void RequestGroup::processCheckIntegrityEntry(
e->getCheckIntegrityMan()->pushEntry(std::move(entry));
return;
}
#endif // ENABLE_MESSAGE_DIGEST
entry->onDownloadIncomplete(commands, e);
}
@ -664,16 +656,12 @@ void RequestGroup::adjustFilename(
outfile.size() <= downloadContext_->getTotalLength()) {
// File exists but user decided to resume it.
}
#ifdef ENABLE_MESSAGE_DIGEST
else if(outfile.exists() && isCheckIntegrityReady()) {
// check-integrity existing file
}
#endif // ENABLE_MESSAGE_DIGEST
else {
shouldCancelDownloadForSafety();
#ifdef ENABLE_MESSAGE_DIGEST
}
#endif // ENABLE_MESSAGE_DIGEST
}
void RequestGroup::removeDefunctControlFile(
@ -709,11 +697,9 @@ void RequestGroup::loadAndOpenFile(
pieceStorage_->getDiskAdaptor()->openExistingFile();
pieceStorage_->markPiecesDone(outfile.size());
}
#ifdef ENABLE_MESSAGE_DIGEST
else if (outfile.exists() && isCheckIntegrityReady()) {
pieceStorage_->getDiskAdaptor()->openExistingFile();
}
#endif // ENABLE_MESSAGE_DIGEST
else {
pieceStorage_->getDiskAdaptor()->initAndOpenFile();
}

View File

@ -66,10 +66,8 @@
#include "base64.h"
#include "BitfieldMan.h"
#include "SessionSerializer.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
# include "message_digest_helper.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
# include "BtRegistry.h"
@ -254,7 +252,6 @@ std::unique_ptr<ValueBase> AddUriRpcMethod::process
}
}
#ifdef ENABLE_MESSAGE_DIGEST
namespace {
std::string getHexSha1(const std::string& s)
{
@ -264,7 +261,6 @@ std::string getHexSha1(const std::string& s)
return util::toHex(hash, sizeof(hash));
}
} // namespace
#endif // ENABLE_MESSAGE_DIGEST
#ifdef ENABLE_BITTORRENT
std::unique_ptr<ValueBase> AddTorrentRpcMethod::process
@ -341,7 +337,6 @@ std::unique_ptr<ValueBase> AddMetalinkRpcMethod::process
size_t pos = posGiven ? posParam->i() : 0;
std::vector<std::shared_ptr<RequestGroup>> result;
#ifdef ENABLE_MESSAGE_DIGEST
std::string filename;
if(requestOption->getAsBool(PREF_RPC_SAVE_UPLOAD_METADATA)) {
// TODO RFC5854 Metalink has the extension .meta4 and Metalink
@ -365,9 +360,6 @@ std::unique_ptr<ValueBase> AddMetalinkRpcMethod::process
} else {
createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
}
#else // !ENABLE_MESSAGE_DIGEST
createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
#endif // !ENABLE_MESSAGE_DIGEST
auto gids = List::g();
if(!result.empty()) {
if(posGiven) {

View File

@ -66,8 +66,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) = 0;
#ifdef ENABLE_MESSAGE_DIGEST
// `begin' is a offset inside this segment.
virtual bool updateHash
(int32_t begin,
@ -78,8 +76,6 @@ public:
virtual std::string getDigest() = 0;
#endif // ENABLE_MESSAGE_DIGEST
virtual void clear(WrDiskCache* diskCache) = 0;
virtual std::shared_ptr<Piece> getPiece() const = 0;

View File

@ -88,11 +88,9 @@ ssize_t SinkStreamFilter::transform
} else {
out->writeData(inbuf, wlen, segment->getPositionToWrite());
}
#ifdef ENABLE_MESSAGE_DIGEST
if(hashUpdate_) {
segment->updateHash(segment->getWrittenLength(), inbuf, wlen);
}
#endif // ENABLE_MESSAGE_DIGEST
segment->updateWrittenLength(wlen);
} else {
wlen = 0;

View File

@ -143,7 +143,6 @@ std::shared_ptr<RequestGroup> createRequestGroup
dctx->getFirstFileEntry()->setUris(uris);
dctx->getFirstFileEntry()->setMaxConnectionPerServer
(option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER));
#ifdef ENABLE_MESSAGE_DIGEST
const std::string& checksum = option->get(PREF_CHECKSUM);
if(!checksum.empty()) {
auto p = util::divide(std::begin(checksum), std::end(checksum), '=');
@ -153,7 +152,6 @@ std::shared_ptr<RequestGroup> createRequestGroup
dctx->setDigest(hashType,
util::fromHex(std::begin(hexDigest), std::end(hexDigest)));
}
#endif // ENABLE_MESSAGE_DIGEST
rg->setDownloadContext(dctx);
rg->setPauseRequested(option->getAsBool(PREF_PAUSE));
removeOneshotOption(option);

View File

@ -85,10 +85,8 @@
#include "SocketCore.h"
#include "Lock.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
# include "message_digest_helper.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#include "message_digest_helper.h"
// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h
#ifndef ULLONG_MAX
@ -1641,14 +1639,10 @@ std::string fixTaintedBasename(const std::string& src)
void generateRandomKey(unsigned char* key)
{
#ifdef ENABLE_MESSAGE_DIGEST
unsigned char bytes[40];
generateRandomData(bytes, sizeof(bytes));
message_digest::digest(key, 20, MessageDigest::sha1().get(), bytes,
sizeof(bytes));
#else // !ENABLE_MESSAGE_DIGEST
generateRandomData(key, 20);
#endif // !ENABLE_MESSAGE_DIGEST
}
// Returns true is given numeric ipv4addr is in Private Address Space.

View File

@ -40,9 +40,7 @@
#include "a2io.h"
#include "FeatureConfig.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#include "help_tags.h"
#include "prefs.h"
#include "fmt.h"
@ -70,10 +68,8 @@ void showVersion() {
<< _("** Configuration **") << "\n"
<< _("Enabled Features") << ": "
<< featureSummary() << "\n"
#ifdef ENABLE_MESSAGE_DIGEST
<< _("Hash Algorithms") << ": "
<< MessageDigest::getSupportedHashTypeString() << "\n"
#endif // ENABLE_MESSAGE_DIGEST
<< _("Libraries") << ": "
<< usedLibs() << "\n"
<< "\n"

View File

@ -65,9 +65,7 @@ void FeatureConfigTest::testFeatureSummary() {
"HTTPS",
#endif // ENABLE_SSL
#ifdef ENABLE_MESSAGE_DIGEST
"Message Digest",
#endif // ENABLE_MESSAGE_DIGEST
#ifdef ENABLE_METALINK
"Metalink",

View File

@ -8,9 +8,7 @@
#include "TestUtil.h"
#include "Exception.h"
#include "util.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
namespace aria2 {
@ -53,10 +51,8 @@ void GZipDecoderTest::testDecode()
out.close();
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
fileHexDigest(MessageDigest::sha1().get(), outfile));
#endif // ENABLE_MESSAGE_DIGEST
}
} // namespace aria2

View File

@ -12,9 +12,7 @@
#include "ByteArrayDiskWriter.h"
#include "SinkStreamFilter.h"
#include "MockSegment.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
namespace aria2 {
@ -70,13 +68,11 @@ void GZipDecodingStreamFilterTest::testTransform()
filter_->transform(writer_, segment_, buf, in.gcount());
}
CPPUNIT_ASSERT(filter_->finished());
#ifdef ENABLE_MESSAGE_DIGEST
std::string data = writer_->getString();
std::shared_ptr<MessageDigest> sha1(MessageDigest::sha1());
sha1->update(data.data(), data.size());
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
util::toHex(sha1->digest()));
#endif // ENABLE_MESSAGE_DIGEST
}
} // namespace aria2

View File

@ -53,9 +53,7 @@ class HttpResponseTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testRetrieveCookie);
CPPUNIT_TEST(testSupportsPersistentConnection);
CPPUNIT_TEST(testGetMetalinKHttpEntries);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST(testGetDigest);
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST_SUITE_END();
private:
@ -88,9 +86,7 @@ public:
void testRetrieveCookie();
void testSupportsPersistentConnection();
void testGetMetalinKHttpEntries();
#ifdef ENABLE_MESSAGE_DIGEST
void testGetDigest();
#endif // ENABLE_MESSAGE_DIGEST
};
@ -667,7 +663,6 @@ void HttpResponseTest::testGetMetalinKHttpEntries()
CPPUNIT_ASSERT(e.geo.empty());
}
#ifdef ENABLE_MESSAGE_DIGEST
void HttpResponseTest::testGetDigest()
{
HttpResponse httpResponse;
@ -692,9 +687,9 @@ void HttpResponseTest::testGetDigest()
httpResponse.getDigest(result);
#ifdef USE_INTERNAL_MD
CPPUNIT_ASSERT_EQUAL((size_t)2, result.size());
#else
#else // USE_INTERNAL_MD
CPPUNIT_ASSERT_EQUAL((size_t)3, result.size());
#endif
#endif // USE_INTERNAL_MD
Checksum c = result[0];
#ifndef USE_INTERNAL_MD
@ -708,6 +703,5 @@ void HttpResponseTest::testGetDigest()
CPPUNIT_ASSERT_EQUAL(std::string("f36003f22b462ffa184390533c500d8989e9f681"),
util::toHex(c.getDigest()));
}
#endif // ENABLE_MESSAGE_DIGEST
} // namespace aria2

View File

@ -108,12 +108,10 @@ if HAVE_SQLITE3
aria2c_SOURCES += Sqlite3CookieParserTest.cc
endif # HAVE_SQLITE3
if ENABLE_MESSAGE_DIGEST
aria2c_SOURCES += MessageDigestHelperTest.cc\
IteratableChunkChecksumValidatorTest.cc\
IteratableChecksumValidatorTest.cc\
MessageDigestTest.cc
endif # ENABLE_MESSAGE_DIGEST
if ENABLE_BITTORRENT
aria2c_SOURCES += BtAllowedFastMessageTest.cc\

View File

@ -61,12 +61,10 @@ void Metalink2RequestGroupTest::testGenerate()
CPPUNIT_ASSERT(dctx);
CPPUNIT_ASSERT_EQUAL((int64_t)0LL, dctx->getTotalLength());
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getHashType());
CPPUNIT_ASSERT_EQUAL
(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"),
util::toHex(dctx->getDigest()));
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT(dctx->getSignature());
CPPUNIT_ASSERT_EQUAL(std::string("pgp"), dctx->getSignature()->getType());
}
@ -80,7 +78,6 @@ void Metalink2RequestGroupTest::testGenerate()
const std::shared_ptr<DownloadContext>& dctx = rg->getDownloadContext();
CPPUNIT_ASSERT(dctx);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getPieceHashType());
CPPUNIT_ASSERT_EQUAL((size_t)2, dctx->getPieceHashes().size());
CPPUNIT_ASSERT_EQUAL(262144, dctx->getPieceLength());
@ -88,7 +85,6 @@ void Metalink2RequestGroupTest::testGenerate()
CPPUNIT_ASSERT_EQUAL
(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
util::toHex(dctx->getDigest()));
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT(!dctx->getSignature());
}

View File

@ -78,9 +78,9 @@ void MetalinkEntryTest::testDropUnsupportedResource()
CPPUNIT_ASSERT_EQUAL((size_t)4, entry->resources.size());
#elif defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
CPPUNIT_ASSERT_EQUAL((size_t)3, entry->resources.size());
#else
#else // defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
CPPUNIT_ASSERT_EQUAL((size_t)2, entry->resources.size());
#endif // ENABLE_MESSAGE_DIGEST
#endif // defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
auto itr = std::begin(entry->resources);
CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_FTP,

View File

@ -7,10 +7,8 @@
#include "MetalinkResource.h"
#include "MetalinkMetaurl.h"
#include "FileEntry.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "Checksum.h"
# include "ChunkChecksum.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "Checksum.h"
#include "ChunkChecksum.h"
#include "Signature.h"
namespace aria2 {
@ -22,11 +20,9 @@ class MetalinkParserControllerTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testResourceTransaction);
CPPUNIT_TEST(testResourceTransaction_withBaseUri);
CPPUNIT_TEST(testMetaurlTransaction);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST(testChecksumTransaction);
CPPUNIT_TEST(testChunkChecksumTransaction);
CPPUNIT_TEST(testChunkChecksumTransactionV4);
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST(testSignatureTransaction);
CPPUNIT_TEST_SUITE_END();
@ -41,11 +37,9 @@ public:
void testResourceTransaction();
void testResourceTransaction_withBaseUri();
void testMetaurlTransaction();
#ifdef ENABLE_MESSAGE_DIGEST
void testChecksumTransaction();
void testChunkChecksumTransaction();
void testChunkChecksumTransactionV4();
#endif // ENABLE_MESSAGE_DIGEST
void testSignatureTransaction();
};
@ -183,7 +177,6 @@ void MetalinkParserControllerTest::testMetaurlTransaction()
#endif // !ENABLE_BITTORRENT
}
#ifdef ENABLE_MESSAGE_DIGEST
void MetalinkParserControllerTest::testChecksumTransaction()
{
MetalinkParserController ctrl;
@ -310,7 +303,6 @@ void MetalinkParserControllerTest::testChunkChecksumTransactionV4()
CPPUNIT_ASSERT(!m->getEntries()[2]->chunkChecksum);
}
}
#endif // ENABLE_MESSAGE_DIGEST
void MetalinkParserControllerTest::testSignatureTransaction()
{

View File

@ -12,11 +12,9 @@
#include "MetalinkEntry.h"
#include "MetalinkResource.h"
#include "MetalinkMetaurl.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
# include "ChunkChecksum.h"
# include "Checksum.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
#include "ChunkChecksum.h"
#include "Checksum.h"
#include "Signature.h"
#include "fmt.h"
#include "RecoverableException.h"
@ -40,13 +38,11 @@ class MetalinkProcessorTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testNoName);
CPPUNIT_TEST(testBadURLPrefs);
CPPUNIT_TEST(testBadURLMaxConn);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST(testUnsupportedType);
CPPUNIT_TEST(testMultiplePieces);
CPPUNIT_TEST(testBadPieceNo);
CPPUNIT_TEST(testBadPieceLength);
CPPUNIT_TEST(testUnsupportedType_piece);
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST(testLargeFileSize);
CPPUNIT_TEST(testXmlPrefixV3);
CPPUNIT_TEST_SUITE_END();
@ -66,13 +62,11 @@ public:
void testNoName();
void testBadURLPrefs();
void testBadURLMaxConn();
#ifdef ENABLE_MESSAGE_DIGEST
void testUnsupportedType();
void testMultiplePieces();
void testBadPieceNo();
void testBadPieceLength();
void testUnsupportedType_piece();
#endif // ENABLE_MESSAGE_DIGEST
void testLargeFileSize();
void testXmlPrefixV3();
};
@ -88,7 +82,6 @@ void MetalinkProcessorTest::testParseFileV4()
CPPUNIT_ASSERT_EQUAL(std::string("example.ext"), e->getPath());
CPPUNIT_ASSERT_EQUAL((int64_t)786430LL, e->getLength());
CPPUNIT_ASSERT_EQUAL(-1, e->maxConnections);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"),
util::toHex(e->checksum->getDigest()));
CPPUNIT_ASSERT(e->checksum);
@ -118,7 +111,6 @@ void MetalinkProcessorTest::testParseFileV4()
(std::string("44213f9f4d59b557314fadcd233232eebcac8012"),
util::toHex(e->chunkChecksum->getPieceHash(2)));
}
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT(e->getSignature());
CPPUNIT_ASSERT_EQUAL(std::string("application/pgp-signature"),
e->getSignature()->getType());
@ -332,7 +324,6 @@ void MetalinkProcessorTest::testParseFileV4_attrs()
// success
}
}
#ifdef ENABLE_MESSAGE_DIGEST
{
// Testing pieces@length
// No pieces@length
@ -449,7 +440,6 @@ void MetalinkProcessorTest::testParseFileV4_attrs()
CPPUNIT_FAIL("exception must be thrown.");
} catch(RecoverableException& e) {}
}
#endif // ENABLE_MESSAGE_DIGEST
{
// Testing signature@mediatype
// No hash@type
@ -499,11 +489,9 @@ void MetalinkProcessorTest::testParseFile()
CPPUNIT_ASSERT_EQUAL(std::string("en-US"), entry1->languages[0]);
CPPUNIT_ASSERT_EQUAL(std::string("Linux-x86"), entry1->oses[0]);
CPPUNIT_ASSERT_EQUAL(1, entry1->maxConnections);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"),
util::toHex(entry1->checksum->getDigest()));
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry1->checksum->getHashType());
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT(entry1->getSignature());
CPPUNIT_ASSERT_EQUAL(std::string("pgp"), entry1->getSignature()->getType());
CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.2.tar.bz2.sig"),
@ -548,7 +536,6 @@ void MetalinkProcessorTest::testParseFile()
CPPUNIT_ASSERT_EQUAL(std::string("ja-JP"), entry2->languages[0]);
CPPUNIT_ASSERT_EQUAL(std::string("Linux-m68k"), entry2->oses[0]);
CPPUNIT_ASSERT_EQUAL(-1, entry2->maxConnections);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
util::toHex(entry2->checksum->getDigest()));
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->countPieceHash());
@ -558,7 +545,6 @@ void MetalinkProcessorTest::testParseFile()
CPPUNIT_ASSERT_EQUAL(std::string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
util::toHex(entry2->chunkChecksum->getPieceHash(1)));
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry2->checksum->getHashType());
#endif // ENABLE_MESSAGE_DIGEST
// See that signature is null
CPPUNIT_ASSERT(!entry2->getSignature());
@ -567,22 +553,18 @@ void MetalinkProcessorTest::testParseFile()
// test case: verification hash is not provided
auto& entry3 = *entryItr;
CPPUNIT_ASSERT_EQUAL(std::string("NoVerificationHash"), entry3->getPath());
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT(!entry3->checksum);
CPPUNIT_ASSERT(!entry3->chunkChecksum);
#endif // ENABLE_MESSAGE_DIGEST
++entryItr;
// test case: unsupported verification hash is included
auto& entry4 = *entryItr;
CPPUNIT_ASSERT_EQUAL(std::string("UnsupportedVerificationHashTypeIncluded"), entry4->getPath());
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry4->checksum->getHashType());
CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
util::toHex(entry4->checksum->getDigest()));
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"),entry4->chunkChecksum->getHashType());
#endif // ENABLE_MESSAGE_DIGEST
} catch(Exception& e) {
@ -809,7 +791,6 @@ void MetalinkProcessorTest::testBadURLMaxConn()
}
}
#ifdef ENABLE_MESSAGE_DIGEST
void MetalinkProcessorTest::testUnsupportedType()
{
ByteArrayDiskWriter dw;
@ -966,7 +947,6 @@ void MetalinkProcessorTest::testUnsupportedType_piece()
CPPUNIT_FAIL(e.stackTrace());
}
}
#endif // ENABLE_MESSAGE_DIGEST
void MetalinkProcessorTest::testLargeFileSize()
{

View File

@ -46,8 +46,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE {}
#ifdef ENABLE_MESSAGE_DIGEST
// `begin' is a offset inside this segment.
virtual bool updateHash
(int32_t begin, const unsigned char* data, size_t dataLength) CXX11_OVERRIDE
@ -65,8 +63,6 @@ public:
return A2STR::NIL;
}
#endif // ENABLE_MESSAGE_DIGEST
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE {}
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE

View File

@ -18,13 +18,10 @@ class PieceTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testGetCompletedLength);
CPPUNIT_TEST(testFlushWrCache);
CPPUNIT_TEST(testAppendWrCache);
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST(testGetDigestWithWrCache);
CPPUNIT_TEST(testUpdateHash);
#endif // ENABLE_MESSAGE_DIGEST
CPPUNIT_TEST_SUITE_END();
private:
std::shared_ptr<DirectDiskAdaptor> adaptor_;
@ -43,12 +40,8 @@ public:
void testFlushWrCache();
void testAppendWrCache();
#ifdef ENABLE_MESSAGE_DIGEST
void testGetDigestWithWrCache();
void testUpdateHash();
#endif // ENABLE_MESSAGE_DIGEST
};
@ -120,8 +113,6 @@ void PieceTest::testAppendWrCache()
CPPUNIT_ASSERT_EQUAL(std::string("foobar"), writer_->getString());
}
#ifdef ENABLE_MESSAGE_DIGEST
void PieceTest::testGetDigestWithWrCache()
{
unsigned char* data;
@ -168,6 +159,4 @@ void PieceTest::testUpdateHash()
util::toHex(p.getDigest()));
}
#endif // ENABLE_MESSAGE_DIGEST
} // namespace aria2

View File

@ -470,11 +470,9 @@ void RpcMethodTest::testAddMetalink()
CPPUNIT_ASSERT_EQUAL
(0, GroupId::toNumericId
(gid4, downcast<String>(resParams->get(1))->s().c_str()));
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT
(File(e_->getOption()->get(PREF_DIR)+
"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
#endif // ENABLE_MESSAGE_DIGEST
auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
CPPUNIT_ASSERT(tar);
@ -507,10 +505,8 @@ void RpcMethodTest::testAddMetalink()
findReservedGroup
(e_->getRequestGroupMan().get(), gid5)->
getFirstFilePath());
#ifdef ENABLE_MESSAGE_DIGEST
CPPUNIT_ASSERT
(File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
#endif // ENABLE_MESSAGE_DIGEST
}
}

View File

@ -21,9 +21,7 @@
#include "Option.h"
#include "FileEntry.h"
#include "DownloadResult.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "message_digest_helper.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "message_digest_helper.h"
namespace aria2 {
@ -80,14 +78,12 @@ std::string fromHex(const std::string& s)
return util::fromHex(s.begin(), s.end());
}
#ifdef ENABLE_MESSAGE_DIGEST
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename)
{
std::shared_ptr<DiskWriter> writer(new DefaultDiskWriter(filename));
writer->openExistingFile();
return util::toHex(message_digest::digest(ctx, writer, 0, writer->size()));
}
#endif // ENABLE_MESSAGE_DIGEST
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
const char* data,

View File

@ -50,10 +50,8 @@ std::unique_ptr<Cookie> createCookie
std::string fromHex(const std::string& s);
#ifdef ENABLE_MESSAGE_DIGEST
// Returns hex digest of contents of file denoted by filename.
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename);
#endif // ENABLE_MESSAGE_DIGEST
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
const char* data,