11void RC6::Base::UncheckedSetKey(
const byte *k,
unsigned int keylen,
const NameValuePairs ¶ms)
13 AssertValidKeyLength(keylen);
15 r = GetRoundsAndThrowIfInvalid(params,
this);
18 static const RC6_WORD MAGIC_P = 0xb7e15163L;
19 static const RC6_WORD MAGIC_Q = 0x9e3779b9L;
20 static const int U=
sizeof(RC6_WORD);
22 const unsigned int c =
STDMAX((keylen+U-1)/U, 1U);
28 for (
unsigned j=1; j<sTable.
size();j++)
29 sTable[j] = sTable[j-1] + MAGIC_Q;
32 const unsigned n = 3*
STDMAX((
unsigned int)sTable.
size(), c);
34 for (
unsigned h=0; h < n; h++)
36 a = sTable[h % sTable.
size()] = rotlConstant<3>((sTable[h % sTable.
size()] + a + b));
37 b = l[h % c] =
rotlMod((l[h % c] + a + b), (a+b));
43void RC6::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
45 const RC6_WORD *sptr = sTable;
46 RC6_WORD a, b, c, d, t, u;
48 Block::Get(inBlock)(a)(b)(c)(d);
53 for(
unsigned i=0; i<r; i++)
55 t = rotlConstant<5>(b*(2*b+1));
56 u = rotlConstant<5>(d*(2*d+1));
59 t = a; a = b; b = c; c = d; d = t;
69void RC6::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
71 const RC6_WORD *sptr = sTable.end();
72 RC6_WORD a, b, c, d, t, u;
74 Block::Get(inBlock)(a)(b)(c)(d);
80 for (
unsigned i=0; i < r; i++)
83 t = a; a = d; d = c; c = b; b = t;
84 u = rotlConstant<5>(d*(2 * d + 1));
85 t = rotlConstant<5>(b*(2 * b + 1));
Interface for retrieving values given their names.
Access a block of memory.
Secure memory block with allocator and cleanup.
void New(size_type newSize)
Change size without preserving contents.
size_type size() const
Provides the count of elements in the SecBlock.
@ LITTLE_ENDIAN_ORDER
byte order is little-endian
Utility functions for the Crypto++ library.
const T & STDMAX(const T &a, const T &b)
Replacement function for std::max.
void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, size_t inlen)
Copy bytes in a buffer to an array of elements in big-endian order.
T rotlMod(T x, unsigned int y)
Performs a left rotate.
T rotrMod(T x, unsigned int y)
Performs a right rotate.
Crypto++ library namespace.
Classes for the RC6 block cipher.
Classes and functions for secure memory allocations.
Access a block of memory.