Merge commit 'dfc115332c94a2f62058ac7f2bce7631fbd20b3d'
[unleashed/tickless.git] / lib / libcrypto / chacha / chacha.h
blob8d94e626f8cb0f36f166c288f079996acb802091
1 /* $OpenBSD: chacha.h,v 1.7 2015/12/09 14:07:55 bcook Exp $ */
2 /*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #ifndef HEADER_CHACHA_H
19 #define HEADER_CHACHA_H
21 #include <openssl/opensslconf.h>
23 #if defined(OPENSSL_NO_CHACHA)
24 #error ChaCha is disabled.
25 #endif
27 #include <stddef.h>
28 #include <stdint.h>
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 typedef struct {
35 unsigned int input[16];
36 unsigned char ks[64];
37 unsigned char unused;
38 } ChaCha_ctx;
40 void ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key,
41 unsigned int keybits);
42 void ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv,
43 const unsigned char *counter);
44 void ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in,
45 size_t len);
47 void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len,
48 const unsigned char key[32], const unsigned char iv[8], uint64_t counter);
50 #ifdef __cplusplus
52 #endif
54 #endif /* HEADER_CHACHA_H */