summaryrefslogtreecommitdiff
path: root/rc2.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2006-12-10 02:12:23 +0000
committerweidai <weidai11@users.noreply.github.com>2006-12-10 02:12:23 +0000
commitf05ea58bb369988a61438411539ea955e0adf8c2 (patch)
treeebfbbcf4dffdf4914b9ce879d3d2c93d3615f7ab /rc2.h
parent28c392e08234698cbe0e5fc3ffb3cfa5af1bc461 (diff)
downloadcryptopp-git-f05ea58bb369988a61438411539ea955e0adf8c2.tar.gz
port to GCC 4, reorganize implementations of SetKey
Diffstat (limited to 'rc2.h')
-rw-r--r--rc2.h24
1 files changed, 10 insertions, 14 deletions
diff --git a/rc2.h b/rc2.h
index 4e86ec48..8a619ab1 100644
--- a/rc2.h
+++ b/rc2.h
@@ -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 &params);
protected:
- template <class T>
- static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, size_t length, const NameValuePairs &param)
- {
- 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));}
};
};