allow DLL to be built with VC++ .NET

pull/2/head
weidai 2003-07-18 21:33:18 +00:00
parent 5b2008101c
commit 55a22f2adf
16 changed files with 142 additions and 146 deletions

View File

@ -11,11 +11,11 @@ class CRYPTOPP_DLL BaseN_Encoder : public Unflushable<Filter>
{ {
public: public:
BaseN_Encoder(BufferedTransformation *attachment=NULL) BaseN_Encoder(BufferedTransformation *attachment=NULL)
: Unflushable<Filter>(attachment) {} {Detach(attachment);}
BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1) BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1)
: Unflushable<Filter>(attachment)
{ {
Detach(attachment);
IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet) IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet)
(Name::Log2Base(), log2base) (Name::Log2Base(), log2base)
(Name::Pad(), padding != -1) (Name::Pad(), padding != -1)
@ -36,11 +36,11 @@ class CRYPTOPP_DLL BaseN_Decoder : public Unflushable<Filter>
{ {
public: public:
BaseN_Decoder(BufferedTransformation *attachment=NULL) BaseN_Decoder(BufferedTransformation *attachment=NULL)
: Unflushable<Filter>(attachment) {} {Detach(attachment);}
BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL) BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL)
: Unflushable<Filter>(attachment)
{ {
Detach(attachment);
IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base)); IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base));
} }
@ -60,11 +60,11 @@ class CRYPTOPP_DLL Grouper : public Bufferless<Filter>
{ {
public: public:
Grouper(BufferedTransformation *attachment=NULL) Grouper(BufferedTransformation *attachment=NULL)
: Bufferless<Filter>(attachment) {} {Detach(attachment);}
Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL) Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL)
: Bufferless<Filter>(attachment)
{ {
Detach(attachment);
IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize) IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize)
(Name::Separator(), ConstByteArrayParameter(separator)) (Name::Separator(), ConstByteArrayParameter(separator))
(Name::Terminator(), ConstByteArrayParameter(terminator))); (Name::Terminator(), ConstByteArrayParameter(terminator)));

View File

@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 advapi32.lib /nologo /base:"0x42900000" /dll /map /debug /machine:I386 /out:"DLL_Release/cryptopp.dll" /opt:ref /export:CryptoPP_Malloc=malloc /export:CryptoPP_Free=free # ADD LINK32 advapi32.lib /nologo /base:"0x42900000" /dll /map /debug /machine:I386 /out:"DLL_Release/cryptopp.dll" /opt:ref
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
# Begin Custom Build # Begin Custom Build
OutDir=.\DLL_Release OutDir=.\DLL_Release

View File

@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c # ADD BASE CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c
# ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c # ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O1 /Ob2 /D "NDEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -75,7 +75,7 @@ PreLink_Cmds=echo This configuration requires cryptopp.dll. echo You can build i
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c # ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c
# ADD CPP /nologo /G5 /Gz /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c # ADD CPP /nologo /G5 /Gz /MTd /W3 /GX /Zi /Od /D "_DEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -111,7 +111,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /map /debug /machine:I386 /OPT:NOWIN98 /OPT:REF /OPT:ICF # ADD LINK32 advapi32.lib Ws2_32.lib /nologo /subsystem:console /map /debug /machine:I386 /OPT:NOWIN98 /OPT:REF /OPT:ICF
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "cryptest - Win32 Debug" !ELSEIF "$(CFG)" == "cryptest - Win32 Debug"
@ -128,7 +128,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /YX /FD /Zm400 /c # ADD CPP /nologo /MTd /W3 /GX /Zi /Od /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /YX /FD /Zm400 /c
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -136,7 +136,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /OPT:NOWIN98 # ADD LINK32 advapi32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ENDIF !ENDIF

View File

