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