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.cpp | |
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.cpp')
-rw-r--r-- | rc2.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -3,13 +3,18 @@ #include "pch.h" #include "rc2.h" #include "misc.h" +#include "argnames.h" NAMESPACE_BEGIN(CryptoPP) -void RC2::Base::UncheckedSetKey(CipherDir direction, const byte *key, unsigned int keyLen, unsigned int effectiveLen) +void RC2::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const NameValuePairs ¶ms) { AssertValidKeyLength(keyLen); + int effectiveLen = params.GetIntValueWithDefault(Name::EffectiveKeyLength(), DEFAULT_EFFECTIVE_KEYLENGTH); + if (effectiveLen > MAX_EFFECTIVE_KEYLENGTH) + throw InvalidArgument("RC2: effective key length parameter exceeds maximum"); + static const unsigned char PITABLE[256] = { 217,120,249,196, 25,221,181,237, 40,233,253,121, 74,160,216,157, 198,126, 55,131, 43,118, 83,142, 98, 76,100,136, 68,139,251,162, @@ -46,13 +51,6 @@ void RC2::Base::UncheckedSetKey(CipherDir direction, const byte *key, unsigned i K[i] = L[2*i] + (L[2*i+1] << 8); } -void RC2::Base::SetKeyWithEffectiveKeyLength(const byte *key, size_t length, unsigned int effectiveKeyLength) -{ - if (effectiveKeyLength > MAX_EFFECTIVE_KEYLENGTH) - throw InvalidArgument("RC2: effective key length parameter exceeds maximum"); - UncheckedSetKey(ENCRYPTION, key, (unsigned int)length, effectiveKeyLength); -} - typedef BlockGetAndPut<word16, LittleEndian> Block; void RC2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const |