a137ab6b2e6dcf20462bc78c3dd075957a48fde8
[tinc] / src / chacha-poly1305 / chacha.h
1 /*
2 chacha-merged.c version 20080118
3 D. J. Bernstein
4 Public domain.
5 */
6
7 #ifndef CHACHA_H
8 #define CHACHA_H
9
10 #include <sys/types.h>
11 #include <stdint.h>
12 #include <stdlib.h>
13 #include <string.h>
14
15 #define CHACHA_BLOCKLEN         64
16
17 /* use memcpy() to copy blocks of memory (typically faster) */
18 #define USE_MEMCPY          1
19 /* use unaligned little-endian load/store (can be faster) */
20 #define USE_UNALIGNED       0
21
22 struct chacha_ctx {
23         uint32_t input[16];
24 };
25
26 void chacha_keysetup(struct chacha_ctx *x, const unsigned char *k,
27                      uint32_t kbits);
28 void chacha_ivsetup(struct chacha_ctx *x, const unsigned char *iv,
29                     const unsigned char *ctr);
30 void chacha_encrypt_bytes(struct chacha_ctx *x, const unsigned char *m,
31                           unsigned char *c, uint32_t bytes);
32
33 #endif  /* CHACHA_H */
34