libsodium: updated to 1.0.10
[tomato.git] / release / src / router / libsodium / src / libsodium / crypto_core / hchacha20 / core_hchacha20.h
blob6e1d1c54fa70e0db52be16093b6c4bfd375f0c51
1 #ifndef core_hchacha20_H
2 #define core_hchacha20_H
4 #include <stdint.h>
5 #include <stdlib.h>
6 #include <string.h>
8 #define U8C(v) (v##U)
9 #define U32C(v) (v##U)
11 #define U8V(v) ((uint8_t)(v) & U8C(0xFF))
12 #define U32V(v) ((uint32_t)(v) & U32C(0xFFFFFFFF))
14 #define ROTL32(v, n) (U32V((v) << (n)) | ((v) >> (32 - (n))))
16 #define ROTATE(v, c) (ROTL32(v, c))
17 #define XOR(v, w) ((v) ^ (w))
18 #define PLUS(v, w) (U32V((v) + (w)))
20 #define QUARTERROUND(a, b, c, d) \
21 do { \
22 a = PLUS(a, b); d = ROTATE(XOR(d, a), 16); \
23 c = PLUS(c, d); b = ROTATE(XOR(b, c), 12); \
24 a = PLUS(a, b); d = ROTATE(XOR(d, a), 8); \
25 c = PLUS(c, d); b = ROTATE(XOR(b, c), 7); \
26 } while(0)
28 #endif