libssh 0.12.0
The SSH library
Loading...
Searching...
No Matches
chacha.h
1/* $OpenBSD: chacha.h,v 1.3 2014/05/02 03:27:54 djm Exp $ */
2
3/*
4chacha-merged.c version 20080118
5D. J. Bernstein
6Public domain.
7*/
8
9#ifndef CHACHA_H
10#define CHACHA_H
11
12#include <stdint.h>
13
14struct chacha_ctx {
15 uint32_t input[16];
16};
17
18#define CHACHA_MINKEYLEN 16
19#define CHACHA_NONCELEN 8
20#define CHACHA_CTRLEN 8
21#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits)
28#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
29 __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)))
30#endif
31 ;
32void chacha_ivsetup(struct chacha_ctx *x, const uint8_t *iv, const uint8_t *ctr)
33#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
34 __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN)))
35 __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN)))
36#endif
37 ;
38void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m,
39 uint8_t *c, uint32_t bytes)
40#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
41 __attribute__((__bounded__(__buffer__, 2, 4)))
42 __attribute__((__bounded__(__buffer__, 3, 4)))
43#endif
44 ;
45
46#ifdef __cplusplus
47}
48#endif
49
50#endif /* CHACHA_H */
Definition chacha.h:14