diff --git a/3way.cpp b/3way.cpp index c6784ee8..cd0d8a7b 100644 --- a/3way.cpp +++ b/3way.cpp @@ -15,11 +15,6 @@ void ThreeWay_TestInstantiations() } #endif -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused1 = ThreeWay::KEYLENGTH; -static const size_t s_unused2 = ThreeWayEncryption::KEYLENGTH; -static const size_t s_unused3 = ThreeWayDecryption::KEYLENGTH; - static const word32 START_E = 0x0b0b; // round constant of first encryption round static const word32 START_D = 0xb1b1; // round constant of first decryption round #ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 diff --git a/cast.h b/cast.h index 63f1e763..52ae53c9 100644 --- a/cast.h +++ b/cast.h @@ -11,6 +11,8 @@ NAMESPACE_BEGIN(CryptoPP) +//! \class CAST +//! \brief CAST block cipher base class CAST { protected: @@ -29,6 +31,8 @@ struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, //! \sa CAST-128 class CAST128 : public CAST128_Info, public BlockCipherDocumentation { + //! \class Base + //! \brief CAST128 block cipher default operation class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl { public: @@ -39,12 +43,16 @@ class CAST128 : public CAST128_Info, public BlockCipherDocumentation FixedSizeSecBlock K; }; + //! \class Enc + //! \brief CAST128 block cipher encryption operation class CRYPTOPP_NO_VTABLE Enc : public Base { public: void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; }; + //! \class Dec + //! \brief CAST128 block cipher decryption operation class CRYPTOPP_NO_VTABLE Dec : public Base { public: @@ -68,6 +76,8 @@ struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16 //! \sa CAST-256 class CAST256 : public CAST256_Info, public BlockCipherDocumentation { + //! \class Base + //! \brief CAST256 block cipher default operation class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl { public: diff --git a/config.h b/config.h index 332bcc43..a25d1430 100644 --- a/config.h +++ b/config.h @@ -544,8 +544,9 @@ NAMESPACE_END # define CRYPTOPP_NOINLINE #endif -// how to declare class constants -#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__) +// How to declare class constants +// Use enum for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 +#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__) || (defined(__APPLE__) && (__GNUC__ == 4) && (__GNUC_MINOR__ <= 2)) # define CRYPTOPP_CONSTANT(x) enum {x}; #else # define CRYPTOPP_CONSTANT(x) static const int x; diff --git a/config.recommend b/config.recommend index ff04befe..c9a1c9db 100644 --- a/config.recommend +++ b/config.recommend @@ -544,8 +544,9 @@ NAMESPACE_END # define CRYPTOPP_NOINLINE #endif -// how to declare class constants -#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__) +// How to declare class constants +// Use enum for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 +#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__) || (defined(__APPLE__) && (__GNUC__ == 4) && (__GNUC_MINOR__ <= 2)) # define CRYPTOPP_CONSTANT(x) enum {x}; #else # define CRYPTOPP_CONSTANT(x) static const int x; diff --git a/des.cpp b/des.cpp index c468403c..6e9a393a 100644 --- a/des.cpp +++ b/des.cpp @@ -20,12 +20,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused1 = DES::KEYLENGTH; -static const size_t s_unused2 = DES_EDE2::KEYLENGTH; -static const size_t s_unused3 = DES_EDE3::KEYLENGTH; -static const size_t s_unused4 = DES_XEX3::KEYLENGTH; - typedef BlockGetAndPut Block; // Richard Outerbridge's initial permutation algorithm diff --git a/gost.cpp b/gost.cpp index f60cf031..53de81a8 100644 --- a/gost.cpp +++ b/gost.cpp @@ -4,9 +4,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = GOST::KEYLENGTH; - // these are the S-boxes given in Applied Cryptography 2nd Ed., p. 333 const byte GOST::Base::sBox[8][16]={ {4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3}, diff --git a/idea.cpp b/idea.cpp index 96f946af..d0b8836f 100644 --- a/idea.cpp +++ b/idea.cpp @@ -7,9 +7,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = IDEA::KEYLENGTH; - static const int IDEA_KEYLEN=(6*IDEA::ROUNDS+4); // key schedule length in # of word16s #define low16(x) ((x)&0xffff) // compiler should be able to optimize this away if word is 16 bits diff --git a/modes.cpp b/modes.cpp index 23f6afb1..ed2b3224 100644 --- a/modes.cpp +++ b/modes.cpp @@ -7,9 +7,9 @@ #include "modes.h" #include "misc.h" -#ifndef NDEBUG +//#ifndef NDEBUG #include "des.h" -#endif +//#endif NAMESPACE_BEGIN(CryptoPP) diff --git a/modes.h b/modes.h index df773116..202210c7 100644 --- a/modes.h +++ b/modes.h @@ -16,8 +16,8 @@ NAMESPACE_BEGIN(CryptoPP) //! \class CipherModeDocumentation -//! \brief Classes for operating block cipher modes of operation -//! \details Each class derived from this one defines two types, Encryption and Decryption, +//! \brief Block cipher mode of operation information +//! \details Each class derived from this one defines two types, Encryption and Decryption, //! both of which implement the SymmetricCipher interface. //! For each mode there are two classes, one of which is a template class, //! and the other one has a name that ends in "_ExternalCipher". @@ -31,6 +31,8 @@ struct CipherModeDocumentation : public SymmetricCipherDocumentation { }; +//! \class CipherModeBase +//! \brief Block cipher mode of operation information class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CipherModeBase : public SymmetricCipher { public: @@ -70,7 +72,7 @@ protected: if (!(feedbackSize == 0 || feedbackSize == BlockSize())) throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode"); } - + // Thanks to Zireael, http://github.com/weidai11/cryptopp/pull/46 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual void ResizeBuffers(); @@ -85,6 +87,9 @@ protected: AlignedSecByteBlock m_register; }; +//! \class ModePolicyCommonTemplate +//! \brief Block cipher mode of operation common operations +//! \tparam POLICY_INTERFACE common operations template class CRYPTOPP_NO_VTABLE ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE { @@ -101,6 +106,8 @@ void ModePolicyCommonTemplate::CipherSetKey(const NameValuePai SetFeedbackSize(feedbackSize); } +//! \class CFB_ModePolicy +//! \brief CFB block cipher mode of operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CFB_ModePolicy : public ModePolicyCommonTemplate { public: @@ -129,6 +136,8 @@ inline void CopyOrZero(void *dest, const void *src, size_t s) memset(dest, 0, s); } +//! \class OFB_ModePolicy +//! \brief OFB block cipher mode of operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate { public: @@ -143,6 +152,8 @@ private: void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); }; +//! \class CTR_ModePolicy +//! \brief CTR block cipher mode of operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate { public: @@ -166,6 +177,8 @@ protected: AlignedSecByteBlock m_counterArray; }; +//! \class BlockOrientedCipherModeBase +//! \brief Block cipher mode of operation default implementation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public CipherModeBase { public: @@ -178,7 +191,7 @@ public: protected: bool RequireAlignedInput() const {return true;} - + // Thanks to Zireael, http://github.com/weidai11/cryptopp/pull/46 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 void ResizeBuffers(); @@ -193,6 +206,8 @@ protected: SecByteBlock m_buffer; }; +//! \class ECB_OneWay +//! \brief ECB block cipher mode of operation default implementation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase { public: @@ -204,6 +219,8 @@ public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECB";} }; +//! \class CBC_ModeBase +//! \brief CBC block cipher mode of operation default implementation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_ModeBase : public BlockOrientedCipherModeBase { public: @@ -213,12 +230,16 @@ public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC";} }; +//! \class CBC_Encryption +//! \brief CBC block cipher mode of operation encryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase { public: void ProcessData(byte *outString, const byte *inString, size_t length); }; +//! \class CBC_CTS_Encryption +//! \brief CBC-CTS block cipher mode of operation encryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption { public: @@ -237,13 +258,15 @@ protected: byte *m_stolenIV; }; +//! \class CBC_Decryption +//! \brief CBC block cipher mode of operation decryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Decryption : public CBC_ModeBase { public: void ProcessData(byte *outString, const byte *inString, size_t length); - + protected: - + // Thanks to Zireael, http://github.com/weidai11/cryptopp/pull/46 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 void ResizeBuffers(); @@ -258,6 +281,8 @@ protected: AlignedSecByteBlock m_temp; }; +//! \class CBC_CTS_Decryption +//! \brief CBC-CTS block cipher mode of operation decryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Decryption : public CBC_Decryption { public: @@ -265,7 +290,8 @@ public: void ProcessLastBlock(byte *outString, const byte *inString, size_t length); }; -//! _ +//! \class CipherModeFinalTemplate_CipherHolder +//! \brief Block cipher mode of operation aggregate template class CipherModeFinalTemplate_CipherHolder : protected ObjectHolder, public AlgorithmImpl > { @@ -296,8 +322,8 @@ public: }; //! \class CipherModeFinalTemplate_ExternalCipher -//! \tparam BASE CipherModeFinalTemplate_CipherHolder class -//! \brief OFB block cipher mode of operation. +//! \tparam BASE CipherModeFinalTemplate_CipherHolder base class +//! \details template class CipherModeFinalTemplate_ExternalCipher : public BASE { diff --git a/panama.cpp b/panama.cpp index 2c76c934..f10edbdc 100644 --- a/panama.cpp +++ b/panama.cpp @@ -17,9 +17,6 @@ NAMESPACE_BEGIN(CryptoPP) # pragma warning(disable: 4731) #endif -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = PanamaCipher<>::KEYLENGTH; - template void Panama::Reset() { diff --git a/safer.h b/safer.h index 3828d8e3..a9150284 100644 --- a/safer.h +++ b/safer.h @@ -1,7 +1,7 @@ // safer.h - written and placed in the public domain by Wei Dai //! \file safer.h -//! \brief Classes for the SAFER block cipher +//! \brief Classes for the SAFER and SAFER-K block ciphers #ifndef CRYPTOPP_SAFER_H #define CRYPTOPP_SAFER_H @@ -12,10 +12,12 @@ NAMESPACE_BEGIN(CryptoPP) //! \class SAFER -//! \brief SAFER base class +//! \brief SAFER block cipher class SAFER { public: + //! \class Base + //! \brief SAFER block cipher default operation class CRYPTOPP_NO_VTABLE Base : public BlockCipher { public: @@ -30,12 +32,16 @@ public: static const byte log_tab[256]; }; + //! \class Enc + //! \brief SAFER block cipher encryption operation class CRYPTOPP_NO_VTABLE Enc : public Base { public: void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; }; + //! \class Dec + //! \brief SAFER block cipher decryption operation class CRYPTOPP_NO_VTABLE Dec : public Base { public: diff --git a/salsa.cpp b/salsa.cpp index 603ae521..ddf779ae 100644 --- a/salsa.cpp +++ b/salsa.cpp @@ -40,10 +40,6 @@ void Salsa20_TestInstantiations() } #endif -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -// static const size_t s_unused1 = Salsa20::KEYLENGTH; -static const size_t s_unused2 = XSalsa20::KEYLENGTH; - void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) { m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); diff --git a/seal.cpp b/seal.cpp index 641a3207..9babbfa1 100644 --- a/seal.cpp +++ b/seal.cpp @@ -17,9 +17,6 @@ void SEAL_TestInstantiations() } #endif -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = SEAL<>::KEYLENGTH; - struct SEAL_Gamma { SEAL_Gamma(const byte *key) diff --git a/seed.cpp b/seed.cpp index 58905fe3..f6a9690f 100644 --- a/seed.cpp +++ b/seed.cpp @@ -6,9 +6,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = SEED::KEYLENGTH; - static const word32 s_kc[16] = { 0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc, 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf, 0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1, 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b}; diff --git a/shark.cpp b/shark.cpp index 503d00b6..99d63d21 100644 --- a/shark.cpp +++ b/shark.cpp @@ -12,9 +12,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = SHARK::KEYLENGTH; - static word64 SHARKTransform(word64 a) { static const byte iG[8][8] = { diff --git a/skipjack.cpp b/skipjack.cpp index c52baf49..d3f59ff7 100644 --- a/skipjack.cpp +++ b/skipjack.cpp @@ -17,9 +17,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = SKIPJACK::KEYLENGTH; - /** * The F-table byte permutation (see description of the G-box permutation) */ diff --git a/skipjack.h b/skipjack.h index c2142ef5..3378931b 100644 --- a/skipjack.h +++ b/skipjack.h @@ -19,7 +19,7 @@ struct SKIPJACK_Info : public FixedBlockSize<8>, public FixedKeyLength<10> }; //! \class SKIPJACK -//! \brief SKIPJACK block cipher information +//! \brief SKIPJACK block cipher //! \sa SKIPJACK class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation { diff --git a/square.cpp b/square.cpp index b868200a..b0912900 100644 --- a/square.cpp +++ b/square.cpp @@ -18,9 +18,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = Square::KEYLENGTH; - // apply theta to a roundkey static void SquareTransform (word32 in[4], word32 out[4]) { diff --git a/tea.cpp b/tea.cpp index f1a82e8d..dba159f6 100644 --- a/tea.cpp +++ b/tea.cpp @@ -6,9 +6,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = TEA::KEYLENGTH; - static const word32 DELTA = 0x9e3779b9; typedef BlockGetAndPut Block; diff --git a/ttmac.cpp b/ttmac.cpp index b7513e8b..98954370 100644 --- a/ttmac.cpp +++ b/ttmac.cpp @@ -6,9 +6,6 @@ NAMESPACE_BEGIN(CryptoPP) -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = TTMAC::KEYLENGTH; - void TTMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &) { AssertValidKeyLength(keylength); diff --git a/wake.cpp b/wake.cpp index 4725947f..888b2e09 100644 --- a/wake.cpp +++ b/wake.cpp @@ -15,9 +15,6 @@ void WAKE_TestInstantiations() } #endif -// Hack for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 -static const size_t s_unused = WAKE_OFB<>::KEYLENGTH; - inline word32 WAKE_Base::M(word32 x, word32 y) { word32 w = x+y;