From c3bad1afc1564f3bfac8434d45d6694811139333 Mon Sep 17 00:00:00 2001 From: weidai Date: Sun, 10 Dec 2006 02:12:23 +0000 Subject: 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 --- rc2.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'rc2.cpp') diff --git a/rc2.cpp b/rc2.cpp index d15ce3d..48df2ef 100644 --- a/rc2.cpp +++ b/rc2.cpp @@ -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 Block; void RC2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const -- cgit v1.2.1