20#ifndef LC_CHACHA20_PRIVATE_H
21#define LC_CHACHA20_PRIVATE_H
23#include "ext_headers.h"
30#define LC_CC20_KEY_SIZE 32
31#define LC_CC20_KEY_SIZE_WORDS (LC_CC20_KEY_SIZE / sizeof(uint32_t))
33#define LC_CC20_BLOCK_SIZE ((4 + 8 + 4) * sizeof(uint32_t))
34#define LC_CC20_BLOCK_SIZE_WORDS (LC_CC20_BLOCK_SIZE / sizeof(uint32_t))
44 uint32_t constants[4];
46 uint32_t u[LC_CC20_KEY_SIZE_WORDS];
47 uint8_t b[LC_CC20_KEY_SIZE];
51 uint32_t u[LC_CC20_BLOCK_SIZE_WORDS];
52 uint8_t b[LC_CC20_BLOCK_SIZE];
54 uint8_t keystream_ptr;
57#define LC_CC20_STATE_SIZE (sizeof(struct lc_sym_state))
59static inline void cc20_init_constants(
struct lc_sym_state *ctx)
65 ctx->constants[0] = 0x61707865;
66 ctx->constants[1] = 0x3320646e;
67 ctx->constants[2] = 0x79622d32;
68 ctx->constants[3] = 0x6b206574;
71static inline void cc20_counter_overflow(
struct lc_sym_state *ctx)
73 if (ctx->counter[0] == 0) {
75 if (ctx->counter[1] == 0) {
77 if (ctx->counter[2] == 0)
83static inline void cc20_inc_counter(
struct lc_sym_state *ctx)
86 cc20_counter_overflow(ctx);