Loading...
Searching...
No Matches
poly1305.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Andrew Moon (dedicated to the public domain)
3 * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
4 * SPDX-FileCopyrightText: 2018 Inria
5 * SPDX-License-Identifier: LGPL-2.1-only
6 */
7
8#pragma once
9
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <stddef.h>
33#include <stdint.h>
34
35#include "compiler_hints.h"
36
40#define POLY1305_BLOCK_SIZE 16
41
45typedef struct {
46 uint32_t r[4];
47 uint32_t pad[4];
48 uint32_t h[5];
49 uint32_t c[4];
50 size_t c_idx;
52
59void poly1305_init(poly1305_ctx_t *ctx, const uint8_t *key);
60
68ACCESS(read_only, 2, 3)
69void poly1305_update(poly1305_ctx_t *ctx, const uint8_t *data, size_t len);
70
77void poly1305_finish(poly1305_ctx_t *ctx, uint8_t *mac);
78
87ACCESS(read_only, 2, 3)
88void poly1305_auth(uint8_t *mac, const uint8_t *data, size_t len,
89 const uint8_t *key);
90
91#ifdef __cplusplus
92}
93#endif
Common macros and compiler attributes/pragmas configuration.
#define ACCESS(mode, ptr_idx, size_idx)
Emit an attribute (if supported by the compiler) that declares how a function will access its paramet...
void poly1305_finish(poly1305_ctx_t *ctx, uint8_t *mac)
Finish the poly1305 operation.
void poly1305_init(poly1305_ctx_t *ctx, const uint8_t *key)
Initialize a poly1305 context.
void poly1305_update(poly1305_ctx_t *ctx, const uint8_t *data, size_t len)
Update the poly1305 context with a block of message.
void poly1305_auth(uint8_t *mac, const uint8_t *data, size_t len, const uint8_t *key)
Calculate a single poly1305 tag.
Poly1305 context.
Definition poly1305.h:45
uint32_t c[4]
Message chunk.
Definition poly1305.h:49
uint32_t pad[4]
Second key part.
Definition poly1305.h:47
uint32_t r[4]
first key part
Definition poly1305.h:46
uint32_t h[5]
Hash.
Definition poly1305.h:48
size_t c_idx
Chunk length.
Definition poly1305.h:50