@ -520,13 +520,13 @@ void GeneratableCryptoMaterial::GenerateRandomWithKeySize(RandomNumberGenerator
GenerateRandom(rng, MakeParameters("KeySize", (int)keySize)); GenerateRandom(rng, MakeParameters("KeySize", (int)keySize));
} }
BufferedTransformation * PK_Encryptor::CreateEncryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment, const NameValuePairs &parameters) const class PK_DefaultEncryptionFilter : public Unflushable<Filter>
{ {
struct EncryptionFilter : public Unflushable<Filter> public:
{ PK_DefaultEncryptionFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment, const NameValuePairs &parameters)
EncryptionFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment, const NameValuePairs &parameters) : m_rng(rng), m_encryptor(encryptor), m_parameters(parameters)
: Unflushable<Filter>(attachment), m_rng(rng), m_encryptor(encryptor), m_parameters(parameters)
{ {
Detach(attachment);
} }
unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking)
@ -558,16 +558,18 @@ BufferedTransformation * PK_Encryptor::CreateEncryptionFilter(RandomNumberGenera
SecByteBlock m_ciphertext; SecByteBlock m_ciphertext;
}; };
return new EncryptionFilter(rng, *this, attachment, parameters); BufferedTransformation * PK_Encryptor::CreateEncryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment, const NameValuePairs &parameters) const
{
return new PK_DefaultEncryptionFilter(rng, *this, attachment, parameters);
} }
BufferedTransformation * PK_Decryptor::CreateDecryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment, const NameValuePairs &parameters) const class PK_DefaultDecryptionFilter : public Unflushable<Filter>
{ {
struct DecryptionFilter : public Unflushable<Filter> public:
{ PK_DefaultDecryptionFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment, const NameValuePairs &parameters)
DecryptionFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment, const NameValuePairs &parameters) : m_rng(rng), m_decryptor(decryptor), m_parameters(parameters)
: Unflushable<Filter>(attachment), m_rng(rng), m_decryptor(decryptor), m_parameters(parameters)
{ {
Detach(attachment);
} }
unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking)
@ -602,7 +604,9 @@ BufferedTransformation * PK_Decryptor::CreateDecryptionFilter(RandomNumberGenera
DecodingResult m_result; DecodingResult m_result;
}; };
return new DecryptionFilter(rng, *this, attachment, parameters); BufferedTransformation * PK_Decryptor::CreateDecryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment, const NameValuePairs &parameters) const
{
return new PK_DefaultDecryptionFilter(rng, *this, attachment, parameters);
} }
unsigned int PK_Signer::Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const unsigned int PK_Signer::Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const

View File

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "FIPS_140_Release" # PROP Intermediate_Dir "FIPS_140_Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /c # ADD BASE CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /c
# ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Release/cryptopp" /FD /c # ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O1 /Ob2 /D "NDEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Release/cryptopp" /FD /c
# ADD BASE RSC /l 0x409 # ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@ -66,7 +66,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "FIPS_140_Debug" # PROP Intermediate_Dir "FIPS_140_Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /c # ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /c
# ADD CPP /nologo /G5 /Gz /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Debug/cryptopp" /FD /c # ADD CPP /nologo /G5 /Gz /MTd /W3 /GX /Zi /Od /D "_DEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Debug/cryptopp" /FD /c
# ADD BASE RSC /l 0x409 # ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe
@ -112,7 +112,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /Yu"pch.h" /FD /c # ADD CPP /nologo /MTd /W3 /GX /Zi /Od /D "_DEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /Yu"pch.h" /FD /c
# ADD BASE RSC /l 0x409 # ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 # ADD RSC /l 0x409
BSC32=bscmake.exe BSC32=bscmake.exe

View File

