14 constexpr
static inline uint32_t rotl32(uint32_t v,
int c) {
return (v << c) | (v >> (32 - c)); }
16 #define QUARTERROUND(a,b,c,d) \ 17 a += b; d = rotl32(d ^ a, 16); \ 18 c += d; b = rotl32(b ^ c, 12); \ 19 a += b; d = rotl32(d ^ a, 8); \ 20 c += d; b = rotl32(b ^ c, 7); 22 static const unsigned char sigma[] =
"expand 32-byte k";
23 static const unsigned char tau[] =
"expand 16-byte k";
27 const unsigned char *constants;
29 input[4] = ReadLE32(k + 0);
30 input[5] = ReadLE32(k + 4);
31 input[6] = ReadLE32(k + 8);
32 input[7] = ReadLE32(k + 12);
39 input[8] = ReadLE32(k + 0);
40 input[9] = ReadLE32(k + 4);
41 input[10] = ReadLE32(k + 8);
42 input[11] = ReadLE32(k + 12);
43 input[0] = ReadLE32(constants + 0);
44 input[1] = ReadLE32(constants + 4);
45 input[2] = ReadLE32(constants + 8);
46 input[3] = ReadLE32(constants + 12);
72 input[13] = pos >> 32;
77 uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
78 uint32_t j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
79 unsigned char *ctarget =
nullptr;
80 unsigned char tmp[64];
123 for (i = 20;i > 0;i -= 2) {
153 WriteLE32(c + 0, x0);
154 WriteLE32(c + 4, x1);
155 WriteLE32(c + 8, x2);
156 WriteLE32(c + 12, x3);
157 WriteLE32(c + 16, x4);
158 WriteLE32(c + 20, x5);
159 WriteLE32(c + 24, x6);
160 WriteLE32(c + 28, x7);
161 WriteLE32(c + 32, x8);
162 WriteLE32(c + 36, x9);
163 WriteLE32(c + 40, x10);
164 WriteLE32(c + 44, x11);
165 WriteLE32(c + 48, x12);
166 WriteLE32(c + 52, x13);
167 WriteLE32(c + 56, x14);
168 WriteLE32(c + 60, x15);
172 for (i = 0;i < bytes;++i) ctarget[i] = c[i];
void Output(unsigned char *output, size_t bytes)
#define QUARTERROUND(a, b, c, d)
void SetKey(const unsigned char *key, size_t keylen)