cipher-chachapoly.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* $OpenBSD: cipher-chachapoly.h,v 1.5 2020/04/03 04:27:03 djm Exp $ */
  2. /*
  3. * Copyright (c) Damien Miller 2013 <djm@mindrot.org>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef CHACHA_POLY_AEAD_H
  18. #define CHACHA_POLY_AEAD_H
  19. #include <sys/types.h>
  20. #include "chacha.h"
  21. #include "poly1305.h"
  22. #define CHACHA_KEYLEN 32 /* Only 256 bit keys used here */
  23. struct chachapoly_ctx;
  24. struct chachapoly_ctx *chachapoly_new(const u_char *key, u_int keylen)
  25. __attribute__((__bounded__(__buffer__, 1, 2)));
  26. void chachapoly_free(struct chachapoly_ctx *cpctx);
  27. int chachapoly_crypt(struct chachapoly_ctx *cpctx, u_int seqnr,
  28. u_char *dest, const u_char *src, u_int len, u_int aadlen, u_int authlen,
  29. int do_encrypt);
  30. int chachapoly_get_length(struct chachapoly_ctx *cpctx,
  31. u_int *plenp, u_int seqnr, const u_char *cp, u_int len)
  32. __attribute__((__bounded__(__buffer__, 4, 5)));
  33. #endif /* CHACHA_POLY_AEAD_H */