summaryrefslogtreecommitdiff
path: root/rc2.cpp
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.cpp
parent28c392e08234698cbe0e5fc3ffb3cfa5af1bc461 (diff)
downloadcryptopp-git-f05ea58bb369988a61438411539ea955e0adf8c2.tar.gz
port to GCC 4, reorganize implementations of SetKey
Diffstat (limited to 'rc2.cpp')
-rw-r--r--rc2.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/rc2.cpp b/rc2.cpp
index d15ce3d1..48df2ef4 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 &params)
{
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