From 085c5b2d0b70a2ff3d9ccf8616a7bdf4abbc957f Mon Sep 17 00:00:00 2001 From: weidai Date: Thu, 14 Dec 2006 11:41:39 +0000 Subject: port to Borland C++Builder 2006 git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@260 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- seckey.h | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'seckey.h') diff --git a/seckey.h b/seckey.h index b5e8824..6fe56b8 100644 --- a/seckey.h +++ b/seckey.h @@ -21,7 +21,7 @@ template class FixedBlockSize { public: - enum {BLOCKSIZE = N}; + CRYPTOPP_CONSTANT(BLOCKSIZE = N) }; // ************** rounds *************** @@ -31,7 +31,7 @@ template class FixedRounds { public: - enum {ROUNDS = R}; + CRYPTOPP_CONSTANT(ROUNDS = R) }; //! to be inherited by ciphers with variable number of rounds @@ -39,7 +39,9 @@ template // use INT_ class VariableRounds { public: - enum {DEFAULT_ROUNDS = D, MIN_ROUNDS = N, MAX_ROUNDS = M}; + CRYPTOPP_CONSTANT(DEFAULT_ROUNDS = D) + CRYPTOPP_CONSTANT(MIN_ROUNDS = N) + CRYPTOPP_CONSTANT(MAX_ROUNDS = M) static unsigned int StaticGetDefaultRounds(size_t keylength) {return DEFAULT_ROUNDS;} protected: @@ -65,17 +67,21 @@ protected: // ************** key length *************** //! to be inherited by keyed algorithms with fixed key length -template +template class FixedKeyLength { public: - enum {KEYLENGTH=N, MIN_KEYLENGTH=N, MAX_KEYLENGTH=N, DEFAULT_KEYLENGTH=N}; - enum {IV_REQUIREMENT = IV_REQ}; + CRYPTOPP_CONSTANT(KEYLENGTH=N) + CRYPTOPP_CONSTANT(MIN_KEYLENGTH=N) + CRYPTOPP_CONSTANT(MAX_KEYLENGTH=N) + CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=N) + CRYPTOPP_CONSTANT(IV_REQUIREMENT = IV_REQ) + CRYPTOPP_CONSTANT(IV_LENGTH = IV_L) static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t) {return KEYLENGTH;} }; /// support query of variable key length, template parameters are default, min, max, multiple (default multiple 1) -template +template class VariableKeyLength { // make these private to avoid Doxygen documenting them in all derived classes @@ -83,11 +89,17 @@ class VariableKeyLength CRYPTOPP_COMPILE_ASSERT(N % Q == 0); CRYPTOPP_COMPILE_ASSERT(M % Q == 0); CRYPTOPP_COMPILE_ASSERT(N < M); - CRYPTOPP_COMPILE_ASSERT(D >= N && M >= D); + CRYPTOPP_COMPILE_ASSERT(D >= N); + CRYPTOPP_COMPILE_ASSERT(M >= D); public: - enum {MIN_KEYLENGTH=N, MAX_KEYLENGTH=M, DEFAULT_KEYLENGTH=D, KEYLENGTH_MULTIPLE=Q}; - enum {IV_REQUIREMENT = IV_REQ}; + CRYPTOPP_CONSTANT(MIN_KEYLENGTH=N) + CRYPTOPP_CONSTANT(MAX_KEYLENGTH=M) + CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=D) + CRYPTOPP_CONSTANT(KEYLENGTH_MULTIPLE=Q) + CRYPTOPP_CONSTANT(IV_REQUIREMENT=IV_REQ) + CRYPTOPP_CONSTANT(IV_LENGTH=IV_L) + static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t n) { if (n < (size_t)MIN_KEYLENGTH) @@ -107,13 +119,16 @@ template class SameKeyLengthAs { public: - enum {MIN_KEYLENGTH=T::MIN_KEYLENGTH, MAX_KEYLENGTH=T::MAX_KEYLENGTH, DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH}; - enum {IV_REQUIREMENT = T::IV_REQUIREMENT}; + CRYPTOPP_CONSTANT(MIN_KEYLENGTH=T::MIN_KEYLENGTH) + CRYPTOPP_CONSTANT(MAX_KEYLENGTH=T::MAX_KEYLENGTH) + CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH) + CRYPTOPP_CONSTANT(IV_REQUIREMENT = T::IV_REQUIREMENT) + CRYPTOPP_CONSTANT(IV_LENGTH = T::IV_LENGTH) static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength) {return T::StaticGetValidKeyLength(keylength);} }; -// ************** implementation helper for SimpledKeyed *************** +// ************** implementation helper for SimpleKeyed *************** //! _ template @@ -125,6 +140,7 @@ public: size_t DefaultKeyLength() const {return INFO::DEFAULT_KEYLENGTH;} size_t GetValidKeyLength(size_t n) const {return INFO::StaticGetValidKeyLength(n);} typename BASE::IV_Requirement IVRequirement() const {return (typename BASE::IV_Requirement)INFO::IV_REQUIREMENT;} + unsigned int IVSize() const {return INFO::IV_LENGTH;} }; template -- cgit v1.2.1