libssh: chacha.h Source File

libssh 0.9.5 The SSH library

chacha.h
1 /* $OpenBSD: chacha.h,v 1.3 2014/05/02 03:27:54 djm 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 struct chacha_ctx {
13 uint32_t input[16];
14 };
15
16 #define CHACHA_MINKEYLEN 16
17 #define CHACHA_NONCELEN 8
18 #define CHACHA_CTRLEN 8
19 #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
20 #define CHACHA_BLOCKLEN 64
21
22 void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits)
23 #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
24 __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)))
25 #endif
26 ;
27 void chacha_ivsetup(struct chacha_ctx *x, const uint8_t *iv, const uint8_t *ctr)
28 #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
29 __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN)))
30 __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN)))
31 #endif
32 ;
33 void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m,
34 uint8_t *c, uint32_t bytes)
35 #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
36 __attribute__((__bounded__(__buffer__, 2, 4)))
37 __attribute__((__bounded__(__buffer__, 3, 4)))
38 #endif
39 ;
40
41 #endif /* CHACHA_H */
chacha_ctx
Definition: chacha.h:12