poly1305.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Common values for the Poly1305 algorithm
  4. */
  5. #ifndef _CRYPTO_INTERNAL_POLY1305_H
  6. #define _CRYPTO_INTERNAL_POLY1305_H
  7. #include <asm/unaligned.h>
  8. #include <linux/types.h>
  9. #include <crypto/poly1305.h>
  10. /*
  11. * Poly1305 core functions. These only accept whole blocks; the caller must
  12. * handle any needed block buffering and padding. 'hibit' must be 1 for any
  13. * full blocks, or 0 for the final block if it had to be padded. If 'nonce' is
  14. * non-NULL, then it's added at the end to compute the Poly1305 MAC. Otherwise,
  15. * only the ε-almost-∆-universal hash function (not the full MAC) is computed.
  16. */
  17. void poly1305_core_setkey(struct poly1305_core_key *key,
  18. const u8 raw_key[POLY1305_BLOCK_SIZE]);
  19. static inline void poly1305_core_init(struct poly1305_state *state)
  20. {
  21. *state = (struct poly1305_state){};
  22. }
  23. void poly1305_core_blocks(struct poly1305_state *state,
  24. const struct poly1305_core_key *key, const void *src,
  25. unsigned int nblocks, u32 hibit);
  26. void poly1305_core_emit(const struct poly1305_state *state, const u32 nonce[4],
  27. void *dst);
  28. #endif