summaryrefslogtreecommitdiff
path: root/safer.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-10 02:12:23 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-10 02:12:23 +0000
commitc3bad1afc1564f3bfac8434d45d6694811139333 (patch)
treeebfbbcf4dffdf4914b9ce879d3d2c93d3615f7ab /safer.cpp
parente553818e00684e8905ede16e53aa490c153b7e7a (diff)
downloadcryptopp-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 'safer.cpp')
-rw-r--r--safer.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/safer.cpp b/safer.cpp
index ef3f90a..d46ca64 100644
--- a/safer.cpp
+++ b/safer.cpp
@@ -3,6 +3,7 @@
#include "pch.h"
#include "safer.h"
#include "misc.h"
+#include "argnames.h"
NAMESPACE_BEGIN(CryptoPP)
@@ -50,8 +51,11 @@ const byte SAFER::Base::log_tab[256] =
static const unsigned int BLOCKSIZE = 8;
static const unsigned int MAX_ROUNDS = 13;
-void SAFER::Base::UncheckedSetKey(CipherDir dir, const byte *userkey_1, unsigned int length, unsigned nof_rounds)
+void SAFER::Base::UncheckedSetKey(const byte *userkey_1, unsigned int length, const NameValuePairs &params)
{
+ bool strengthened = Strengthened();
+ unsigned int nof_rounds = params.GetIntValueWithDefault(Name::Rounds(), length == 8 ? (strengthened ? 8 : 6) : 10);
+
const byte *userkey_2 = length == 8 ? userkey_1 : userkey_1 + 8;
keySchedule.New(1 + BLOCKSIZE * (1 + 2 * nof_rounds));
@@ -69,6 +73,7 @@ void SAFER::Base::UncheckedSetKey(CipherDir dir, const byte *userkey_1, unsigned
ka[BLOCKSIZE] ^= ka[j] = rotlFixed(userkey_1[j], 5U);
kb[BLOCKSIZE] ^= kb[j] = *key++ = userkey_2[j];
}
+
for (i = 1; i <= nof_rounds; i++)
{
for (j = 0; j < BLOCKSIZE + 1; j++)