xref: /linux/include/crypto/internal/poly1305.h (revision 1c08a104360f3e18f4ee6346c21cc3923efb952e)
148ea8c6eSArd Biesheuvel /* SPDX-License-Identifier: GPL-2.0 */
248ea8c6eSArd Biesheuvel /*
348ea8c6eSArd Biesheuvel  * Common values for the Poly1305 algorithm
448ea8c6eSArd Biesheuvel  */
548ea8c6eSArd Biesheuvel 
648ea8c6eSArd Biesheuvel #ifndef _CRYPTO_INTERNAL_POLY1305_H
748ea8c6eSArd Biesheuvel #define _CRYPTO_INTERNAL_POLY1305_H
848ea8c6eSArd Biesheuvel 
948ea8c6eSArd Biesheuvel #include <asm/unaligned.h>
1048ea8c6eSArd Biesheuvel #include <linux/types.h>
1148ea8c6eSArd Biesheuvel #include <crypto/poly1305.h>
1248ea8c6eSArd Biesheuvel 
1348ea8c6eSArd Biesheuvel /*
14*1c08a104SJason A. Donenfeld  * Poly1305 core functions.  These only accept whole blocks; the caller must
15*1c08a104SJason A. Donenfeld  * handle any needed block buffering and padding.  'hibit' must be 1 for any
16*1c08a104SJason A. Donenfeld  * full blocks, or 0 for the final block if it had to be padded.  If 'nonce' is
17*1c08a104SJason A. Donenfeld  * non-NULL, then it's added at the end to compute the Poly1305 MAC.  Otherwise,
18*1c08a104SJason A. Donenfeld  * only the ε-almost-∆-universal hash function (not the full MAC) is computed.
1948ea8c6eSArd Biesheuvel  */
20*1c08a104SJason A. Donenfeld 
21*1c08a104SJason A. Donenfeld void poly1305_core_setkey(struct poly1305_core_key *key, const u8 *raw_key);
2248ea8c6eSArd Biesheuvel static inline void poly1305_core_init(struct poly1305_state *state)
2348ea8c6eSArd Biesheuvel {
2448ea8c6eSArd Biesheuvel 	*state = (struct poly1305_state){};
2548ea8c6eSArd Biesheuvel }
2648ea8c6eSArd Biesheuvel 
2748ea8c6eSArd Biesheuvel void poly1305_core_blocks(struct poly1305_state *state,
28*1c08a104SJason A. Donenfeld 			  const struct poly1305_core_key *key, const void *src,
2948ea8c6eSArd Biesheuvel 			  unsigned int nblocks, u32 hibit);
30*1c08a104SJason A. Donenfeld void poly1305_core_emit(const struct poly1305_state *state, const u32 nonce[4],
31*1c08a104SJason A. Donenfeld 			void *dst);
3248ea8c6eSArd Biesheuvel 
3348ea8c6eSArd Biesheuvel #endif
34