ProtoCore
v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
poly1305.h
Go to the documentation of this file.
1
// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2
// SPDX-License-Identifier: AGPL-3.0-or-later
3
4
/**
5
* @file poly1305.h
6
* @brief Poly1305 one-time authenticator (D. J. Bernstein; RFC 8439 Section 2.5).
7
*
8
* A one-time MAC over a message under a 32-byte key (r || s). Used by the
9
* chacha20-poly1305@openssh.com cipher, where the key is the first 32 bytes of the ChaCha20
10
* block-0 keystream for the packet. 130-bit modular arithmetic in 5 x 26-bit limbs (poly1305-donna
11
* layout). Pure, no heap; the caller must use each key exactly once.
12
*
13
* @author Douglas Quigg (dstroy0)
14
* @date 2026
15
*/
16
17
#ifndef PROTOCORE_POLY1305_H
18
#define PROTOCORE_POLY1305_H
19
20
#include <stddef.h>
21
#include <stdint.h>
22
23
#define PC_POLY1305_KEY_LEN 32
24
#define PC_POLY1305_TAG_LEN 16
25
26
/** @brief Compute the 16-byte Poly1305 tag over @p msg under the 32-byte one-time @p key. */
27
void
pc_poly1305
(uint8_t tag[
PC_POLY1305_TAG_LEN
],
const
uint8_t *msg,
size_t
len,
28
const
uint8_t key[
PC_POLY1305_KEY_LEN
]);
29
30
#endif
// PROTOCORE_POLY1305_H
pc_poly1305
void pc_poly1305(uint8_t tag[PC_POLY1305_TAG_LEN], const uint8_t *msg, size_t len, const uint8_t key[PC_POLY1305_KEY_LEN])
Compute the 16-byte Poly1305 tag over msg under the 32-byte one-time key.
Definition
poly1305.cpp:97
PC_POLY1305_KEY_LEN
#define PC_POLY1305_KEY_LEN
Definition
poly1305.h:23
PC_POLY1305_TAG_LEN
#define PC_POLY1305_TAG_LEN
Definition
poly1305.h:24
src
crypto
mac
poly1305.h
Generated by
1.9.8