9 NAMESPACE_BEGIN(CryptoPP)
11 void Serpent_KeySchedule(word32 *k,
unsigned int rounds, const byte *userKey,
size_t keylen)
14 GetUserKey(LITTLE_ENDIAN_ORDER, k0.begin(), 8, userKey, keylen);
16 k0[keylen/4] |= word32(1) << ((keylen%4)*8);
20 for (i = 0; i < 8; ++i)
21 k[i] = k0[i] = t = rotlFixed(k0[i] ^ k0[(i+3)%8] ^ k0[(i+5)%8] ^ t ^ 0x9e3779b9 ^ i, 11);
22 for (i = 8; i < 4*(rounds+1); ++i)
23 k[i] = t = rotlFixed(k[i-8] ^ k[i-5] ^ k[i-3] ^ t ^ 0x9e3779b9 ^ i, 11);
27 for (i=0; i<rounds/8; i++)
29 afterS2(LK); afterS2(S3); afterS3(SK);
30 afterS1(LK); afterS1(S2); afterS2(SK);
31 afterS0(LK); afterS0(S1); afterS1(SK);
32 beforeS0(LK); beforeS0(S0); afterS0(SK);
34 afterS6(LK); afterS6(S7); afterS7(SK);
35 afterS5(LK); afterS5(S6); afterS6(SK);
36 afterS4(LK); afterS4(S5); afterS5(SK);
37 afterS3(LK); afterS3(S4); afterS4(SK);
39 afterS2(LK); afterS2(S3); afterS3(SK);
42 void Serpent::Base::UncheckedSetKey(
const byte *userKey,
unsigned int keylen,
const NameValuePairs &)
44 AssertValidKeyLength(keylen);
45 Serpent_KeySchedule(m_key, 32, userKey, keylen);
50 void Serpent::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const
54 Block::Get(inBlock)(a)(b)(c)(d);
56 const word32 *k = m_key;
61 beforeS0(KX); beforeS0(S0); afterS0(LT);
62 afterS0(KX); afterS0(S1); afterS1(LT);
63 afterS1(KX); afterS1(S2); afterS2(LT);
64 afterS2(KX); afterS2(S3); afterS3(LT);
65 afterS3(KX); afterS3(S4); afterS4(LT);
66 afterS4(KX); afterS4(S5); afterS5(LT);
67 afterS5(KX); afterS5(S6); afterS6(LT);
68 afterS6(KX); afterS6(S7);
89 void Serpent::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const
93 Block::Get(inBlock)(a)(b)(c)(d);
95 const word32 *k = m_key + 96;
109 beforeI7(I7); afterI7(KX);
110 afterI7(ILT); afterI7(I6); afterI6(KX);
111 afterI6(ILT); afterI6(I5); afterI5(KX);
112 afterI5(ILT); afterI5(I4); afterI4(KX);
113 afterI4(ILT); afterI4(I3); afterI3(KX);
114 afterI3(ILT); afterI3(I2); afterI2(KX);
115 afterI2(ILT); afterI2(I1); afterI1(KX);
116 afterI1(ILT); afterI1(I0); afterI0(KX);
interface for retrieving values given their names