poly1305.h 881 B

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