diff --git a/algparam.h b/algparam.h index 635aaafbc..7db6f1049 100644 --- a/algparam.h +++ b/algparam.h @@ -61,7 +61,7 @@ class ConstByteArrayParameter template ConstByteArrayParameter(const T &string, bool deepCopy = false) : m_deepCopy(false), m_data(NULL), m_size(0) { - CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1); + CRYPTOPP_COMPILE_ASSERT(sizeof(typename T::value_type) == 1); Assign((const byte *)string.data(), string.size(), deepCopy); } @@ -235,68 +235,6 @@ GetValueHelperClass GetValueHelper(const T *pObject, const char *name, con // ******************************************************** -// VC60 workaround -#if defined(_MSC_VER) && (_MSC_VER < 1300) -template -R Hack_DefaultValueFromConstReferenceType(const R &) -{ - return R(); -} - -template -bool Hack_GetValueIntoConstReference(const NameValuePairs &source, const char *name, const R &value) -{ - return source.GetValue(name, const_cast(value)); -} - -template -class AssignFromHelperClass -{ -public: - AssignFromHelperClass(T *pObject, const NameValuePairs &source) - : m_pObject(pObject), m_source(source), m_done(false) - { - if (source.GetThisObject(*pObject)) - m_done = true; - else if (typeid(BASE) != typeid(T)) - pObject->BASE::AssignFrom(source); - } - - template - AssignFromHelperClass & operator()(const char *name, void (T::*pm)(R)) // VC60 workaround: "const R &" here causes compiler error - { - if (!m_done) - { - R value = Hack_DefaultValueFromConstReferenceType(reinterpret_cast(*(int *)NULL)); - if (!Hack_GetValueIntoConstReference(m_source, name, value)) - throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name + "'"); - (m_pObject->*pm)(value); - } - return *this; - } - - template - AssignFromHelperClass & operator()(const char *name1, const char *name2, void (T::*pm)(R, S)) // VC60 workaround: "const R &" here causes compiler error - { - if (!m_done) - { - R value1 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast(*(int *)NULL)); - if (!Hack_GetValueIntoConstReference(m_source, name1, value1)) - throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name1 + "'"); - S value2 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast(*(int *)NULL)); - if (!Hack_GetValueIntoConstReference(m_source, name2, value2)) - throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name2 + "'"); - (m_pObject->*pm)(value1, value2); - } - return *this; - } - -private: - T *m_pObject; - const NameValuePairs &m_source; - bool m_done; -}; -#else template class AssignFromHelperClass { @@ -344,7 +282,6 @@ class AssignFromHelperClass const NameValuePairs &m_source; bool m_done; }; -#endif template AssignFromHelperClass AssignFromHelper(T *pObject, const NameValuePairs &source, BASE *dummy=NULL) @@ -382,22 +319,6 @@ class CRYPTOPP_DLL AlgorithmParametersBase ParameterNotUsed(const char *name) : Exception(OTHER_ERROR, std::string("AlgorithmParametersBase: parameter \"") + name + "\" not used") {} }; - // this is actually a move, not a copy - AlgorithmParametersBase(const AlgorithmParametersBase &x) - : m_name(x.m_name), m_throwIfNotUsed(x.m_throwIfNotUsed), m_used(x.m_used) - { - m_next.reset(const_cast(x).m_next.release()); - x.m_used = true; - } - - //! \brief Construct a AlgorithmParametersBase - //! \param name the parameter name - //! \param throwIfNotUsed flags indicating whether an exception should be thrown - //! \details If throwIfNotUsed is true, then a ParameterNotUsed exception - //! will be thrown in the destructor if the parameter is not not retrieved. - AlgorithmParametersBase(const char *name, bool throwIfNotUsed) - : m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {} - virtual ~AlgorithmParametersBase() CRYPTOPP_THROW { #ifdef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE @@ -416,11 +337,27 @@ class CRYPTOPP_DLL AlgorithmParametersBase #endif } + // this is actually a move, not a copy + AlgorithmParametersBase(const AlgorithmParametersBase &x) + : m_name(x.m_name), m_throwIfNotUsed(x.m_throwIfNotUsed), m_used(x.m_used) + { + m_next.reset(const_cast(x).m_next.release()); + x.m_used = true; + } + + //! \brief Construct a AlgorithmParametersBase + //! \param name the parameter name + //! \param throwIfNotUsed flags indicating whether an exception should be thrown + //! \details If throwIfNotUsed is true, then a ParameterNotUsed exception + //! will be thrown in the destructor if the parameter is not not retrieved. + AlgorithmParametersBase(const char *name, bool throwIfNotUsed) + : m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {} + bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const; protected: friend class AlgorithmParameters; - void operator=(const AlgorithmParametersBase& rhs); // assignment not allowed, declare this for VC60 + void operator=(const AlgorithmParametersBase& rhs); // assignment not allowed, declare this for VC60 virtual void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const =0; virtual void MoveInto(void *p) const =0; // not really const diff --git a/bench1.cpp b/bench1.cpp index ce29d45a4..1e8cb4c5b 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -206,13 +206,10 @@ void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValue OutputResultKeying(iterations, timeTaken); } -//VC60 workaround: compiler bug triggered without the extra dummy parameters -// on VC60 also needs to be named differently from BenchMarkByName template -void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T_FactoryOutput *x=NULL, T_Interface *y=NULL) +void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs) { - CRYPTOPP_UNUSED(x), CRYPTOPP_UNUSED(y), CRYPTOPP_UNUSED(params); - + CRYPTOPP_UNUSED(params); std::string name(factoryName ? factoryName : ""); member_ptr obj(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); @@ -229,20 +226,17 @@ void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char BenchMarkKeying(*obj, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), ConstByteArrayParameter(defaultKey, obj->IVSize()), false))); } -//VC60 workaround: compiler bug triggered without the extra dummy parameters template -void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T_FactoryOutput *x=NULL) +void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs) { - CRYPTOPP_UNUSED(x), CRYPTOPP_UNUSED(params); - - BenchMarkByName2(factoryName, keyLength, displayName, params, x, x); + CRYPTOPP_UNUSED(params); + BenchMarkByName2(factoryName, keyLength, displayName, params); } template -void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL) +void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs) { - CRYPTOPP_UNUSED(x), CRYPTOPP_UNUSED(params); - + CRYPTOPP_UNUSED(params); std::string name = factoryName; if (displayName) name = displayName; diff --git a/bench2.cpp b/bench2.cpp index 421596988..329887cfb 100644 --- a/bench2.cpp +++ b/bench2.cpp @@ -237,12 +237,9 @@ void BenchMarkAgreement(const char *name, AuthenticatedKeyAgreementDomainWithRol } #endif -//VC60 workaround: compiler bug triggered without the extra dummy parameters template -void BenchMarkCrypto(const char *filename, const char *name, double timeTotal, SCHEME *x=NULL) +void BenchMarkCrypto(const char *filename, const char *name, double timeTotal) { - CRYPTOPP_UNUSED(x); - FileSource f(filename, true, new HexDecoder()); typename SCHEME::Decryptor priv(f); typename SCHEME::Encryptor pub(priv); @@ -250,12 +247,9 @@ void BenchMarkCrypto(const char *filename, const char *name, double timeTotal, S BenchMarkDecryption(name, priv, pub, timeTotal); } -//VC60 workaround: compiler bug triggered without the extra dummy parameters template -void BenchMarkSignature(const char *filename, const char *name, double timeTotal, SCHEME *x=NULL) +void BenchMarkSignature(const char *filename, const char *name, double timeTotal) { - CRYPTOPP_UNUSED(x); - FileSource f(filename, true, new HexDecoder()); typename SCHEME::Signer priv(f); typename SCHEME::Verifier pub(priv); @@ -263,12 +257,9 @@ void BenchMarkSignature(const char *filename, const char *name, double timeTotal BenchMarkVerification(name, priv, pub, timeTotal); } -//VC60 workaround: compiler bug triggered without the extra dummy parameters template -void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal, D *x=NULL) +void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal) { - CRYPTOPP_UNUSED(x); - FileSource f(filename, true, new HexDecoder()); D d(f); BenchMarkKeyGen(name, d, timeTotal); diff --git a/blake2.cpp b/blake2.cpp index 931a35b1b..508b59db7 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -25,7 +25,7 @@ NAMESPACE_BEGIN(CryptoPP) // Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. Win32 lacks _mm_set_epi64x (Win64 supplies it except for VS2008). // Also see http://stackoverflow.com/a/38547909/608639 -#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600)) +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (defined(_MSC_VER) && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600)) inline __m128i _mm_set_epi64x(const word64 a, const word64 b) { const word64 t[2] = {b,a}; __m128i r; diff --git a/config.h b/config.h index 3051e43dd..5e42d7b2c 100644 --- a/config.h +++ b/config.h @@ -329,19 +329,8 @@ NAMESPACE_END #endif #endif -#if defined(_MSC_VER) - #if _MSC_VER == 1200 - #include - #endif - #if _MSC_VER > 1200 || defined(_mm_free) - #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later - #else - #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack - #endif -#endif - #ifndef CRYPTOPP_ALIGN_DATA - #if defined(CRYPTOPP_MSVC6PP_OR_LATER) + #if defined(_MSC_VER) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) #elif defined(__GNUC__) #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) @@ -374,20 +363,6 @@ NAMESPACE_END #define CRYPTOPP_FASTCALL #endif -// VC60 workaround: it doesn't allow typename in some places -#if defined(_MSC_VER) && (_MSC_VER < 1300) -#define CPP_TYPENAME -#else -#define CPP_TYPENAME typename -#endif - -// VC60 workaround: can't cast unsigned __int64 to float or double -#if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER) -#define CRYPTOPP_VC6_INT64 (__int64) -#else -#define CRYPTOPP_VC6_INT64 -#endif - #ifdef _MSC_VER #define CRYPTOPP_NO_VTABLE __declspec(novtable) #else @@ -455,7 +430,7 @@ NAMESPACE_END // C++Builder 2010 does not allow "call label" where label is defined within inline assembly #define CRYPTOPP_X86_ASM_AVAILABLE - #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__)) + #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__)) #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 #else #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0 @@ -476,7 +451,7 @@ NAMESPACE_END #define CRYPTOPP_X64_ASM_AVAILABLE #endif -#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) && !defined(_M_ARM) +#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__)) && !defined(_M_ARM) #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1 #else #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0 @@ -536,7 +511,7 @@ NAMESPACE_END #endif // how to allocate 16-byte aligned memory (for SSE2) -#if defined(CRYPTOPP_MSVC6PP_OR_LATER) +#if defined(_MSC_VER) #define CRYPTOPP_MM_MALLOC_AVAILABLE #elif defined(__APPLE__) #define CRYPTOPP_APPLE_MALLOC_AVAILABLE @@ -552,7 +527,7 @@ NAMESPACE_END // http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html // how to disable inlining -#if defined(_MSC_VER) && _MSC_VER >= 1300 +#if defined(_MSC_VER) # define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE __declspec(noinline) #elif defined(__GNUC__) diff --git a/cryptlib.h b/cryptlib.h index 07dce0810..0f2edd7ae 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -111,7 +111,7 @@ enum CipherDir { const unsigned long INFINITE_TIME = ULONG_MAX; // VC60 workaround: using enums as template parameters causes problems -//! \brief Converts a typename to an enumerated value +//! \brief Converts an enumeration to a type suitable for use as a template parameter template struct EnumToType { diff --git a/default.cpp b/default.cpp index 48d5d6444..f9b42085b 100644 --- a/default.cpp +++ b/default.cpp @@ -89,12 +89,10 @@ DefaultEncryptor::DefaultEncryptor(const byte *passphrase, size_t passphraseLeng { } - void DefaultEncryptor::FirstPut(const byte *) { - // VC60 workaround: __LINE__ expansion bug - CRYPTOPP_COMPILE_ASSERT_INSTANCE(SALTLENGTH <= DefaultHashModule::DIGESTSIZE, 1); - CRYPTOPP_COMPILE_ASSERT_INSTANCE(BLOCKSIZE <= DefaultHashModule::DIGESTSIZE, 2); + CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DefaultHashModule::DIGESTSIZE); + CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE <= DefaultHashModule::DIGESTSIZE); SecByteBlock salt(DefaultHashModule::DIGESTSIZE), keyCheck(DefaultHashModule::DIGESTSIZE); DefaultHashModule hash; diff --git a/dessp.cpp b/dessp.cpp index 938272106..46ca7aaf7 100644 --- a/dessp.cpp +++ b/dessp.cpp @@ -8,13 +8,6 @@ NAMESPACE_BEGIN(CryptoPP) -// VC60 workaround: gives a C4786 warning without this function -// when runtime lib is set to multithread debug DLL -// even though warning 4786 is disabled! -void DES_VC60Workaround() -{ -} - const word32 RawDES::Spbox[8][64] = { { 0x01010400,0x00000000,0x00010000,0x01010404, 0x01010004,0x00010404,0x00000004,0x00010000, diff --git a/dh.h b/dh.h index 1b7260a0a..9af0bc100 100644 --- a/dh.h +++ b/dh.h @@ -21,7 +21,7 @@ NAMESPACE_BEGIN(CryptoPP) //! for generating key pairs and deriving agreed values. //! \sa DL_SimpleKeyAgreementDomainBase //! \since Crypto++ 1.0 -template +template class DH_Domain : public DL_SimpleKeyAgreementDomainBase { typedef DL_SimpleKeyAgreementDomainBase Base; diff --git a/dll.cpp b/dll.cpp index 26a658a4a..118c9c195 100644 --- a/dll.cpp +++ b/dll.cpp @@ -56,9 +56,7 @@ NAMESPACE_END USING_NAMESPACE(CryptoPP) -#if !(defined(_MSC_VER) && (_MSC_VER < 1300)) using std::set_new_handler; -#endif static PNew s_pNew = NULL; static PDelete s_pDelete = NULL; @@ -161,4 +159,4 @@ void operator delete [] (void * p) operator delete (p); } -#endif // #ifdef CRYPTOPP_EXPORTS +#endif // CRYPTOPP_EXPORTS diff --git a/dll.h b/dll.h index 3fd4b0832..bdaf054e6 100644 --- a/dll.h +++ b/dll.h @@ -62,14 +62,10 @@ NAMESPACE_BEGIN(CryptoPP) -#if !(defined(_MSC_VER) && (_MSC_VER < 1300)) -using std::new_handler; -#endif - typedef void * (CRYPTOPP_API * PNew)(size_t); typedef void (CRYPTOPP_API * PDelete)(void *); typedef void (CRYPTOPP_API * PGetNewAndDelete)(PNew &, PDelete &); -typedef new_handler (CRYPTOPP_API * PSetNewHandler)(new_handler); +typedef std::new_handler (CRYPTOPP_API * PSetNewHandler)(std::new_handler); typedef void (CRYPTOPP_API * PSetNewAndDelete)(PNew, PDelete, PSetNewHandler); NAMESPACE_END diff --git a/eccrypto.cpp b/eccrypto.cpp index 19395a2cb..49f243678 100644 --- a/eccrypto.cpp +++ b/eccrypto.cpp @@ -46,8 +46,8 @@ static void ECDSA_TestInstantiations() #endif #endif -// VC60 workaround: complains when these functions are put into an anonymous namespace -static Integer ConvertToInteger(const PolynomialMod2 &x) +ANONYMOUS_NAMESPACE_BEGIN +Integer ConvertToInteger(const PolynomialMod2 &x) { unsigned int l = x.ByteCount(); SecByteBlock temp(l); @@ -55,12 +55,12 @@ static Integer ConvertToInteger(const PolynomialMod2 &x) return Integer(temp, l); } -static inline Integer ConvertToInteger(const Integer &x) +inline Integer ConvertToInteger(const Integer &x) { return x; } -static bool CheckMOVCondition(const Integer &q, const Integer &r) +bool CheckMOVCondition(const Integer &q, const Integer &r) { // see "Updated standards for validating elliptic curves", http://eprint.iacr.org/2007/343 Integer t = 1; @@ -77,6 +77,7 @@ static bool CheckMOVCondition(const Integer &q, const Integer &r) } return true; } +ANONYMOUS_NAMESPACE_END // ****************************************************************** @@ -626,13 +627,13 @@ void DL_GroupParameters_EC::SimultaneousExponentiate(Element *results, const } template -CPP_TYPENAME DL_GroupParameters_EC::Element DL_GroupParameters_EC::MultiplyElements(const Element &a, const Element &b) const +typename DL_GroupParameters_EC::Element DL_GroupParameters_EC::MultiplyElements(const Element &a, const Element &b) const { return GetCurve().Add(a, b); } template -CPP_TYPENAME DL_GroupParameters_EC::Element DL_GroupParameters_EC::CascadeExponentiate(const Element &element1, const Integer &exponent1, const Element &element2, const Integer &exponent2) const +typename DL_GroupParameters_EC::Element DL_GroupParameters_EC::CascadeExponentiate(const Element &element1, const Integer &exponent1, const Element &element2, const Integer &exponent2) const { return GetCurve().CascadeMultiply(exponent1, element1, exponent2, element2); } diff --git a/eccrypto.h b/eccrypto.h index 719e277a2..a20a96478 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -196,7 +196,7 @@ class DL_PrivateKey_EC : public DL_PrivateKeyImpl > //! \tparam EC elliptic curve field //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option" //! \sa Elliptic Curve Diffie-Hellman, AKA ECDH -template ::DefaultCofactorOption> +template ::DefaultCofactorOption> struct ECDH { typedef DH_Domain, COFACTOR_OPTION> Domain; @@ -207,7 +207,7 @@ struct ECDH //! \tparam EC elliptic curve field //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option" /// \sa Elliptic Curve Menezes-Qu-Vanstone, AKA ECMQV -template ::DefaultCofactorOption> +template ::DefaultCofactorOption> struct ECMQV { typedef MQV_Domain, COFACTOR_OPTION> Domain; @@ -219,7 +219,7 @@ struct ECMQV //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option" //! \details This implementation follows Hugo Krawczyk's HMQV: A High-Performance //! Secure Diffie-Hellman Protocol. Note: this implements HMQV only. HMQV-C with Key Confirmation is not provided. -template ::DefaultCofactorOption, class HASH = SHA256> +template ::DefaultCofactorOption, class HASH = SHA256> struct ECHMQV { typedef HMQV_Domain, COFACTOR_OPTION, HASH> Domain; @@ -237,7 +237,7 @@ typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 //! \details This implementation follows Augustin P. Sarr and Philippe Elbaz–Vincent, and Jean–Claude Bajard's //! A Secure and Efficient Authenticated Diffie-Hellman Protocol. //! Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C. -template ::DefaultCofactorOption, class HASH = SHA256> +template ::DefaultCofactorOption, class HASH = SHA256> struct ECFHMQV { typedef FHMQV_Domain, COFACTOR_OPTION, HASH> Domain; diff --git a/esign.h b/esign.h index 6afb544f3..fa6bd2f40 100644 --- a/esign.h +++ b/esign.h @@ -138,7 +138,7 @@ struct ESIGN_Keys //! \tparam STANDARD Signature encoding method //! \since Crypto++ 5.0 template -struct ESIGN : public TF_SS +struct ESIGN : public TF_SS { }; diff --git a/factory.h b/factory.h index 43df9f208..693db6dd2 100644 --- a/factory.h +++ b/factory.h @@ -42,7 +42,7 @@ class ObjectFactoryRegistry ~ObjectFactoryRegistry() { - for (CPP_TYPENAME Map::iterator i = m_map.begin(); i != m_map.end(); ++i) + for (typename Map::iterator i = m_map.begin(); i != m_map.end(); ++i) { delete (ObjectFactory *)i->second; i->second = NULL; @@ -56,7 +56,7 @@ class ObjectFactoryRegistry const ObjectFactory * GetFactory(const char *name) const { - CPP_TYPENAME Map::const_iterator i = m_map.find(name); + typename Map::const_iterator i = m_map.find(name); return i == m_map.end() ? NULL : (ObjectFactory *)i->second; } @@ -73,7 +73,7 @@ class ObjectFactoryRegistry std::vector GetFactoryNames() const { std::vector names; - CPP_TYPENAME Map::const_iterator iter; + typename Map::const_iterator iter; for (iter = m_map.begin(); iter != m_map.end(); ++iter) names.push_back(iter->first); return names; @@ -110,32 +110,32 @@ template void RegisterAsymmetricCipherDefaultFactories(const char *name=NULL, SchemeClass *dummy=NULL) { CRYPTOPP_UNUSED(dummy); - RegisterDefaultFactoryFor((const char *)name); - RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); } template void RegisterSignatureSchemeDefaultFactories(const char *name=NULL, SchemeClass *dummy=NULL) { CRYPTOPP_UNUSED(dummy); - RegisterDefaultFactoryFor((const char *)name); - RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); } template void RegisterSymmetricCipherDefaultFactories(const char *name=NULL, SchemeClass *dummy=NULL) { CRYPTOPP_UNUSED(dummy); - RegisterDefaultFactoryFor((const char *)name); - RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); } template void RegisterAuthenticatedSymmetricCipherDefaultFactories(const char *name=NULL, SchemeClass *dummy=NULL) { CRYPTOPP_UNUSED(dummy); - RegisterDefaultFactoryFor((const char *)name); - RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); + RegisterDefaultFactoryFor((const char *)name); } NAMESPACE_END diff --git a/fhmqv.h b/fhmqv.h index 260324a19..2d0112002 100644 --- a/fhmqv.h +++ b/fhmqv.h @@ -20,7 +20,7 @@ NAMESPACE_BEGIN(CryptoPP) //! Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C. //! \sa MQV, HMQV, FHMQV, and AuthenticatedKeyAgreementDomain //! \since Crypto++ 5.6.4 -template +template class FHMQV_Domain : public AuthenticatedKeyAgreementDomain { public: diff --git a/gfpcrypt.h b/gfpcrypt.h index e1e0a22b6..4e4b38b77 100644 --- a/gfpcrypt.h +++ b/gfpcrypt.h @@ -97,7 +97,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE DL_GroupParameters_IntegerBased : public A //! \brief Integer-based GroupParameters default implementation //! \tparam GROUP_PRECOMP group parameters precomputation specialization //! \tparam BASE_PRECOMP base class precomputation specialization -template > +template > class CRYPTOPP_NO_VTABLE DL_GroupParameters_IntegerBasedImpl : public DL_GroupParametersImpl { typedef DL_GroupParameters_IntegerBasedImpl ThisClass; diff --git a/hmqv.h b/hmqv.h index c7e81255b..2abe00c71 100644 --- a/hmqv.h +++ b/hmqv.h @@ -19,7 +19,7 @@ NAMESPACE_BEGIN(CryptoPP) //! Secure Diffie-Hellman Protocol. Note: this implements HMQV only. HMQV-C with Key Confirmation is not provided. //! \sa MQV, HMQV, FHMQV, and AuthenticatedKeyAgreementDomain //! \since Crypto++ 5.6.4 -template +template class HMQV_Domain: public AuthenticatedKeyAgreementDomain { public: diff --git a/hrtimer.cpp b/hrtimer.cpp index 615293572..c8869dcb9 100644 --- a/hrtimer.cpp +++ b/hrtimer.cpp @@ -54,7 +54,7 @@ double TimerBase::ConvertTo(TimerWord t, Unit unit) // When 'unit' is an enum 'Unit', a Clang warning is generated. CRYPTOPP_ASSERT(static_cast(unit) < COUNTOF(unitsPerSecondTable)); - return (double)CRYPTOPP_VC6_INT64 t * unitsPerSecondTable[unit] / CRYPTOPP_VC6_INT64 TicksPerSecond(); + return static_cast(t) * unitsPerSecondTable[unit] / TicksPerSecond(); } void TimerBase::StartTimer() diff --git a/integer.cpp b/integer.cpp index 4dc9dfcb9..4549ace94 100644 --- a/integer.cpp +++ b/integer.cpp @@ -46,10 +46,6 @@ #include #endif -#ifdef CRYPTOPP_MSVC6_NO_PP - #pragma message("You do not seem to have the Visual C++ Processor Pack installed, so use of SSE2 instructions will be disabled.") -#endif - // "Error: The operand ___LKDB cannot be assigned to", http://github.com/weidai11/cryptopp/issues/188 #if (__SUNPRO_CC >= 0x5130) # define MAYBE_CONST @@ -70,7 +66,7 @@ # define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0 # define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0 #else -# define CRYPTOPP_INTEGER_SSE2 (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && CRYPTOPP_BOOL_X86) +# define CRYPTOPP_INTEGER_SSE2 (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86)) #endif NAMESPACE_BEGIN(CryptoPP) @@ -567,13 +563,8 @@ inline word DWord::operator%(word a) __asm pop esi \ __asm pop edi \ __asm ret 8 -#if _MSC_VER < 1300 - #define SaveEBX __asm push ebx - #define RestoreEBX __asm pop ebx -#else #define SaveEBX #define RestoreEBX -#endif #define SquPrologue \ AS2( mov eax, A) \ AS2( mov ecx, C) \ @@ -862,8 +853,8 @@ CRYPTOPP_NAKED int CRYPTOPP_FASTCALL SSE2_Sub(size_t N, word *C, const word *A, AddEpilogue } -#endif // #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE -#else +#endif // CRYPTOPP_INTEGER_SSE2 +#else // CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE int CRYPTOPP_FASTCALL Baseline_Add(size_t N, word *C, const word *A, const word *B) { CRYPTOPP_ASSERT (N%2 == 0); @@ -2082,7 +2073,7 @@ static PAdd s_pAdd = &Baseline_Add, s_pSub = &Baseline_Sub; static size_t s_recursionLimit = 8; #else static const size_t s_recursionLimit = 16; -#endif +#endif // CRYPTOPP_INTEGER_SSE2 static PMul s_pMul[9], s_pBot[9]; static PSqu s_pSqu[9]; @@ -2099,13 +2090,11 @@ static void SetFunctionPointers() #if CRYPTOPP_INTEGER_SSE2 if (HasSSE2()) { -#if _MSC_VER != 1200 || !(CRYPTOPP_DEBUG) if (IsP4()) { s_pAdd = &SSE2_Add; s_pSub = &SSE2_Sub; } -#endif s_recursionLimit = 32; @@ -2129,7 +2118,7 @@ static void SetFunctionPointers() s_pTop[8] = &SSE2_MultiplyTop32; } else -#endif +#endif // CRYPTOPP_INTEGER_SSE2 { s_pMul[1] = &Baseline_Multiply4; s_pMul[2] = &Baseline_Multiply8; @@ -2147,7 +2136,7 @@ static void SetFunctionPointers() s_pBot[4] = &Baseline_MultiplyBottom16; s_pSqu[4] = &Baseline_Square16; s_pTop[4] = &Baseline_MultiplyTop16; -#endif +#endif // !CRYPTOPP_INTEGER_SSE2 } } @@ -2157,7 +2146,7 @@ inline int Add(word *C, const word *A, const word *B, size_t N) return s_pAdd(N, C, A, B); #else return Baseline_Add(N, C, A, B); -#endif +#endif // CRYPTOPP_INTEGER_SSE2 } inline int Subtract(word *C, const word *A, const word *B, size_t N) @@ -2166,7 +2155,7 @@ inline int Subtract(word *C, const word *A, const word *B, size_t N) return s_pSub(N, C, A, B); #else return Baseline_Sub(N, C, A, B); -#endif +#endif // CRYPTOPP_INTEGER_SSE2 } // ******************************************************** diff --git a/lubyrack.h b/lubyrack.h index 1845fd4a1..3808e931b 100644 --- a/lubyrack.h +++ b/lubyrack.h @@ -11,15 +11,10 @@ NAMESPACE_BEGIN(CryptoPP) -template struct DigestSizeDoubleWorkaround // VC60 workaround -{ - CRYPTOPP_CONSTANT(RESULT = 2*T::DIGESTSIZE) -}; - //! \class LR_Info //! \brief Luby-Rackoff block cipher information template -struct LR_Info : public VariableKeyLength<16, 0, 2*(INT_MAX/2), 2>, public FixedBlockSize::RESULT> +struct LR_Info : public VariableKeyLength<16, 0, 2*(INT_MAX/2), 2>, public FixedBlockSize<2*T::DIGESTSIZE> { static std::string StaticAlgorithmName() {return std::string("LR/")+T::StaticAlgorithmName();} }; diff --git a/luc.h b/luc.h index beb07c0ed..ea16a44ad 100644 --- a/luc.h +++ b/luc.h @@ -116,7 +116,7 @@ struct LUC //! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes //! defined later in this .h file may be of more practical interest. template -struct LUCES : public TF_ES +struct LUCES : public TF_ES { }; @@ -125,7 +125,7 @@ struct LUCES : public TF_ES //! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes //! defined later in this .h file may be of more practical interest. template -struct LUCSS : public TF_SS +struct LUCSS : public TF_SS { }; diff --git a/misc.cpp b/misc.cpp index 9d30fa965..d77c2c33e 100644 --- a/misc.cpp +++ b/misc.cpp @@ -197,13 +197,11 @@ std::string StringNarrow(const wchar_t *str, bool throwOnError) return result; } -#if !(defined(_MSC_VER) && (_MSC_VER < 1300)) -using std::new_handler; -using std::set_new_handler; -#endif - void CallNewHandler() { + using std::new_handler; + using std::set_new_handler; + new_handler newHandler = set_new_handler(NULL); if (newHandler) set_new_handler(newHandler); diff --git a/misc.h b/misc.h index 721c518a6..b10ce8b32 100644 --- a/misc.h +++ b/misc.h @@ -473,7 +473,7 @@ inline void * memset_z(void *ptr, int value, size_t num) //! \param a the first value //! \param b the second value //! \returns the minimum value based on a comparison of b \< a using operator\< -//! \details STDMIN was provided because the library could not use std::min or std::max in MSVC60 or Cygwin 1.1.0 +//! \details STDMIN was provided because the library could not easily use std::min or std::max in Windows or Cygwin 1.1.0 template inline const T& STDMIN(const T& a, const T& b) { return b < a ? b : a; @@ -483,10 +483,9 @@ template inline const T& STDMIN(const T& a, const T& b) //! \param a the first value //! \param b the second value //! \returns the minimum value based on a comparison of a \< b using operator\< -//! \details STDMAX was provided because the library could not use std::min or std::max in MSVC60 or Cygwin 1.1.0 +//! \details STDMAX was provided because the library could not easily use std::min or std::max in Windows or Cygwin 1.1.0 template inline const T& STDMAX(const T& a, const T& b) { - // can't use std::min or std::max in MSVC60 or Cygwin 1.1.0 return a < b ? b : a; } @@ -911,7 +910,6 @@ inline T1 RoundUpToMultipleOf(const T1 &n, const T2 &m) } //! \brief Returns the minimum alignment requirements of a type -//! \param dummy an unused Visual C++ 6.0 workaround //! \returns the minimum alignment requirements of a type, in bytes //! \details Internally the function calls C++11's alignof if available. If not available, //! then the function uses compiler specific extensions such as __alignof and @@ -921,14 +919,14 @@ inline T1 RoundUpToMultipleOf(const T1 &n, const T2 &m) //! In all cases, if CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS is defined, then the //! function returns 1. template -inline unsigned int GetAlignmentOf(T *dummy=NULL) // VC60 workaround +inline unsigned int GetAlignmentOf() { // GCC 4.6 (circa 2008) and above aggressively uses vectorization. #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) if (sizeof(T) < 16) return 1; #endif - CRYPTOPP_UNUSED(dummy); + #if defined(CRYPTOPP_CXX11_ALIGNOF) return alignof(T); #elif (_MSC_VER >= 1300) @@ -960,13 +958,11 @@ inline bool IsAlignedOn(const void *ptr, unsigned int alignment) //! \brief Determines whether ptr is minimally aligned //! \param ptr the pointer to check for alignment -//! \param dummy an unused Visual C++ 6.0 workaround //! \returns true if ptr follows native byte ordering, false otherwise //! \details Internally the function calls IsAlignedOn with a second parameter of GetAlignmentOf template -inline bool IsAligned(const void *ptr, T *dummy=NULL) // VC60 workaround +inline bool IsAligned(const void *ptr) { - CRYPTOPP_UNUSED(dummy); return IsAlignedOn(ptr, GetAlignmentOf()); } diff --git a/modes.h b/modes.h index 4eb026085..20c1de612 100644 --- a/modes.h +++ b/modes.h @@ -336,8 +336,8 @@ CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate struct CFB_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder > > > Encryption; - typedef CipherModeFinalTemplate_CipherHolder > > > Decryption; + typedef CipherModeFinalTemplate_CipherHolder > > > Encryption; + typedef CipherModeFinalTemplate_CipherHolder > > > Decryption; }; //! \class CFB_Mode_ExternalCipher @@ -354,8 +354,8 @@ struct CFB_Mode_ExternalCipher : public CipherModeDocumentation template struct CFB_FIPS_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder > > > > Encryption; - typedef CipherModeFinalTemplate_CipherHolder > > > > Decryption; + typedef CipherModeFinalTemplate_CipherHolder > > > > Encryption; + typedef CipherModeFinalTemplate_CipherHolder > > > > Decryption; }; //! \class CFB_FIPS_Mode_ExternalCipher @@ -374,7 +374,7 @@ CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate struct OFB_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder > > > Encryption; + typedef CipherModeFinalTemplate_CipherHolder > > > Encryption; typedef Encryption Decryption; }; @@ -394,7 +394,7 @@ CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher struct CTR_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder > > > Encryption; + typedef CipherModeFinalTemplate_CipherHolder > > > Encryption; typedef Encryption Decryption; }; @@ -411,8 +411,8 @@ struct CTR_Mode_ExternalCipher : public CipherModeDocumentation template struct ECB_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder Encryption; - typedef CipherModeFinalTemplate_CipherHolder Decryption; + typedef CipherModeFinalTemplate_CipherHolder Encryption; + typedef CipherModeFinalTemplate_CipherHolder Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher; @@ -429,8 +429,8 @@ struct ECB_Mode_ExternalCipher : public CipherModeDocumentation template struct CBC_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder Encryption; - typedef CipherModeFinalTemplate_CipherHolder Decryption; + typedef CipherModeFinalTemplate_CipherHolder Encryption; + typedef CipherModeFinalTemplate_CipherHolder Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher; @@ -447,8 +447,8 @@ struct CBC_Mode_ExternalCipher : public CipherModeDocumentation template struct CBC_CTS_Mode : public CipherModeDocumentation { - typedef CipherModeFinalTemplate_CipherHolder Encryption; - typedef CipherModeFinalTemplate_CipherHolder Decryption; + typedef CipherModeFinalTemplate_CipherHolder Encryption; + typedef CipherModeFinalTemplate_CipherHolder Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher; diff --git a/mqv.h b/mqv.h index cad301175..b7f898854 100644 --- a/mqv.h +++ b/mqv.h @@ -23,7 +23,7 @@ NAMESPACE_BEGIN(CryptoPP) //! Binary curves use a polynomial to represent its characteristic, while prime curves //! use a prime number. //! \sa MQV, HMQV, FHMQV, and AuthenticatedKeyAgreementDomain -template +template class MQV_Domain : public AuthenticatedKeyAgreementDomain { public: diff --git a/network.cpp b/network.cpp index 70d98339a..acafae8a8 100644 --- a/network.cpp +++ b/network.cpp @@ -399,7 +399,7 @@ float NetworkSink::ComputeCurrentSpeed() float NetworkSink::GetMaxObservedSpeed() const { lword m = GetMaxBytesPerSecond(); - return m ? STDMIN(m_maxObservedSpeed, float(CRYPTOPP_VC6_INT64 m)) : m_maxObservedSpeed; + return m ? STDMIN(m_maxObservedSpeed, static_cast(m)) : m_maxObservedSpeed; } unsigned int NetworkSink::GetMaxWaitObjectCount() const diff --git a/poly1305.h b/poly1305.h index 9fb8b90d4..9bc56ef81 100644 --- a/poly1305.h +++ b/poly1305.h @@ -86,7 +86,7 @@ class CRYPTOPP_NO_VTABLE Poly1305_Base : public FixedKeyLength<32, SimpleKeyingI void HashBlocks(const byte *input, size_t length, word32 padbit); void HashFinal(byte *mac, size_t length); - CPP_TYPENAME T::Encryption m_cipher; + typename T::Encryption m_cipher; // Accumulated hash, clamped r-key, and encrypted nonce FixedSizeAlignedSecBlock m_h; diff --git a/pubkey.h b/pubkey.h index 65503166b..7db0e816a 100644 --- a/pubkey.h +++ b/pubkey.h @@ -52,9 +52,6 @@ #include "smartptr.h" #include "stdcpp.h" -// VC60 workaround: this macro is defined in shlobj.h and conflicts with a template parameter used in this file -#undef INTERFACE - #if defined(__SUNPRO_CC) # define MAYBE_RETURN(x) return x #else @@ -273,10 +270,10 @@ class CRYPTOPP_NO_VTABLE PK_FixedLengthCryptoSystemImpl : public BASE //! \class TF_CryptoSystemBase //! \brief Trapdoor function cryptosystem base class -//! \tparam INTERFACE public key cryptosystem base interface +//! \tparam INTFACE public key cryptosystem base interface //! \tparam BASE public key cryptosystem implementation base -template -class CRYPTOPP_NO_VTABLE TF_CryptoSystemBase : public PK_FixedLengthCryptoSystemImpl, protected BASE +template +class CRYPTOPP_NO_VTABLE TF_CryptoSystemBase : public PK_FixedLengthCryptoSystemImpl, protected BASE { public: virtual ~TF_CryptoSystemBase() {} @@ -478,8 +475,8 @@ class PK_MessageAccumulatorImpl : public PK_MessageAccumulatorBase, protected Ob }; //! _ -template -class CRYPTOPP_NO_VTABLE TF_SignatureSchemeBase : public INTERFACE, protected BASE +template +class CRYPTOPP_NO_VTABLE TF_SignatureSchemeBase : public INTFACE, protected BASE { public: virtual ~TF_SignatureSchemeBase() {} @@ -571,16 +568,16 @@ class CRYPTOPP_NO_VTABLE TF_ObjectImplBase : public AlgorithmImpl; + return new PK_MessageAccumulatorImpl; } PK_MessageAccumulator * NewVerificationAccumulator() const { - return new PK_MessageAccumulatorImpl; + return new PK_MessageAccumulatorImpl; } protected: const typename BASE::MessageEncodingInterface & GetMessageEncodingInterface() const - {return Singleton().Ref();} + {return Singleton().Ref();} const TrapdoorFunctionBounds & GetTrapdoorFunctionBounds() const {return GetKey();} const typename BASE::TrapdoorFunctionInterface & GetTrapdoorFunctionInterface() const @@ -589,12 +586,12 @@ class CRYPTOPP_NO_VTABLE TF_ObjectImplBase : public AlgorithmImpl L; + typedef typename SchemeOptions::MessageEncodingMethod::HashIdentifierLookup::template HashIdentifierLookup2 L; return L::Lookup(); } size_t GetDigestSize() const { - typedef CPP_TYPENAME SchemeOptions::HashFunction H; + typedef typename SchemeOptions::HashFunction H; return H::DIGESTSIZE; } }; @@ -940,7 +937,7 @@ class CRYPTOPP_NO_VTABLE DL_GroupParameters : public CryptoParameters //! \tparam GROUP_PRECOMP group precomputation class //! \tparam BASE_PRECOMP fixed base precomputation class //! \tparam BASE class or type of an element -template , class BASE = DL_GroupParameters > +template , class BASE = DL_GroupParameters > class DL_GroupParametersImpl : public BASE { public: @@ -1098,7 +1095,7 @@ class PKCS8PrivateKey; //! _ template -class DL_PrivateKeyImpl : public DL_PrivateKey, public DL_KeyImpl +class DL_PrivateKeyImpl : public DL_PrivateKey, public DL_KeyImpl { public: typedef typename GP::Element Element; @@ -1329,12 +1326,12 @@ class CRYPTOPP_NO_VTABLE DL_Base }; //! \brief Discrete Log (DL) signature scheme base implementation -//! \tparam INTERFACE PK_Signer or PK_Verifier derived class +//! \tparam INTFACE PK_Signer or PK_Verifier derived class //! \tparam DL_Base key base used in the scheme //! \details DL_SignatureSchemeBase provides common functions for signers and verifiers. //! DL_Base is used for signers, and DL_Base is used for verifiers. -template -class CRYPTOPP_NO_VTABLE DL_SignatureSchemeBase : public INTERFACE, public DL_Base +template +class CRYPTOPP_NO_VTABLE DL_SignatureSchemeBase : public INTFACE, public DL_Base { public: virtual ~DL_SignatureSchemeBase() {} @@ -1379,7 +1376,7 @@ class CRYPTOPP_NO_VTABLE DL_SignatureSchemeBase : public INTERFACE, public DL_Ba size_t MessageRepresentativeLength() const {return BitsToBytes(MessageRepresentativeBitLength());} size_t MessageRepresentativeBitLength() const {return this->GetAbstractGroupParameters().GetSubgroupOrder().BitCount();} - virtual const DL_ElgamalLikeSignatureAlgorithm & GetSignatureAlgorithm() const =0; + virtual const DL_ElgamalLikeSignatureAlgorithm & GetSignatureAlgorithm() const =0; virtual const PK_SignatureMessageEncodingMethod & GetMessageEncodingInterface() const =0; virtual HashIdentifier GetHashIdentifier() const =0; virtual size_t GetDigestSize() const =0; @@ -1736,11 +1733,11 @@ class CRYPTOPP_NO_VTABLE DL_ObjectImplBase : public AlgorithmImpl::Lookup(); + return HashLookup::template HashIdentifierLookup2::Lookup(); } size_t GetDigestSize() const { - typedef CPP_TYPENAME SchemeOptions::HashFunction H; + typedef typename SchemeOptions::HashFunction H; return H::DIGESTSIZE; } @@ -1762,17 +1759,17 @@ class CRYPTOPP_NO_VTABLE DL_ObjectImpl : public DL_ObjectImplBase & GetSignatureAlgorithm() const - {return Singleton().Ref();} + {return Singleton().Ref();} const DL_KeyAgreementAlgorithm & GetKeyAgreementAlgorithm() const - {return Singleton().Ref();} + {return Singleton().Ref();} const DL_KeyDerivationAlgorithm & GetKeyDerivationAlgorithm() const - {return Singleton().Ref();} + {return Singleton().Ref();} const DL_SymmetricEncryptionAlgorithm & GetSymmetricEncryptionAlgorithm() const - {return Singleton().Ref();} + {return Singleton().Ref();} HashIdentifier GetHashIdentifier() const {return HashIdentifier();} const PK_SignatureMessageEncodingMethod & GetMessageEncodingInterface() const - {return Singleton().Ref();} + {return Singleton().Ref();} }; //! \brief Discrete Log (DL) signer implementation @@ -1783,7 +1780,7 @@ class DL_SignerImpl : public DL_ObjectImpl p(new PK_MessageAccumulatorImpl); + member_ptr p(new PK_MessageAccumulatorImpl); this->RestartMessageAccumulator(rng, *p); return p.release(); } @@ -1797,7 +1794,7 @@ class DL_VerifierImpl : public DL_ObjectImpl; + return new PK_MessageAccumulatorImpl; } }; @@ -2042,10 +2039,10 @@ struct SignatureStandard {}; //! \tparam STANDARD standard //! \tparam KEYS keys used in the encryption scheme //! \tparam ALG_INFO algorithm information -template +template class TF_ES; -template > +template > class TF_ES : public KEYS { typedef typename STANDARD::EncryptionMessageEncodingMethod MessageEncodingMethod; @@ -2069,10 +2066,10 @@ class TF_ES : public KEYS //! \tparam H hash function //! \tparam KEYS keys used in the signature scheme //! \tparam ALG_INFO algorithm information -template // VC60 workaround: doesn't work if KEYS is first parameter +template class TF_SS; -template > // VC60 workaround: doesn't work if KEYS is first parameter +template > class TF_SS : public KEYS { public: diff --git a/rabin.h b/rabin.h index dcc86c5ec..799676d6d 100644 --- a/rabin.h +++ b/rabin.h @@ -90,13 +90,13 @@ struct Rabin //! Rabin encryption template -struct RabinES : public TF_ES +struct RabinES : public TF_ES { }; //! Rabin signature template -struct RabinSS : public TF_SS +struct RabinSS : public TF_SS { }; diff --git a/rdtables.cpp b/rdtables.cpp index 870f6480e..8b2cea5b5 100644 --- a/rdtables.cpp +++ b/rdtables.cpp @@ -6,13 +6,6 @@ #include "rijndael.h" -// VC60 workaround: gives a C4786 warning without this function -// when runtime lib is set to multithread debug DLL -// even though warning 4786 is disabled! -void Rijndael_VC60Workaround() -{ -} - NAMESPACE_BEGIN(CryptoPP) /* diff --git a/rsa.h b/rsa.h index 044227f73..eacb97c48 100644 --- a/rsa.h +++ b/rsa.h @@ -168,7 +168,7 @@ struct CRYPTOPP_DLL RSA //! \sa RSA cryptosystem //! \since Crypto++ 1.0 template -struct RSAES : public TF_ES +struct RSAES : public TF_ES { }; @@ -180,7 +180,7 @@ struct RSAES : public TF_ES //! \sa RSA signature scheme with appendix //! \since Crypto++ 1.0 template -struct RSASS : public TF_SS +struct RSASS : public TF_SS { }; @@ -199,7 +199,7 @@ struct CRYPTOPP_DLL RSA_ISO //! \tparam H hash transformation //! \since Crypto++ 1.0 template -struct RSASS_ISO : public TF_SS +struct RSASS_ISO : public TF_SS { }; diff --git a/rw.h b/rw.h index 140dbe92e..1a70736c7 100644 --- a/rw.h +++ b/rw.h @@ -119,7 +119,7 @@ struct RW //! \class RWSS //! \brief Rabin-Williams signature scheme template -struct RWSS : public TF_SS +struct RWSS : public TF_SS { }; diff --git a/shark.cpp b/shark.cpp index b9bd1307c..e84debee9 100644 --- a/shark.cpp +++ b/shark.cpp @@ -90,29 +90,25 @@ void SHARK::Enc::InitForKeySetup() #endif } -typedef word64 ArrayOf256Word64s[256]; - -template -struct SharkProcessAndXorBlock{ // VC60 workaround: problem with template functions -inline SharkProcessAndXorBlock(const word64 *roundKeys, unsigned int rounds, const byte *inBlock, const byte *xorBlock, byte *outBlock) +void SHARK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { CRYPTOPP_ASSERT(IsAlignedOn(inBlock,GetAlignmentOf())); - word64 tmp = *(word64 *)(void *)inBlock ^ roundKeys[0]; + word64 tmp = *(word64 *)(void *)inBlock ^ m_roundKeys[0]; ByteOrder order = GetNativeByteOrder(); tmp = cbox[0][GetByte(order, tmp, 0)] ^ cbox[1][GetByte(order, tmp, 1)] ^ cbox[2][GetByte(order, tmp, 2)] ^ cbox[3][GetByte(order, tmp, 3)] ^ cbox[4][GetByte(order, tmp, 4)] ^ cbox[5][GetByte(order, tmp, 5)] ^ cbox[6][GetByte(order, tmp, 6)] ^ cbox[7][GetByte(order, tmp, 7)] - ^ roundKeys[1]; + ^ m_roundKeys[1]; - for(unsigned int i=2; i(xorBlock, outBlock) @@ -126,17 +122,42 @@ inline SharkProcessAndXorBlock(const word64 *roundKeys, unsigned int rounds, con (sbox[GETBYTE(tmp, 0)]); CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf())); - *(word64 *)(void *)outBlock ^= roundKeys[rounds]; -}}; - -void SHARK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const -{ - SharkProcessAndXorBlock(m_roundKeys, m_rounds, inBlock, xorBlock, outBlock); + *(word64 *)(void *)outBlock ^= m_roundKeys[m_rounds]; } void SHARK::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { - SharkProcessAndXorBlock(m_roundKeys, m_rounds, inBlock, xorBlock, outBlock); + CRYPTOPP_ASSERT(IsAlignedOn(inBlock,GetAlignmentOf())); + word64 tmp = *(word64 *)(void *)inBlock ^ m_roundKeys[0]; + + ByteOrder order = GetNativeByteOrder(); + tmp = cbox[0][GetByte(order, tmp, 0)] ^ cbox[1][GetByte(order, tmp, 1)] + ^ cbox[2][GetByte(order, tmp, 2)] ^ cbox[3][GetByte(order, tmp, 3)] + ^ cbox[4][GetByte(order, tmp, 4)] ^ cbox[5][GetByte(order, tmp, 5)] + ^ cbox[6][GetByte(order, tmp, 6)] ^ cbox[7][GetByte(order, tmp, 7)] + ^ m_roundKeys[1]; + + for(unsigned int i=2; i(xorBlock, outBlock) + (sbox[GETBYTE(tmp, 7)]) + (sbox[GETBYTE(tmp, 6)]) + (sbox[GETBYTE(tmp, 5)]) + (sbox[GETBYTE(tmp, 4)]) + (sbox[GETBYTE(tmp, 3)]) + (sbox[GETBYTE(tmp, 2)]) + (sbox[GETBYTE(tmp, 1)]) + (sbox[GETBYTE(tmp, 0)]); + + CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf())); + *(word64 *)(void *)outBlock ^= m_roundKeys[m_rounds]; } NAMESPACE_END diff --git a/strciphr.h b/strciphr.h index a45a4c3e7..29c087ea2 100644 --- a/strciphr.h +++ b/strciphr.h @@ -62,7 +62,7 @@ class CRYPTOPP_NO_VTABLE AbstractPolicyHolder : public BASE //! \brief Stream cipher policy object //! \tparam POLICY class implementing AbstractPolicyHolder //! \tparam BASE class or type to use as a base class -template +template class ConcretePolicyHolder : public BASE, protected POLICY { public: diff --git a/tiger.cpp b/tiger.cpp index d7261f925..5f1e2ca05 100644 --- a/tiger.cpp +++ b/tiger.cpp @@ -50,12 +50,7 @@ void Tiger::Transform (word64 *digest, const word64 *X) INTEL_NOPREFIX AS_PUSH_IF86(bx) #else - #if _MSC_VER < 1300 - const word64 *t = table; - AS2( mov edx, t) - #else AS2( lea edx, [table]) - #endif AS2( mov eax, digest) AS2( mov esi, X) #endif diff --git a/validat1.cpp b/validat1.cpp index f673a949b..a33e7404c 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -1714,17 +1714,14 @@ bool TestRDSEED() } #endif -// VC50 workaround -typedef auto_ptr apbt; - class CipherFactory { public: virtual unsigned int BlockSize() const =0; virtual unsigned int KeyLength() const =0; - virtual apbt NewEncryption(const byte *keyStr) const =0; - virtual apbt NewDecryption(const byte *keyStr) const =0; + virtual BlockTransformation* NewEncryption(const byte *keyStr) const =0; + virtual BlockTransformation* NewDecryption(const byte *keyStr) const =0; }; template class FixedRoundsCipherFactory : public CipherFactory @@ -1734,10 +1731,10 @@ template class FixedRoundsCipherFactory : public CipherFactor unsigned int BlockSize() const {return E::BLOCKSIZE;} unsigned int KeyLength() const {return m_keylen;} - apbt NewEncryption(const byte *keyStr) const - {return apbt(new E(keyStr, m_keylen));} - apbt NewDecryption(const byte *keyStr) const - {return apbt(new D(keyStr, m_keylen));} + BlockTransformation* NewEncryption(const byte *keyStr) const + {return new E(keyStr, m_keylen);} + BlockTransformation* NewDecryption(const byte *keyStr) const + {return new D(keyStr, m_keylen);} unsigned int m_keylen; }; @@ -1750,10 +1747,10 @@ template class VariableRoundsCipherFactory : public CipherFac unsigned int BlockSize() const {return E::BLOCKSIZE;} unsigned int KeyLength() const {return m_keylen;} - apbt NewEncryption(const byte *keyStr) const - {return apbt(new E(keyStr, m_keylen, m_rounds));} - apbt NewDecryption(const byte *keyStr) const - {return apbt(new D(keyStr, m_keylen, m_rounds));} + BlockTransformation* NewEncryption(const byte *keyStr) const + {return new E(keyStr, m_keylen, m_rounds);} + BlockTransformation* NewDecryption(const byte *keyStr) const + {return new D(keyStr, m_keylen, m_rounds);} unsigned int m_keylen, m_rounds; }; @@ -1771,11 +1768,11 @@ bool BlockTransformationTest(const CipherFactory &cg, BufferedTransformation &va valdata.Get(plain, cg.BlockSize()); valdata.Get(cipher, cg.BlockSize()); - apbt transE = cg.NewEncryption(key); + member_ptr transE(cg.NewEncryption(key)); transE->ProcessBlock(plain, out); fail = memcmp(out, cipher, cg.BlockSize()) != 0; - apbt transD = cg.NewDecryption(key); + member_ptr transD(cg.NewDecryption(key)); transD->ProcessBlock(out, outplain); fail=fail || memcmp(outplain, plain, cg.BlockSize()); @@ -2239,11 +2236,11 @@ bool ValidateRC2() valdata.Get(plain, RC2Encryption::BLOCKSIZE); valdata.Get(cipher, RC2Encryption::BLOCKSIZE); - apbt transE(new RC2Encryption(key, keyLen, effectiveLen)); + member_ptr transE(new RC2Encryption(key, keyLen, effectiveLen)); transE->ProcessBlock(plain, out); fail = memcmp(out, cipher, RC2Encryption::BLOCKSIZE) != 0; - apbt transD(new RC2Decryption(key, keyLen, effectiveLen)); + member_ptr transD(new RC2Decryption(key, keyLen, effectiveLen)); transD->ProcessBlock(out, outplain); fail=fail || memcmp(outplain, plain, RC2Encryption::BLOCKSIZE); @@ -2386,7 +2383,6 @@ bool ValidateARC4() 0x9e,0x27,0x55,0xab,0x18,0x1a,0xb7,0xe9,0x40,0xb0, 0xc0}; - // VC60 workaround: auto_ptr lacks reset() member_ptr arc4; bool pass=true, fail; unsigned int i; diff --git a/vmac.cpp b/vmac.cpp index d482cc7c6..c50f99581 100644 --- a/vmac.cpp +++ b/vmac.cpp @@ -196,7 +196,7 @@ VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, AS2( mov %1, %%ebx) INTEL_NOPREFIX #else - #if _MSC_VER < 1300 || defined(__INTEL_COMPILER) + #if defined(__INTEL_COMPILER) char isFirstBlock = m_isFirstBlock; AS2( mov ebx, [L1KeyLength]) AS2( mov dl, [isFirstBlock]) @@ -540,9 +540,7 @@ VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, } #endif -#if !(defined(_MSC_VER) && _MSC_VER < 1300) template -#endif void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemainingInWord64) { CRYPTOPP_ASSERT(IsAlignedOn(m_polyState(),GetAlignmentOf())); @@ -556,9 +554,6 @@ void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemaining AccumulateNH(nhB, d0+nhK[i+2*j+2], d1+nhK[i+2*j+3]);\ } -#if (defined(_MSC_VER) && _MSC_VER < 1300) - bool T_128BitTag = m_is128; -#endif size_t L1KeyLengthInWord64 = m_L1KeyLength / 8; size_t innerLoopEnd = L1KeyLengthInWord64; const word64 *nhK = m_nhKey(); @@ -816,14 +811,10 @@ inline void VMAC_Base::VHASH_Update(const word64 *data, size_t blocksRemainingIn else #endif { -#if defined(_MSC_VER) && _MSC_VER < 1300 - VHASH_Update_Template(data, blocksRemainingInWord64); -#else if (m_is128) VHASH_Update_Template(data, blocksRemainingInWord64); else VHASH_Update_Template(data, blocksRemainingInWord64); -#endif } } diff --git a/vmac.h b/vmac.h index e2d15d110..0ce060123 100644 --- a/vmac.h +++ b/vmac.h @@ -48,10 +48,8 @@ class VMAC_Base : public IteratedHashBase word64* DataBuf() {return (word64 *)(void*)m_data();} void VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, int tagPart); -#if !(defined(_MSC_VER) && _MSC_VER < 1300) // can't use function template here with VC6 template -#endif - void VHASH_Update_Template(const word64 *data, size_t blockRemainingInWord128); + void VHASH_Update_Template(const word64 *data, size_t blockRemainingInWord128); void VHASH_Update(const word64 *data, size_t blocksRemainingInWord128); CRYPTOPP_BLOCK_1(polyState, word64, 4*(m_is128+1)) diff --git a/whrlpool.cpp b/whrlpool.cpp index dc7c7c94b..1278ad8a8 100644 --- a/whrlpool.cpp +++ b/whrlpool.cpp @@ -422,9 +422,6 @@ void Whirlpool::Transform(word64 *digest, const word64 *block) AS_PUSH_IF86( bx) AS2( mov AS_REG_6, WORD_REG(ax)) #else - #if _MSC_VER < 1300 - AS_PUSH_IF86( bx) - #endif AS2( lea AS_REG_6, [Whirlpool_C]) AS2( mov WORD_REG(cx), digest) AS2( mov WORD_REG(dx), block) @@ -586,7 +583,7 @@ void Whirlpool::Transform(word64 *digest, const word64 *block) AS_POP_IF86( sp) AS1( emms) -#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER < 1300) +#if defined(__GNUC__) AS_POP_IF86( bx) #endif #ifdef __GNUC__