QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
poly1305.h
Go to the documentation of this file.
1/* 2025 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE: All information contained herein is, and remains
5 * the property of Quantum Resistant Cryptographic Solutions Incorporated.
6 * The intellectual and technical concepts contained
7 * herein are proprietary to Quantum Resistant Cryptographic Solutions Incorporated
8 * and its suppliers and may be covered by U.S. and Foreign Patents,
9 * patents in process, and are protected by trade secret or copyright law.
10 * Dissemination of this information or reproduction of this material
11 * is strictly forbidden unless prior written permission is obtained
12 * from Quantum Resistant Cryptographic Solutions Incorporated.
13 *
14 * Written by John G. Underhill
15 * Contact: john.underhill@protonmail.com
16 */
17
18#ifndef QSC_POLY1305_H
19#define QSC_POLY1305_H
20
21#include "common.h"
22
23QSC_CPLUSPLUS_ENABLED_START
24
58
63#define QSC_POLY1305_BLOCK_SIZE 16
64
69#define QSC_POLY1305_KEY_SIZE 32
70
75#define QSC_POLY1305_MAC_SIZE 16
76
82{
83 uint32_t h[5];
84 uint32_t k[4];
85 uint32_t r[5];
86 uint32_t s[4];
88 size_t fnl;
89 size_t rmd;
91
92
102QSC_EXPORT_API void qsc_poly1305_blockupdate(qsc_poly1305_state* ctx, const uint8_t* message);
103
114QSC_EXPORT_API void qsc_poly1305_compute(uint8_t* output, const uint8_t* message, size_t msglen, const uint8_t* key);
115
122
131
138QSC_EXPORT_API void qsc_poly1305_initialize(qsc_poly1305_state* ctx, const uint8_t* key);
139
146
155QSC_EXPORT_API void qsc_poly1305_update(qsc_poly1305_state* ctx, const uint8_t* message, size_t msglen);
156
167QSC_EXPORT_API int32_t qsc_poly1305_verify(const uint8_t* code, const uint8_t* message, size_t msglen, const uint8_t* key);
168
169QSC_CPLUSPLUS_ENABLED_END
170
171#endif
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition common.h:520
#define QSC_POLY1305_BLOCK_SIZE
The natural block size of the message input in bytes.
Definition poly1305.h:63
QSC_EXPORT_API int32_t qsc_poly1305_verify(const uint8_t *code, const uint8_t *message, size_t msglen, const uint8_t *key)
Verify a MAC code. Tests the code against the message and returns MQC_STATUS_SUCCESS or MQC_STATUS_FA...
Definition poly1305.c:257
QSC_EXPORT_API void qsc_poly1305_compute(uint8_t *output, const uint8_t *message, size_t msglen, const uint8_t *key)
Compute the MAC code and return the result in the mac byte array.
Definition poly1305.c:56
QSC_EXPORT_API void qsc_poly1305_update(qsc_poly1305_state *ctx, const uint8_t *message, size_t msglen)
Update the poly1305 generator with a length of message input. Absorbs the input message into the ctx.
Definition poly1305.c:206
QSC_EXPORT_API void qsc_poly1305_reset(qsc_poly1305_state *ctx)
Reset the ctx values to zero.
Definition poly1305.c:193
QSC_EXPORT_API void qsc_poly1305_initialize(qsc_poly1305_state *ctx, const uint8_t *key)
Initialize the ctx with the secret key.
Definition poly1305.c:166
QSC_EXPORT_API void qsc_poly1305_finalize(qsc_poly1305_state *ctx, uint8_t *mac)
Finalize the message ctx and returns the MAC code. Absorb the last block of message and create the MA...
Definition poly1305.c:79
QSC_EXPORT_API void qsc_poly1305_blockupdate(qsc_poly1305_state *ctx, const uint8_t *message)
Update the poly1305 generator with a single block of message input. Absorbs block sized lengths of in...
Definition poly1305.c:5
QSC_EXPORT_API void qsc_poly1305_dispose(qsc_poly1305_state *ctx)
Dispose of the ctx resetting all values to zero.
Definition poly1305.c:69
Contains the Poly1305 internal state.
Definition poly1305.h:82
uint32_t k[4]
Definition poly1305.h:84
size_t fnl
Definition poly1305.h:88
uint32_t s[4]
Definition poly1305.h:86
uint8_t buf[QSC_POLY1305_BLOCK_SIZE]
Definition poly1305.h:87
uint32_t h[5]
Definition poly1305.h:83
uint32_t r[5]
Definition poly1305.h:85
size_t rmd
Definition poly1305.h:89