xref: /freebsd/sys/crypto/chacha20/chacha.h (revision 02e9120893770924227138ba49df1edb3896112a)
1 /* $OpenBSD: chacha.h,v 1.4 2016/08/27 04:04:56 guenther Exp $ */
2 
3 /*
4 chacha-merged.c version 20080118
5 D. J. Bernstein
6 Public domain.
7 */
8 
9 #ifndef CHACHA_H
10 #define CHACHA_H
11 
12 #include <sys/types.h>
13 #include <crypto/chacha20/_chacha.h>
14 
15 #define CHACHA_MINKEYLEN 	16
16 #define CHACHA_NONCELEN		8
17 #define CHACHA_CTRLEN		8
18 #define CHACHA_STATELEN		(CHACHA_NONCELEN+CHACHA_CTRLEN)
19 #define CHACHA_BLOCKLEN		64
20 
21 #ifdef CHACHA_EMBED
22 #define LOCAL static
23 #else
24 #define LOCAL
25 #endif
26 
27 #ifdef CHACHA_NONCE0_CTR128
28 #define CHACHA_UNUSED __unused
29 #else
30 #define CHACHA_UNUSED
31 #endif
32 
33 LOCAL void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits);
34 LOCAL void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv CHACHA_UNUSED,
35     const u_char *ctr);
36 LOCAL void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m,
37     u_char *c, u_int bytes);
38 
39 #undef CHACHA_UNUSED
40 
41 #endif	/* CHACHA_H */
42 
43