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 /safer.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 'safer.cpp')
-rw-r--r-- | safer.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 ¶ms) { + 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++) |