diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2006-12-10 02:12:23 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2006-12-10 02:12:23 +0000 |
commit | c3bad1afc1564f3bfac8434d45d6694811139333 (patch) | |
tree | ebfbbcf4dffdf4914b9ce879d3d2c93d3615f7ab /rc2.h | |
parent | e553818e00684e8905ede16e53aa490c153b7e7a (diff) | |
download | cryptopp-c3bad1afc1564f3bfac8434d45d6694811139333.tar.gz |
port to GCC 4, reorganize implementations of SetKey
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@248 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'rc2.h')
-rw-r--r-- | rc2.h | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -6,6 +6,7 @@ #include "seckey.h" #include "secblock.h" +#include "algparam.h" NAMESPACE_BEGIN(CryptoPP) @@ -22,18 +23,9 @@ class RC2 : public RC2_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC2_Info> { public: - void UncheckedSetKey(CipherDir direction, const byte *key, unsigned int length, unsigned int effectiveKeyLength); - void SetKeyWithEffectiveKeyLength(const byte *key, size_t length, unsigned int effectiveKeyLength); + void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: - template <class T> - static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, size_t length, const NameValuePairs ¶m) - { - obj->ThrowIfInvalidKeyLength(length); - int effectiveKeyLength = param.GetIntValueWithDefault("EffectiveKeyLength", DEFAULT_EFFECTIVE_KEYLENGTH); - obj->SetKeyWithEffectiveKeyLength(key, length, effectiveKeyLength); - } - FixedSizeSecBlock<word16, 64> K; // expanded key table }; @@ -54,16 +46,20 @@ public: { public: Encryption() {} - Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH, unsigned int effectiveLen=1024) - {SetKeyWithEffectiveKeyLength(key, keyLen, effectiveLen);} + Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH) + {SetKey(key, keyLen);} + Encryption(const byte *key, size_t keyLen, int effectiveKeyLen) + {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));} }; class Decryption : public BlockCipherFinal<DECRYPTION, Dec> { public: Decryption() {} - Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH, unsigned int effectiveLen=1024) - {SetKeyWithEffectiveKeyLength(key, keyLen, effectiveLen);} + Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH) + {SetKey(key, keyLen);} + Decryption(const byte *key, size_t keyLen, int effectiveKeyLen) + {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));} }; }; |