11NAMESPACE_BEGIN(CryptoPP)
13void Serpent_KeySchedule(
word32 *k,
unsigned int rounds,
const byte *userKey,
size_t keylen)
16 GetUserKey(LITTLE_ENDIAN_ORDER, k0.begin(), 8, userKey, keylen);
18 k0[keylen/4] |=
word32(1) << ((keylen%4)*8);
22 for (i = 0; i < 8; ++i)
23 k[i] = k0[i] = t = rotlConstant<11>(k0[i] ^ k0[(i + 3) % 8] ^ k0[(i + 5) % 8] ^ t ^ 0x9e3779b9 ^ i);
24 for (i = 8; i < 4*(rounds+1); ++i)
25 k[i] = t = rotlConstant<11>(k[i-8] ^ k[i-5] ^ k[i-3] ^ t ^ 0x9e3779b9 ^ i);
29 for (i=0; i<rounds/8; i++)
31 afterS2(LK); afterS2(S3); afterS3(SK);
32 afterS1(LK); afterS1(S2); afterS2(SK);
33 afterS0(LK); afterS0(S1); afterS1(SK);
34 beforeS0(LK); beforeS0(S0); afterS0(SK);
36 afterS6(LK); afterS6(S7); afterS7(SK);
37 afterS5(LK); afterS5(S6); afterS6(SK);
38 afterS4(LK); afterS4(S5); afterS5(SK);
39 afterS3(LK); afterS3(S4); afterS4(SK);
41 afterS2(LK); afterS2(S3); afterS3(SK);
44void Serpent::Base::UncheckedSetKey(
const byte *userKey,
unsigned int keylen,
const NameValuePairs &)
46 AssertValidKeyLength(keylen);
47 Serpent_KeySchedule(m_key, 32, userKey, keylen);
52void Serpent::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
56 Block::Get(inBlock)(a)(b)(c)(d);
63 beforeS0(KX); beforeS0(S0); afterS0(LT);
64 afterS0(KX); afterS0(S1); afterS1(LT);
65 afterS1(KX); afterS1(S2); afterS2(LT);
66 afterS2(KX); afterS2(S3); afterS3(LT);
67 afterS3(KX); afterS3(S4); afterS4(LT);
68 afterS4(KX); afterS4(S5); afterS5(LT);
69 afterS5(KX); afterS5(S6); afterS6(LT);
70 afterS6(KX); afterS6(S7);
91void Serpent::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
95 Block::Get(inBlock)(a)(b)(c)(d);
97 const word32 *k = m_key + 96;
111 beforeI7(I7); afterI7(KX);
112 afterI7(ILT); afterI7(I6); afterI6(KX);
113 afterI6(ILT); afterI6(I5); afterI5(KX);
114 afterI5(ILT); afterI5(I4); afterI4(KX);
115 afterI4(ILT); afterI4(I3); afterI3(KX);
116 afterI3(ILT); afterI3(I2); afterI2(KX);
117 afterI2(ILT); afterI2(I1); afterI1(KX);
118 afterI1(ILT); afterI1(I0); afterI0(KX);
Fixed size stack-based SecBlock.
Interface for retrieving values given their names.
Access a block of memory.
unsigned int word32
32-bit unsigned datatype
Utility functions for the Crypto++ library.
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.
Classes and functions for secure memory allocations.
Classes for the Serpent block cipher.
Access a block of memory.