@ -12,7 +12,7 @@ void FIPS140_SampleApplication()
{ {
if (!FIPS_140_2_ComplianceEnabled()) if (!FIPS_140_2_ComplianceEnabled())
{ {
cerr << "FIPS-140-2 compliance was turned off at compile time.\n"; cerr << "FIPS 140-2 compliance was turned off at compile time.\n";
abort(); abort();
} }

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /c # ADD CPP /nologo /Gz /MT /W3 /GX /Zi /O1 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /GZ /c # ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe

View File

@ -118,7 +118,7 @@ public:
const EllipticCurve& GetCurve() const {return m_groupPrecomputation.GetCurve();} const EllipticCurve& GetCurve() const {return m_groupPrecomputation.GetCurve();}
bool operator==(const ThisClass &rhs) const bool operator==(const ThisClass &rhs) const
{return DL_GroupParametersImpl<EcPrecomputation<EC> >::operator==(rhs);} {return m_groupPrecomputation.GetCurve() == rhs.m_groupPrecomputation.GetCurve() && m_gpc.GetBase(m_groupPrecomputation) == rhs.m_gpc.GetBase(rhs.m_groupPrecomputation);}
#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY #ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
const Point& GetBasePoint() const {return GetSubgroupGenerator();} const Point& GetBasePoint() const {return GetSubgroupGenerator();}

View File

@ -40,14 +40,12 @@ const BufferedTransformation *Filter::AttachedTransformation() const
void Filter::Detach(BufferedTransformation *newOut) void Filter::Detach(BufferedTransformation *newOut)
{ {
m_attachment.reset(newOut); m_attachment.reset(newOut);
NotifyAttachmentChange();
} }
void Filter::Insert(Filter *filter) void Filter::Insert(Filter *filter)
{ {
filter->m_attachment.reset(m_attachment.release()); filter->m_attachment.reset(m_attachment.release());
m_attachment.reset(filter); m_attachment.reset(filter);
NotifyAttachmentChange();
} }
unsigned int Filter::CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end, const std::string &channel, bool blocking) const unsigned int Filter::CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end, const std::string &channel, bool blocking) const
@ -896,14 +894,20 @@ unsigned int StringStore::CopyRangeTo2(BufferedTransformation &target, unsigned
return blockedBytes; return blockedBytes;
} }
void RandomNumberStore::StoreInitialize(const NameValuePairs &parameters)
{
parameters.GetRequiredParameter("RandomNumberStore", "RandomNumberGeneratorPointer", m_rng);
parameters.GetRequiredIntParameter("RandomNumberStore", "RandomNumberStoreSize", m_length);
}
unsigned int RandomNumberStore::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking) unsigned int RandomNumberStore::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking)
{ {
if (!blocking) if (!blocking)
throw NotImplemented("RandomNumberStore: nonblocking transfer is not implemented by this object"); throw NotImplemented("RandomNumberStore: nonblocking transfer is not implemented by this object");
unsigned long transferMax = transferBytes; unsigned long transferMax = transferBytes;
for (transferBytes = 0; transferBytes<transferMax && m_count < m_length; ++transferBytes, ++m_count) for (transferBytes = 0; transferBytes<transferMax && m_count < (unsigned long)m_length; ++transferBytes, ++m_count)
target.ChannelPut(channel, m_rng.GenerateByte()); target.ChannelPut(channel, m_rng->GenerateByte());
return 0; return 0;
} }

View File

