1 /* $NetBSD: chacha.h,v 1.3 2021/04/19 14:40:15 christos Exp $ */ 2 /* $OpenBSD: chacha.h,v 1.5 2021/04/03 05:54:14 djm Exp $ */ 3 4 /* 5 chacha-merged.c version 20080118 6 D. J. Bernstein 7 Public domain. 8 */ 9 10 #ifndef CHACHA_H 11 #define CHACHA_H 12 13 #include <sys/types.h> 14 #include <stdlib.h> 15 16 struct chacha_ctx { 17 u_int input[16]; 18 }; 19 20 #define CHACHA_MINKEYLEN 16 21 #define CHACHA_NONCELEN 8 22 #define CHACHA_CTRLEN 8 23 #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) 24 #define CHACHA_BLOCKLEN 64 25 26 void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits) 27 __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))); 28 void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr) 29 __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN))) 30 __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN))); 31 void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, 32 u_char *c, u_int bytes) 33 __attribute__((__bounded__(__buffer__, 2, 4))) 34 __attribute__((__bounded__(__buffer__, 3, 4))); 35 36 #endif /* CHACHA_H */ 37 38