13 constexpr
static inline uint32_t
rotl32(uint32_t v,
int c) {
return (v << c) | (v >> (32 - c)); }
15 #define QUARTERROUND(a,b,c,d) \ 16 a += b; d = rotl32(d ^ a, 16); \ 17 c += d; b = rotl32(b ^ c, 12); \ 18 a += b; d = rotl32(d ^ a, 8); \ 19 c += d; b = rotl32(b ^ c, 7); 21 static const unsigned char sigma[] =
"expand 32-byte k";
22 static const unsigned char tau[] =
"expand 16-byte k";
26 const unsigned char *constants;
71 input[13] = pos >> 32;
76 uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
77 uint32_t j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
78 unsigned char *ctarget =
nullptr;
79 unsigned char tmp[64];
122 for (i = 20;i > 0;i -= 2) {
171 for (i = 0;i < bytes;++i) ctarget[i] = c[i];
184 uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
185 uint32_t j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
186 unsigned char *ctarget =
nullptr;
187 unsigned char tmp[64];
213 for (i = 0;i < bytes;++i) tmp[i] = m[i];
234 for (i = 20;i > 0;i -= 2) {
300 for (i = 0;i < bytes;++i) ctarget[i] = c[i];
static const unsigned char sigma[]
void Crypt(const unsigned char *input, unsigned char *output, size_t bytes)
enciphers the message <input> of length <bytes> and write the enciphered representation into <output>...
static void WriteLE32(unsigned char *ptr, uint32_t x)
static uint32_t ReadLE32(const unsigned char *ptr)
#define QUARTERROUND(a, b, c, d)
static constexpr uint32_t rotl32(uint32_t v, int c)
void Keystream(unsigned char *c, size_t bytes)
outputs the keystream of size <bytes> into
static const unsigned char tau[]
void SetKey(const unsigned char *key, size_t keylen)
set key with flexible keylength; 256bit recommended */