14 return (v <<
c) | (v >> (32 -
c));
17#define QUARTERROUND(a, b, c, d) \
20 d = rotl32(d ^ a, 16); \
22 b = rotl32(b ^ c, 12); \
24 d = rotl32(d ^ a, 8); \
26 b = rotl32(b ^ c, 7); \
76 input[13] = pos >> 32;
80 uint32_t x0,
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8,
x9,
x10,
x11,
x12,
x13,
x14,
82 uint32_t j0,
j1,
j2,
j3,
j4,
j5,
j6,
j7,
j8,
j9,
j10,
j11,
j12,
j13,
j14,
130 for (i = 20; i > 0; i -= 2) {
181 for (i = 0; i < bytes; ++i) {
195 uint32_t x0,
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8,
x9,
x10,
x11,
x12,
x13,
x14,
197 uint32_t j0,
j1,
j2,
j3,
j4,
j5,
j6,
j7,
j8,
j9,
j10,
j11,
j12,
j13,
j14,
228 for (i = 0; i < bytes; ++i) {
251 for (i = 20; i > 0; i -= 2) {
319 for (i = 0; i < bytes; ++i) {
void SetKey(const uint8_t *key, size_t keylen)
set key with flexible keylength; 256bit recommended
void Keystream(uint8_t *c, size_t bytes)
outputs the keystream of size <bytes> into
void Crypt(const uint8_t *input, uint8_t *output, size_t bytes)
enciphers the message <input> of length <bytes> and write the enciphered representation into <output>...
static const uint8_t tau[]
static constexpr uint32_t rotl32(uint32_t v, int c)
static const uint8_t sigma[]
#define QUARTERROUND(a, b, c, d)
static void WriteLE32(uint8_t *ptr, uint32_t x)
static uint32_t ReadLE32(const uint8_t *ptr)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...