1 #ifndef _CRYPTO_CHACHA_H_
2 #define _CRYPTO_CHACHA_H_
4 #define CHACHA_NONCELEN 8
5 #define CHACHA_CTRLEN 8
6 #define CHACHA_STATELEN (CHACHA_NONCELEN + CHACHA_CTRLEN)
7 #define CHACHA_BLOCKLEN 64
9 typedef struct chacha_ctx
11 uint32_t input
[16]; /* could be compressed */
14 void chacha_keysetup(chacha_ctx
*x
, const uint8_t *k
, uint32_t kbits
);
15 void chacha_ivsetup(chacha_ctx
*x
, const uint8_t *iv
);
16 void chacha_encrypt_bytes(chacha_ctx
*x
, const uint8_t *m
, uint8_t *c
, uint32_t bytes
);
17 void chacha_decrypt_bytes(chacha_ctx
*x
, const uint8_t *c
, uint8_t *m
, uint32_t bytes
);
18 void chacha_keystream_bytes(chacha_ctx
*x
, uint8_t *stream
, uint32_t bytes
);
19 int chacha_incr_counter(chacha_ctx
*x
);
20 int chacha_check_counter(chacha_ctx
*x
);