blob: dc4cf5ceb26ad0ed07d997e9db90ed5402f1195c [file] [log] [blame]
Martin Willi2546f812015-07-16 19:14:05 +02001/*
2 * Common values for the Poly1305 algorithm
3 */
4
5#ifndef _CRYPTO_POLY1305_H
6#define _CRYPTO_POLY1305_H
7
8#include <linux/types.h>
9#include <linux/crypto.h>
10
11#define POLY1305_BLOCK_SIZE 16
12#define POLY1305_KEY_SIZE 32
13#define POLY1305_DIGEST_SIZE 16
14
Eric Biggers888679d2018-11-16 17:26:27 -080015struct poly1305_key {
16 u32 r[5]; /* key, base 2^26 */
17};
18
19struct poly1305_state {
20 u32 h[5]; /* accumulator, base 2^26 */
21};
22
Martin Willi2546f812015-07-16 19:14:05 +020023struct poly1305_desc_ctx {
24 /* key */
Eric Biggers888679d2018-11-16 17:26:27 -080025 struct poly1305_key r;
Martin Willi2546f812015-07-16 19:14:05 +020026 /* finalize key */
27 u32 s[4];
28 /* accumulator */
Eric Biggers888679d2018-11-16 17:26:27 -080029 struct poly1305_state h;
Martin Willi2546f812015-07-16 19:14:05 +020030 /* partial buffer */
31 u8 buf[POLY1305_BLOCK_SIZE];
32 /* bytes used in partial buffer */
33 unsigned int buflen;
34 /* r key has been set */
35 bool rset;
36 /* s key has been set */
37 bool sset;
38};
39
40int crypto_poly1305_init(struct shash_desc *desc);
Martin Willi2546f812015-07-16 19:14:05 +020041unsigned int crypto_poly1305_setdesckey(struct poly1305_desc_ctx *dctx,
42 const u8 *src, unsigned int srclen);
43int crypto_poly1305_update(struct shash_desc *desc,
44 const u8 *src, unsigned int srclen);
45int crypto_poly1305_final(struct shash_desc *desc, u8 *dst);
46
47#endif