Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/include/openssl/chacha.h

raw
1 // Copyright (c) 2014, Google Inc.
2 // SPDX-License-Identifier: ISC
3
4 #ifndef OPENSSL_HEADER_CHACHA_H
5 #define OPENSSL_HEADER_CHACHA_H
6
7 #include <openssl/base.h>
8
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
12
13 // ChaCha20.
14 //
15 // ChaCha20 is a stream cipher. See https://tools.ietf.org/html/rfc8439.
16
17
18 // CRYPTO_chacha_20 encrypts |in_len| bytes from |in| with the given key and
19 // nonce and writes the result to |out|. If |in| and |out| alias, they must be
20 // equal. The initial block counter is specified by |counter|. |in| must be
21 // aligned on a block boundary.
22 //
23 // This function implements a 32-bit block counter as in RFC 8439. On overflow,
24 // the counter wraps. Reusing a key, nonce, and block counter combination is not
25 // secure, so wrapping is usually a bug in the caller. While it is possible to
26 // wrap without reuse with a large initial block counter, this is not
27 // recommended and may not be portable to other ChaCha20 implementations.
28 OPENSSL_EXPORT void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in,
29 size_t in_len, const uint8_t key[32],
30 const uint8_t nonce[12], uint32_t counter);
31
32
33 #if defined(__cplusplus)
34 } // extern C
35 #endif
36
37 #endif // OPENSSL_HEADER_CHACHA_H