diff options
author | weidai <weidai11@users.noreply.github.com> | 2006-12-10 02:12:23 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2006-12-10 02:12:23 +0000 |
commit | f05ea58bb369988a61438411539ea955e0adf8c2 (patch) | |
tree | ebfbbcf4dffdf4914b9ce879d3d2c93d3615f7ab /rc2.cpp | |
parent | 28c392e08234698cbe0e5fc3ffb3cfa5af1bc461 (diff) | |
download | cryptopp-git-f05ea58bb369988a61438411539ea955e0adf8c2.tar.gz |
port to GCC 4, reorganize implementations of SetKey
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 |