poly1305.h 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Common values for the Poly1305 algorithm
  4. */
  5. #ifndef _CRYPTO_POLY1305_H
  6. #define _CRYPTO_POLY1305_H
  7. #include <linux/types.h>
  8. #include <linux/crypto.h>
  9. #define POLY1305_BLOCK_SIZE 16
  10. #define POLY1305_KEY_SIZE 32
  11. #define POLY1305_DIGEST_SIZE 16
  12. struct poly1305_desc_ctx {
  13. /* key */
  14. u32 r[5];
  15. /* finalize key */
  16. u32 s[4];
  17. /* accumulator */
  18. u32 h[5];
  19. /* partial buffer */
  20. u8 buf[POLY1305_BLOCK_SIZE];
  21. /* bytes used in partial buffer */
  22. unsigned int buflen;
  23. /* r key has been set */
  24. bool rset;
  25. /* s key has been set */
  26. bool sset;
  27. };
  28. int crypto_poly1305_init(struct shash_desc *desc);
  29. unsigned int crypto_poly1305_setdesckey(struct poly1305_desc_ctx *dctx,
  30. const u8 *src, unsigned int srclen);
  31. int crypto_poly1305_update(struct shash_desc *desc,
  32. const u8 *src, unsigned int srclen);
  33. int crypto_poly1305_final(struct shash_desc *desc, u8 *dst);
  34. #endif