@ -14,7 +14,7 @@ NAMESPACE_BEGIN(CryptoPP)
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Filter : public BufferedTransformation, public NotCopyable class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Filter : public BufferedTransformation, public NotCopyable
{ {
public: public:
Filter(BufferedTransformation *attachment); Filter(BufferedTransformation *attachment = NULL);
bool Attachable() {return true;} bool Attachable() {return true;}
BufferedTransformation *AttachedTransformation(); BufferedTransformation *AttachedTransformation();
@ -29,7 +29,6 @@ public:
bool MessageSeriesEnd(int propagation=-1, bool blocking=true); bool MessageSeriesEnd(int propagation=-1, bool blocking=true);
protected: protected:
virtual void NotifyAttachmentChange() {}
virtual BufferedTransformation * NewDefaultAttachment() const; virtual BufferedTransformation * NewDefaultAttachment() const;
void Insert(Filter *nextFilter); // insert filter after this one void Insert(Filter *nextFilter); // insert filter after this one
@ -84,7 +83,7 @@ class CRYPTOPP_DLL MeterFilter : public Bufferless<Filter>
{ {
public: public:
MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true) MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true)
: Bufferless<Filter>(attachment), m_transparent(transparent) {ResetMeter();} : m_transparent(transparent) {Detach(attachment); ResetMeter();}
void SetTransparent(bool transparent) {m_transparent = transparent;} void SetTransparent(bool transparent) {m_transparent = transparent;}
void ResetMeter() {m_currentMessageBytes = m_totalBytes = m_currentSeriesMessages = m_totalMessages = m_totalMessageSeries = 0;} void ResetMeter() {m_currentMessageBytes = m_totalBytes = m_currentSeriesMessages = m_totalMessages = m_totalMessageSeries = 0;}
@ -269,7 +268,7 @@ class CRYPTOPP_DLL HashFilter : public Bufferless<Filter>, private FilterPutSpac
{ {
public: public:
HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false) HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false)
: Bufferless<Filter>(attachment), m_hashModule(hm), m_putMessage(putMessage) {} : m_hashModule(hm), m_putMessage(putMessage) {Detach(attachment);}
void IsolatedInitialize(const NameValuePairs &parameters); void IsolatedInitialize(const NameValuePairs &parameters);
unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
@ -321,7 +320,7 @@ class CRYPTOPP_DLL SignerFilter : public Unflushable<Filter>
{ {
public: public:
SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false) SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false)
: Unflushable<Filter>(attachment), m_rng(rng), m_signer(signer), m_messageAccumulator(signer.NewSignatureAccumulator(rng)), m_putMessage(putMessage) {} : m_rng(rng), m_signer(signer), m_messageAccumulator(signer.NewSignatureAccumulator(rng)), m_putMessage(putMessage) {Detach(attachment);}
void IsolatedInitialize(const NameValuePairs &parameters); void IsolatedInitialize(const NameValuePairs &parameters);
unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
@ -597,8 +596,11 @@ private:
class CRYPTOPP_DLL RandomNumberStore : public Store class CRYPTOPP_DLL RandomNumberStore : public Store
{ {
public: public:
RandomNumberStore()
: m_rng(NULL), m_length(0), m_count(0) {}
RandomNumberStore(RandomNumberGenerator &rng, unsigned long length) RandomNumberStore(RandomNumberGenerator &rng, unsigned long length)
: m_rng(rng), m_length(length), m_count(0) {} : m_rng(&rng), m_length(length), m_count(0) {}
bool AnyRetrievable() const {return MaxRetrievable() != 0;} bool AnyRetrievable() const {return MaxRetrievable() != 0;}
unsigned long MaxRetrievable() const {return m_length-m_count;} unsigned long MaxRetrievable() const {return m_length-m_count;}
@ -610,10 +612,10 @@ public:
} }
private: private:
void StoreInitialize(const NameValuePairs &parameters) {m_count = 0;} void StoreInitialize(const NameValuePairs &parameters);
RandomNumberGenerator &m_rng; RandomNumberGenerator *m_rng;
const unsigned long m_length; int m_length;
unsigned long m_count; unsigned long m_count;
}; };
@ -635,8 +637,8 @@ private:
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Source : public InputRejecting<Filter> class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Source : public InputRejecting<Filter>
{ {
public: public:
Source(BufferedTransformation *attachment) Source(BufferedTransformation *attachment = NULL)
: InputRejecting<Filter>(attachment) {} {Detach(attachment);}
unsigned long Pump(unsigned long pumpMax=ULONG_MAX) unsigned long Pump(unsigned long pumpMax=ULONG_MAX)
{Pump2(pumpMax); return pumpMax;} {Pump2(pumpMax); return pumpMax;}
@ -665,8 +667,6 @@ class SourceTemplate : public Source
public: public:
SourceTemplate<T>(BufferedTransformation *attachment) SourceTemplate<T>(BufferedTransformation *attachment)
: Source(attachment) {} : Source(attachment) {}
SourceTemplate<T>(BufferedTransformation *attachment, T store)
: Source(attachment), m_store(store) {}
void IsolatedInitialize(const NameValuePairs &parameters) void IsolatedInitialize(const NameValuePairs &parameters)
{m_store.IsolatedInitialize(parameters);} {m_store.IsolatedInitialize(parameters);}
unsigned int Pump2(unsigned long &byteCount, bool blocking=true) unsigned int Pump2(unsigned long &byteCount, bool blocking=true)
@ -704,8 +704,9 @@ public:
class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate<RandomNumberStore> class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate<RandomNumberStore>
{ {
public: public:
RandomNumberSource(RandomNumberGenerator &rng, unsigned int length, bool pumpAll, BufferedTransformation *attachment = NULL) RandomNumberSource(RandomNumberGenerator &rng, int length, bool pumpAll, BufferedTransformation *attachment = NULL)
: SourceTemplate<RandomNumberStore>(attachment, RandomNumberStore(rng, length)) {if (pumpAll) PumpAll();} : SourceTemplate<RandomNumberStore>(attachment)
{SourceInitialize(pumpAll, MakeParameters("RandomNumberGeneratorPointer", &rng)("RandomNumberStoreSize", length));}
}; };
NAMESPACE_END NAMESPACE_END

18
ida.h
View File

@ -14,7 +14,7 @@ class RawIDA : public AutoSignaling<Unflushable<Multichannel<Filter> > >
{ {
public: public:
RawIDA(BufferedTransformation *attachment=NULL) RawIDA(BufferedTransformation *attachment=NULL)
: AutoSignaling<Unflushable<Multichannel<Filter> > >(attachment) {} {Detach(attachment);}
unsigned int GetThreshold() const {return m_threshold;} unsigned int GetThreshold() const {return m_threshold;}
void AddOutputChannel(word32 channelId); void AddOutputChannel(word32 channelId);
@ -57,8 +57,11 @@ class SecretSharing : public CustomFlushPropagation<Filter>
{ {
public: public:
SecretSharing(RandomNumberGenerator &rng, int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true) SecretSharing(RandomNumberGenerator &rng, int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true)
: CustomFlushPropagation<Filter>(attachment), m_rng(rng), m_ida(new OutputProxy(*this, true)) : m_rng(rng), m_ida(new OutputProxy(*this, true))
{IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding));} {
Detach(attachment);
IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding));
}
void IsolatedInitialize(const NameValuePairs &parameters=g_nullNameValuePairs); void IsolatedInitialize(const NameValuePairs &parameters=g_nullNameValuePairs);
unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
@ -92,8 +95,11 @@ class InformationDispersal : public CustomFlushPropagation<Filter>
{ {
public: public:
InformationDispersal(int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true) InformationDispersal(int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true)
: CustomFlushPropagation<Filter>(attachment), m_ida(new OutputProxy(*this, true)) : m_ida(new OutputProxy(*this, true))
{IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding));} {
Detach(attachment);
IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding));
}
void IsolatedInitialize(const NameValuePairs &parameters=g_nullNameValuePairs); void IsolatedInitialize(const NameValuePairs &parameters=g_nullNameValuePairs);
unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
@ -127,7 +133,7 @@ class PaddingRemover : public Unflushable<Filter>
{ {
public: public:
PaddingRemover(BufferedTransformation *attachment=NULL) PaddingRemover(BufferedTransformation *attachment=NULL)
: Unflushable<Filter>(attachment), m_possiblePadding(false) {} : m_possiblePadding(false) {Detach(attachment);}
void IsolatedInitialize(const NameValuePairs &parameters) {m_possiblePadding = false;} void IsolatedInitialize(const NameValuePairs &parameters) {m_possiblePadding = false;}
unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);

View File

@ -69,8 +69,9 @@ public:
/*! if throwIfNotEqual is false, this filter will output a '\0' byte when it detects a mismatch, '\1' otherwise */ /*! if throwIfNotEqual is false, this filter will output a '\0' byte when it detects a mismatch, '\1' otherwise */
EqualityComparisonFilter(BufferedTransformation *attachment=NULL, bool throwIfNotEqual=true, const std::string &firstChannel="0", const std::string &secondChannel="1") EqualityComparisonFilter(BufferedTransformation *attachment=NULL, bool throwIfNotEqual=true, const std::string &firstChannel="0", const std::string &secondChannel="1")
: Unflushable<Multichannel<Filter> >(attachment), m_throwIfNotEqual(throwIfNotEqual), m_mismatchDetected(false) : m_throwIfNotEqual(throwIfNotEqual), m_mismatchDetected(false)
, m_firstChannel(firstChannel), m_secondChannel(secondChannel) {} , m_firstChannel(firstChannel), m_secondChannel(secondChannel)
{Detach(attachment);}
unsigned int ChannelPut2(const std::string &channel, const byte *begin, unsigned int length, int messageEnd, bool blocking); unsigned int ChannelPut2(const std::string &channel, const byte *begin, unsigned int length, int messageEnd, bool blocking);
bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true); bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true);

