chacha.h 1000 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* $OpenBSD: chacha.h,v 1.4 2016/08/27 04:04:56 guenther Exp $ */
  2. /*
  3. chacha-merged.c version 20080118
  4. D. J. Bernstein
  5. Public domain.
  6. */
  7. #ifndef CHACHA_H
  8. #define CHACHA_H
  9. #include <sys/types.h>
  10. #include <stdlib.h>
  11. struct chacha_ctx {
  12. u_int input[16];
  13. };
  14. #define CHACHA_MINKEYLEN 16
  15. #define CHACHA_NONCELEN 8
  16. #define CHACHA_CTRLEN 8
  17. #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
  18. #define CHACHA_BLOCKLEN 64
  19. void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits)
  20. __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)));
  21. void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr)
  22. __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN)))
  23. __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN)));
  24. void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m,
  25. u_char *c, u_int bytes)
  26. __attribute__((__bounded__(__buffer__, 2, 4)))
  27. __attribute__((__bounded__(__buffer__, 3, 4)));
  28. #endif /* CHACHA_H */