File Index
Files and directories
Sign in
FILE

poly1305.h

File preview with syntax highlighting.

linux-6.19.14/include/crypto/poly1305.h OBJECTIVE-C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * Common values for the Poly1305 algorithm
 4 */
 5
 6#ifndef _CRYPTO_POLY1305_H
 7#define _CRYPTO_POLY1305_H
 8
 9#include <linux/types.h>
10
11#define POLY1305_BLOCK_SIZE	16
12#define POLY1305_KEY_SIZE	32
13#define POLY1305_DIGEST_SIZE	16
14
15/* The poly1305_key and poly1305_state types are mostly opaque and
16 * implementation-defined. Limbs might be in base 2^64 or base 2^26, or
17 * different yet. The union type provided keeps these 64-bit aligned for the
18 * case in which this is implemented using 64x64 multiplies.
19 */
20
21struct poly1305_key {
22	union {
23		u32 r[5];
24		u64 r64[3];
25	};
26};
27
28struct poly1305_core_key {
29	struct poly1305_key key;
30	struct poly1305_key precomputed_s;
31};
32
33struct poly1305_state {
34	union {
35		u32 h[5];
36		u64 h64[3];
37	};
38};
39
40/* Combined state for block function. */
41struct poly1305_block_state {
42	/* accumulator */
43	struct poly1305_state h;
44	/* key */
45	union {
46		struct poly1305_key opaque_r[CONFIG_CRYPTO_LIB_POLY1305_RSIZE];
47		struct poly1305_core_key core_r;
48	};
49};
50
51struct poly1305_desc_ctx {
52	/* partial buffer */
53	u8 buf[POLY1305_BLOCK_SIZE];
54	/* bytes used in partial buffer */
55	unsigned int buflen;
56	/* finalize key */
57	u32 s[4];
58	struct poly1305_block_state state;
59};
60
61void poly1305_init(struct poly1305_desc_ctx *desc,
62		   const u8 key[at_least POLY1305_KEY_SIZE]);
63void poly1305_update(struct poly1305_desc_ctx *desc,
64		     const u8 *src, unsigned int nbytes);
65void poly1305_final(struct poly1305_desc_ctx *desc, u8 *digest);
66
67#endif
~/ Read-only file preview.