View File

@ -11,7 +11,7 @@ class CRYPTOPP_NO_VTABLE NonblockingSource : public AutoSignaling<Source>
{ {
public: public:
NonblockingSource(BufferedTransformation *attachment) NonblockingSource(BufferedTransformation *attachment)
: AutoSignaling<Source>(attachment), m_messageEndSent(false) {} : m_messageEndSent(false) {Detach(attachment);}
//! \name NONBLOCKING SOURCE //! \name NONBLOCKING SOURCE
//@{ //@{

View File

@ -639,9 +639,6 @@ public:
const DL_FixedBasePrecomputation<Element> & GetBasePrecomputation() const {return m_gpc;} const DL_FixedBasePrecomputation<Element> & GetBasePrecomputation() const {return m_gpc;}
DL_FixedBasePrecomputation<Element> & AccessBasePrecomputation() {return m_gpc;} DL_FixedBasePrecomputation<Element> & AccessBasePrecomputation() {return m_gpc;}
bool operator==(const DL_GroupParametersImpl<GROUP_PRECOMP, BASE_PRECOMP, BASE> &rhs) const
{return m_groupPrecomputation.GetCurve() == rhs.m_groupPrecomputation.GetCurve() && m_gpc.GetBase(m_groupPrecomputation) == rhs.m_gpc.GetBase(rhs.m_groupPrecomputation);}
protected: protected:
GROUP_PRECOMP m_groupPrecomputation; GROUP_PRECOMP m_groupPrecomputation;
BASE_PRECOMP m_gpc; BASE_PRECOMP m_gpc;

View File

@ -56,8 +56,6 @@ template <class T>
class CRYPTOPP_NO_VTABLE Bufferless : public T class CRYPTOPP_NO_VTABLE Bufferless : public T
{ {
public: public:
Bufferless() {}
Bufferless(BufferedTransformation *q) : T(q) {}
bool IsolatedFlush(bool hardFlush, bool blocking) {return false;} bool IsolatedFlush(bool hardFlush, bool blocking) {return false;}
}; };
@ -65,8 +63,6 @@ template <class T>
class CRYPTOPP_NO_VTABLE Unflushable : public T class CRYPTOPP_NO_VTABLE Unflushable : public T
{ {
public: public:
Unflushable() {}
Unflushable(BufferedTransformation *q) : T(q) {}
bool Flush(bool completeFlush, int propagation=-1, bool blocking=true) bool Flush(bool completeFlush, int propagation=-1, bool blocking=true)
{return ChannelFlush(NULL_CHANNEL, completeFlush, propagation, blocking);} {return ChannelFlush(NULL_CHANNEL, completeFlush, propagation, blocking);}
bool IsolatedFlush(bool hardFlush, bool blocking) bool IsolatedFlush(bool hardFlush, bool blocking)
@ -90,10 +86,6 @@ template <class T>
class CRYPTOPP_NO_VTABLE InputRejecting : public T class CRYPTOPP_NO_VTABLE InputRejecting : public T
{ {
public: public:
InputRejecting() {}
InputRejecting(BufferedTransformation *q) : T(q) {}
protected:
struct InputRejected : public NotImplemented struct InputRejected : public NotImplemented
{InputRejected() : NotImplemented("BufferedTransformation: this object doesn't allow input") {}}; {InputRejected() : NotImplemented("BufferedTransformation: this object doesn't allow input") {}};
@ -112,9 +104,6 @@ template <class T>
class CRYPTOPP_NO_VTABLE CustomFlushPropagation : public T class CRYPTOPP_NO_VTABLE CustomFlushPropagation : public T
{ {
public: public:
CustomFlushPropagation() {}
CustomFlushPropagation(BufferedTransformation *q) : T(q) {}
virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) =0; virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) =0;
private: private:
@ -125,9 +114,6 @@ template <class T>
class CRYPTOPP_NO_VTABLE CustomSignalPropagation : public CustomFlushPropagation<T> class CRYPTOPP_NO_VTABLE CustomSignalPropagation : public CustomFlushPropagation<T>
{ {
public: public:
CustomSignalPropagation() {}
CustomSignalPropagation(BufferedTransformation *q) : CustomFlushPropagation<T>(q) {}
virtual void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1) =0; virtual void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1) =0;
private: private:
@ -138,9 +124,6 @@ template <class T>
class CRYPTOPP_NO_VTABLE Multichannel : public CustomFlushPropagation<T> class CRYPTOPP_NO_VTABLE Multichannel : public CustomFlushPropagation<T>
{ {
public: public:
Multichannel() {}
Multichannel(BufferedTransformation *q) : CustomFlushPropagation<T>(q) {}
bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
{return ChannelFlush(NULL_CHANNEL, hardFlush, propagation, blocking);} {return ChannelFlush(NULL_CHANNEL, hardFlush, propagation, blocking);}
bool MessageSeriesEnd(int propagation=-1, bool blocking=true) bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
@ -171,7 +154,6 @@ class CRYPTOPP_NO_VTABLE AutoSignaling : public T
{ {
public: public:
AutoSignaling(int propagation=-1) : m_autoSignalPropagation(propagation) {} AutoSignaling(int propagation=-1) : m_autoSignalPropagation(propagation) {}
AutoSignaling(BufferedTransformation *q, int propagation=-1) : T(q), m_autoSignalPropagation(propagation) {}
void SetAutoSignalPropagation(int propagation) void SetAutoSignalPropagation(int propagation)
{m_autoSignalPropagation = propagation;} {m_autoSignalPropagation = propagation;}

View File

@ -209,9 +209,10 @@ bool HuffmanDecoder::Decode(LowFirstBitReader &reader, value_t &value) const
// ************************************************************* // *************************************************************
Inflator::Inflator(BufferedTransformation *attachment, bool repeat, int propagation) Inflator::Inflator(BufferedTransformation *attachment, bool repeat, int propagation)
: AutoSignaling<Filter>(attachment, propagation) : AutoSignaling<Filter>(propagation)
, m_state(PRE_STREAM), m_repeat(repeat), m_reader(m_inQueue) , m_state(PRE_STREAM), m_repeat(repeat), m_reader(m_inQueue)
{ {
Detach(attachment);
} }
void Inflator::IsolatedInitialize(const NameValuePairs &parameters) void Inflator::IsolatedInitialize(const NameValuePairs &parameters)