diff --git a/basecode.h b/basecode.h index d1fa3b5d..a70e9caa 100644 --- a/basecode.h +++ b/basecode.h @@ -11,11 +11,11 @@ class CRYPTOPP_DLL BaseN_Encoder : public Unflushable { public: BaseN_Encoder(BufferedTransformation *attachment=NULL) - : Unflushable(attachment) {} + {Detach(attachment);} BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1) - : Unflushable(attachment) { + Detach(attachment); IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet) (Name::Log2Base(), log2base) (Name::Pad(), padding != -1) @@ -36,11 +36,11 @@ class CRYPTOPP_DLL BaseN_Decoder : public Unflushable { public: BaseN_Decoder(BufferedTransformation *attachment=NULL) - : Unflushable(attachment) {} + {Detach(attachment);} BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL) - : Unflushable(attachment) { + Detach(attachment); IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base)); } @@ -60,11 +60,11 @@ class CRYPTOPP_DLL Grouper : public Bufferless { public: Grouper(BufferedTransformation *attachment=NULL) - : Bufferless(attachment) {} + {Detach(attachment);} Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL) - : Bufferless(attachment) { + Detach(attachment); IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize) (Name::Separator(), ConstByteArrayParameter(separator)) (Name::Terminator(), ConstByteArrayParameter(terminator))); diff --git a/cryptdll.dsp b/cryptdll.dsp index abdb9066..d0a071e2 100644 --- a/cryptdll.dsp +++ b/cryptdll.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo 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 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 # Begin Custom Build OutDir=.\DLL_Release diff --git a/cryptest.dsp b/cryptest.dsp index 3a07817f..2b6b2322 100644 --- a/cryptest.dsp +++ b/cryptest.dsp @@ -45,7 +45,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # 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 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 RSC /l 0x409 /d "NDEBUG" 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 Target_Dir "" # 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 RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -111,7 +111,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo 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 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 !ELSEIF "$(CFG)" == "cryptest - Win32 Debug" @@ -128,7 +128,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # 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 RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -136,7 +136,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo 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 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 !ENDIF diff --git a/cryptlib.cpp b/cryptlib.cpp index cc1e3ce6..cafaaa71 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -520,89 +520,93 @@ void GeneratableCryptoMaterial::GenerateRandomWithKeySize(RandomNumberGenerator GenerateRandom(rng, MakeParameters("KeySize", (int)keySize)); } +class PK_DefaultEncryptionFilter : public Unflushable +{ +public: + PK_DefaultEncryptionFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment, const NameValuePairs ¶meters) + : m_rng(rng), m_encryptor(encryptor), m_parameters(parameters) + { + Detach(attachment); + } + + unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) + { + FILTER_BEGIN; + m_plaintextQueue.Put(inString, length); + + if (messageEnd) + { + { + unsigned int plaintextLength = m_plaintextQueue.CurrentSize(); + unsigned int ciphertextLength = m_encryptor.CiphertextLength(plaintextLength); + + SecByteBlock plaintext(plaintextLength); + m_plaintextQueue.Get(plaintext, plaintextLength); + m_ciphertext.resize(ciphertextLength); + m_encryptor.Encrypt(m_rng, plaintext, plaintextLength, m_ciphertext, m_parameters); + } + + FILTER_OUTPUT(1, m_ciphertext, m_ciphertext.size(), messageEnd); + } + FILTER_END_NO_MESSAGE_END; + } + + RandomNumberGenerator &m_rng; + const PK_Encryptor &m_encryptor; + const NameValuePairs &m_parameters; + ByteQueue m_plaintextQueue; + SecByteBlock m_ciphertext; +}; + BufferedTransformation * PK_Encryptor::CreateEncryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment, const NameValuePairs ¶meters) const { - struct EncryptionFilter : public Unflushable - { - EncryptionFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment, const NameValuePairs ¶meters) - : Unflushable(attachment), m_rng(rng), m_encryptor(encryptor), m_parameters(parameters) - { - } - - unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) - { - FILTER_BEGIN; - m_plaintextQueue.Put(inString, length); - - if (messageEnd) - { - { - unsigned int plaintextLength = m_plaintextQueue.CurrentSize(); - unsigned int ciphertextLength = m_encryptor.CiphertextLength(plaintextLength); - - SecByteBlock plaintext(plaintextLength); - m_plaintextQueue.Get(plaintext, plaintextLength); - m_ciphertext.resize(ciphertextLength); - m_encryptor.Encrypt(m_rng, plaintext, plaintextLength, m_ciphertext, m_parameters); - } - - FILTER_OUTPUT(1, m_ciphertext, m_ciphertext.size(), messageEnd); - } - FILTER_END_NO_MESSAGE_END; - } - - RandomNumberGenerator &m_rng; - const PK_Encryptor &m_encryptor; - const NameValuePairs &m_parameters; - ByteQueue m_plaintextQueue; - SecByteBlock m_ciphertext; - }; - - return new EncryptionFilter(rng, *this, attachment, parameters); + return new PK_DefaultEncryptionFilter(rng, *this, attachment, parameters); } +class PK_DefaultDecryptionFilter : public Unflushable +{ +public: + PK_DefaultDecryptionFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment, const NameValuePairs ¶meters) + : m_rng(rng), m_decryptor(decryptor), m_parameters(parameters) + { + Detach(attachment); + } + + unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) + { + FILTER_BEGIN; + m_ciphertextQueue.Put(inString, length); + + if (messageEnd) + { + { + unsigned int ciphertextLength = m_ciphertextQueue.CurrentSize(); + unsigned int maxPlaintextLength = m_decryptor.MaxPlaintextLength(ciphertextLength); + + SecByteBlock ciphertext(ciphertextLength); + m_ciphertextQueue.Get(ciphertext, ciphertextLength); + m_plaintext.resize(maxPlaintextLength); + m_result = m_decryptor.Decrypt(m_rng, ciphertext, ciphertextLength, m_plaintext, m_parameters); + if (!m_result.isValidCoding) + throw InvalidCiphertext(m_decryptor.AlgorithmName() + ": invalid ciphertext"); + } + + FILTER_OUTPUT(1, m_plaintext, m_result.messageLength, messageEnd); + } + FILTER_END_NO_MESSAGE_END; + } + + RandomNumberGenerator &m_rng; + const PK_Decryptor &m_decryptor; + const NameValuePairs &m_parameters; + ByteQueue m_ciphertextQueue; + SecByteBlock m_plaintext; + DecodingResult m_result; +}; + BufferedTransformation * PK_Decryptor::CreateDecryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment, const NameValuePairs ¶meters) const { - struct DecryptionFilter : public Unflushable - { - DecryptionFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment, const NameValuePairs ¶meters) - : Unflushable(attachment), m_rng(rng), m_decryptor(decryptor), m_parameters(parameters) - { - } - - unsigned int Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) - { - FILTER_BEGIN; - m_ciphertextQueue.Put(inString, length); - - if (messageEnd) - { - { - unsigned int ciphertextLength = m_ciphertextQueue.CurrentSize(); - unsigned int maxPlaintextLength = m_decryptor.MaxPlaintextLength(ciphertextLength); - - SecByteBlock ciphertext(ciphertextLength); - m_ciphertextQueue.Get(ciphertext, ciphertextLength); - m_plaintext.resize(maxPlaintextLength); - m_result = m_decryptor.Decrypt(m_rng, ciphertext, ciphertextLength, m_plaintext, m_parameters); - if (!m_result.isValidCoding) - throw InvalidCiphertext(m_decryptor.AlgorithmName() + ": invalid ciphertext"); - } - - FILTER_OUTPUT(1, m_plaintext, m_result.messageLength, messageEnd); - } - FILTER_END_NO_MESSAGE_END; - } - - RandomNumberGenerator &m_rng; - const PK_Decryptor &m_decryptor; - const NameValuePairs &m_parameters; - ByteQueue m_ciphertextQueue; - SecByteBlock m_plaintext; - DecodingResult m_result; - }; - - return new DecryptionFilter(rng, *this, attachment, parameters); + return new PK_DefaultDecryptionFilter(rng, *this, attachment, parameters); } unsigned int PK_Signer::Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const diff --git a/cryptlib.dsp b/cryptlib.dsp index c5a5dead..1205ba2b 100644 --- a/cryptlib.dsp +++ b/cryptlib.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Intermediate_Dir "FIPS_140_Release" # 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 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 RSC /l 0x409 BSC32=bscmake.exe @@ -66,7 +66,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "FIPS_140_Debug" # 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 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 RSC /l 0x409 BSC32=bscmake.exe @@ -112,7 +112,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # 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 RSC /l 0x409 BSC32=bscmake.exe diff --git a/dlltest.cpp b/dlltest.cpp index ae7e1c37..a8b28133 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -12,7 +12,7 @@ void FIPS140_SampleApplication() { 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(); } diff --git a/dlltest.dsp b/dlltest.dsp index 0d82a114..005775c0 100644 --- a/dlltest.dsp +++ b/dlltest.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # 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 RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # 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 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 RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/eccrypto.h b/eccrypto.h index cb295a6a..25c6424b 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -118,7 +118,7 @@ public: const EllipticCurve& GetCurve() const {return m_groupPrecomputation.GetCurve();} bool operator==(const ThisClass &rhs) const - {return DL_GroupParametersImpl >::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 const Point& GetBasePoint() const {return GetSubgroupGenerator();} diff --git a/filters.cpp b/filters.cpp index 12c32dd6..7928abf4 100644 --- a/filters.cpp +++ b/filters.cpp @@ -40,14 +40,12 @@ const BufferedTransformation *Filter::AttachedTransformation() const void Filter::Detach(BufferedTransformation *newOut) { m_attachment.reset(newOut); - NotifyAttachmentChange(); } void Filter::Insert(Filter *filter) { filter->m_attachment.reset(m_attachment.release()); m_attachment.reset(filter); - NotifyAttachmentChange(); } 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; } +void RandomNumberStore::StoreInitialize(const NameValuePairs ¶meters) +{ + 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) { if (!blocking) throw NotImplemented("RandomNumberStore: nonblocking transfer is not implemented by this object"); unsigned long transferMax = transferBytes; - for (transferBytes = 0; transferBytesGenerateByte()); return 0; } diff --git a/filters.h b/filters.h index ccaa2ce1..8b26d669 100644 --- a/filters.h +++ b/filters.h @@ -14,7 +14,7 @@ NAMESPACE_BEGIN(CryptoPP) class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Filter : public BufferedTransformation, public NotCopyable { public: - Filter(BufferedTransformation *attachment); + Filter(BufferedTransformation *attachment = NULL); bool Attachable() {return true;} BufferedTransformation *AttachedTransformation(); @@ -29,7 +29,6 @@ public: bool MessageSeriesEnd(int propagation=-1, bool blocking=true); protected: - virtual void NotifyAttachmentChange() {} virtual BufferedTransformation * NewDefaultAttachment() const; void Insert(Filter *nextFilter); // insert filter after this one @@ -84,7 +83,7 @@ class CRYPTOPP_DLL MeterFilter : public Bufferless { public: MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true) - : Bufferless(attachment), m_transparent(transparent) {ResetMeter();} + : m_transparent(transparent) {Detach(attachment); ResetMeter();} void SetTransparent(bool transparent) {m_transparent = transparent;} void ResetMeter() {m_currentMessageBytes = m_totalBytes = m_currentSeriesMessages = m_totalMessages = m_totalMessageSeries = 0;} @@ -269,7 +268,7 @@ class CRYPTOPP_DLL HashFilter : public Bufferless, private FilterPutSpac { public: HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false) - : Bufferless(attachment), m_hashModule(hm), m_putMessage(putMessage) {} + : m_hashModule(hm), m_putMessage(putMessage) {Detach(attachment);} void IsolatedInitialize(const NameValuePairs ¶meters); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); @@ -321,7 +320,7 @@ class CRYPTOPP_DLL SignerFilter : public Unflushable { public: SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false) - : Unflushable(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 ¶meters); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); @@ -597,8 +596,11 @@ private: class CRYPTOPP_DLL RandomNumberStore : public Store { public: + RandomNumberStore() + : m_rng(NULL), m_length(0), m_count(0) {} + 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;} unsigned long MaxRetrievable() const {return m_length-m_count;} @@ -610,10 +612,10 @@ public: } private: - void StoreInitialize(const NameValuePairs ¶meters) {m_count = 0;} + void StoreInitialize(const NameValuePairs ¶meters); - RandomNumberGenerator &m_rng; - const unsigned long m_length; + RandomNumberGenerator *m_rng; + int m_length; unsigned long m_count; }; @@ -635,8 +637,8 @@ private: class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Source : public InputRejecting { public: - Source(BufferedTransformation *attachment) - : InputRejecting(attachment) {} + Source(BufferedTransformation *attachment = NULL) + {Detach(attachment);} unsigned long Pump(unsigned long pumpMax=ULONG_MAX) {Pump2(pumpMax); return pumpMax;} @@ -665,8 +667,6 @@ class SourceTemplate : public Source public: SourceTemplate(BufferedTransformation *attachment) : Source(attachment) {} - SourceTemplate(BufferedTransformation *attachment, T store) - : Source(attachment), m_store(store) {} void IsolatedInitialize(const NameValuePairs ¶meters) {m_store.IsolatedInitialize(parameters);} unsigned int Pump2(unsigned long &byteCount, bool blocking=true) @@ -704,8 +704,9 @@ public: class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate { public: - RandomNumberSource(RandomNumberGenerator &rng, unsigned int length, bool pumpAll, BufferedTransformation *attachment = NULL) - : SourceTemplate(attachment, RandomNumberStore(rng, length)) {if (pumpAll) PumpAll();} + RandomNumberSource(RandomNumberGenerator &rng, int length, bool pumpAll, BufferedTransformation *attachment = NULL) + : SourceTemplate(attachment) + {SourceInitialize(pumpAll, MakeParameters("RandomNumberGeneratorPointer", &rng)("RandomNumberStoreSize", length));} }; NAMESPACE_END diff --git a/ida.h b/ida.h index a19ff856..ba4cbd74 100644 --- a/ida.h +++ b/ida.h @@ -14,7 +14,7 @@ class RawIDA : public AutoSignaling > > { public: RawIDA(BufferedTransformation *attachment=NULL) - : AutoSignaling > >(attachment) {} + {Detach(attachment);} unsigned int GetThreshold() const {return m_threshold;} void AddOutputChannel(word32 channelId); @@ -57,8 +57,11 @@ class SecretSharing : public CustomFlushPropagation { public: SecretSharing(RandomNumberGenerator &rng, int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true) - : CustomFlushPropagation(attachment), m_rng(rng), m_ida(new OutputProxy(*this, true)) - {IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding));} + : m_rng(rng), m_ida(new OutputProxy(*this, true)) + { + Detach(attachment); + IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding)); + } void IsolatedInitialize(const NameValuePairs ¶meters=g_nullNameValuePairs); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); @@ -92,8 +95,11 @@ class InformationDispersal : public CustomFlushPropagation { public: InformationDispersal(int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true) - : CustomFlushPropagation(attachment), m_ida(new OutputProxy(*this, true)) - {IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding));} + : m_ida(new OutputProxy(*this, true)) + { + Detach(attachment); + IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("NumberOfShares", nShares)("AddPadding", addPadding)); + } void IsolatedInitialize(const NameValuePairs ¶meters=g_nullNameValuePairs); unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); @@ -127,7 +133,7 @@ class PaddingRemover : public Unflushable { public: PaddingRemover(BufferedTransformation *attachment=NULL) - : Unflushable(attachment), m_possiblePadding(false) {} + : m_possiblePadding(false) {Detach(attachment);} void IsolatedInitialize(const NameValuePairs ¶meters) {m_possiblePadding = false;} unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); diff --git a/mqueue.h b/mqueue.h index 1cad9214..1bf88926 100644 --- a/mqueue.h +++ b/mqueue.h @@ -69,8 +69,9 @@ public: /*! 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") - : Unflushable >(attachment), m_throwIfNotEqual(throwIfNotEqual), m_mismatchDetected(false) - , m_firstChannel(firstChannel), m_secondChannel(secondChannel) {} + : m_throwIfNotEqual(throwIfNotEqual), m_mismatchDetected(false) + , 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); bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true); diff --git a/network.h b/network.h index b4c79ac2..819cc7a7 100644 --- a/network.h +++ b/network.h @@ -11,7 +11,7 @@ class CRYPTOPP_NO_VTABLE NonblockingSource : public AutoSignaling { public: NonblockingSource(BufferedTransformation *attachment) - : AutoSignaling(attachment), m_messageEndSent(false) {} + : m_messageEndSent(false) {Detach(attachment);} //! \name NONBLOCKING SOURCE //@{ diff --git a/pubkey.h b/pubkey.h index 1d3666f9..272865fa 100644 --- a/pubkey.h +++ b/pubkey.h @@ -639,9 +639,6 @@ public: const DL_FixedBasePrecomputation & GetBasePrecomputation() const {return m_gpc;} DL_FixedBasePrecomputation & AccessBasePrecomputation() {return m_gpc;} - bool operator==(const DL_GroupParametersImpl &rhs) const - {return m_groupPrecomputation.GetCurve() == rhs.m_groupPrecomputation.GetCurve() && m_gpc.GetBase(m_groupPrecomputation) == rhs.m_gpc.GetBase(rhs.m_groupPrecomputation);} - protected: GROUP_PRECOMP m_groupPrecomputation; BASE_PRECOMP m_gpc; diff --git a/simple.h b/simple.h index 6a71b17e..1c3972e3 100644 --- a/simple.h +++ b/simple.h @@ -56,8 +56,6 @@ template class CRYPTOPP_NO_VTABLE Bufferless : public T { public: - Bufferless() {} - Bufferless(BufferedTransformation *q) : T(q) {} bool IsolatedFlush(bool hardFlush, bool blocking) {return false;} }; @@ -65,8 +63,6 @@ template class CRYPTOPP_NO_VTABLE Unflushable : public T { public: - Unflushable() {} - Unflushable(BufferedTransformation *q) : T(q) {} bool Flush(bool completeFlush, int propagation=-1, bool blocking=true) {return ChannelFlush(NULL_CHANNEL, completeFlush, propagation, blocking);} bool IsolatedFlush(bool hardFlush, bool blocking) @@ -90,10 +86,6 @@ template class CRYPTOPP_NO_VTABLE InputRejecting : public T { public: - InputRejecting() {} - InputRejecting(BufferedTransformation *q) : T(q) {} - -protected: struct InputRejected : public NotImplemented {InputRejected() : NotImplemented("BufferedTransformation: this object doesn't allow input") {}}; @@ -112,9 +104,6 @@ template class CRYPTOPP_NO_VTABLE CustomFlushPropagation : public T { public: - CustomFlushPropagation() {} - CustomFlushPropagation(BufferedTransformation *q) : T(q) {} - virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) =0; private: @@ -125,9 +114,6 @@ template class CRYPTOPP_NO_VTABLE CustomSignalPropagation : public CustomFlushPropagation { public: - CustomSignalPropagation() {} - CustomSignalPropagation(BufferedTransformation *q) : CustomFlushPropagation(q) {} - virtual void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1) =0; private: @@ -138,9 +124,6 @@ template class CRYPTOPP_NO_VTABLE Multichannel : public CustomFlushPropagation { public: - Multichannel() {} - Multichannel(BufferedTransformation *q) : CustomFlushPropagation(q) {} - bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) {return ChannelFlush(NULL_CHANNEL, hardFlush, propagation, blocking);} bool MessageSeriesEnd(int propagation=-1, bool blocking=true) @@ -171,7 +154,6 @@ class CRYPTOPP_NO_VTABLE AutoSignaling : public T { public: AutoSignaling(int propagation=-1) : m_autoSignalPropagation(propagation) {} - AutoSignaling(BufferedTransformation *q, int propagation=-1) : T(q), m_autoSignalPropagation(propagation) {} void SetAutoSignalPropagation(int propagation) {m_autoSignalPropagation = propagation;} diff --git a/zinflate.cpp b/zinflate.cpp index 685268f6..339d1b10 100644 --- a/zinflate.cpp +++ b/zinflate.cpp @@ -209,9 +209,10 @@ bool HuffmanDecoder::Decode(LowFirstBitReader &reader, value_t &value) const // ************************************************************* Inflator::Inflator(BufferedTransformation *attachment, bool repeat, int propagation) - : AutoSignaling(attachment, propagation) + : AutoSignaling(propagation) , m_state(PRE_STREAM), m_repeat(repeat), m_reader(m_inQueue) { + Detach(attachment); } void Inflator::IsolatedInitialize(const NameValuePairs ¶meters)