nrfxlib API 3.3.99
Loading...
Searching...
No Matches
ocrypto_chacha20_poly1305.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 - 2025 Nordic Semiconductor ASA
3 * Copyright (c) since 2013 Oberon microsystems AG
4 *
5 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6 */
7
8
30#ifndef OCRYPTO_CHACHA20_POLY1305_INC_H
31#define OCRYPTO_CHACHA20_POLY1305_INC_H
32
33#include <stdint.h>
34#include <stddef.h>
35#include "ocrypto_chacha20.h"
36#include "ocrypto_poly1305.h"
37
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43
47#define ocrypto_chacha20_poly1305_KEY_BYTES (32)
48
52#define ocrypto_chacha20_poly1305_NONCE_BYTES_MAX (12)
53
57#define ocrypto_chacha20_poly1305_TAG_BYTES (16)
58
59
61typedef struct {
62 ocrypto_chacha20_ctx enc_ctx;
63 ocrypto_poly1305_ctx auth_ctx;
64 size_t msg_len;
65 size_t aad_len;
66} ocrypto_chacha20_poly1305_ctx;
114 ocrypto_chacha20_poly1305_ctx *ctx,
115 const uint8_t *n, size_t n_len,
116 const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]);
117
138 ocrypto_chacha20_poly1305_ctx *ctx,
139 const uint8_t *a, size_t a_len);
140
163 ocrypto_chacha20_poly1305_ctx *ctx,
164 uint8_t *c,
165 const uint8_t *m, size_t m_len);
166
189 ocrypto_chacha20_poly1305_ctx *ctx,
190 uint8_t *m,
191 const uint8_t *c, size_t c_len);
192
202 ocrypto_chacha20_poly1305_ctx *ctx,
204
217 ocrypto_chacha20_poly1305_ctx *ctx,
218 const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES]);
252 uint8_t *c,
253 const uint8_t *m, size_t m_len,
254 const uint8_t *a, size_t a_len,
255 const uint8_t *n, size_t n_len,
256 const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]);
257
282 const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES],
283 uint8_t *m,
284 const uint8_t *c, size_t c_len,
285 const uint8_t *a, size_t a_len,
286 const uint8_t *n, size_t n_len,
287 const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]);
288
289#ifdef __cplusplus
290}
291#endif
292
293#endif
294
void ocrypto_chacha20_poly1305_update_enc(ocrypto_chacha20_poly1305_ctx *ctx, uint8_t *c, const uint8_t *m, size_t m_len)
int ocrypto_chacha20_poly1305_decrypt(const uint8_t tag[(16)], uint8_t *m, const uint8_t *c, size_t c_len, const uint8_t *a, size_t a_len, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
void ocrypto_chacha20_poly1305_update_aad(ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t *a, size_t a_len)
#define ocrypto_chacha20_poly1305_KEY_BYTES
Definition ocrypto_chacha20_poly1305.h:47
#define ocrypto_chacha20_poly1305_TAG_BYTES
Definition ocrypto_chacha20_poly1305.h:57
void ocrypto_chacha20_poly1305_update_dec(ocrypto_chacha20_poly1305_ctx *ctx, uint8_t *m, const uint8_t *c, size_t c_len)
int ocrypto_chacha20_poly1305_final_dec(ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t tag[(16)])
void ocrypto_chacha20_poly1305_encrypt(uint8_t tag[(16)], uint8_t *c, const uint8_t *m, size_t m_len, const uint8_t *a, size_t a_len, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
void ocrypto_chacha20_poly1305_init(ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
void ocrypto_chacha20_poly1305_final_enc(ocrypto_chacha20_poly1305_ctx *ctx, uint8_t tag[(16)])
ChaCha20 and XChaCha20 algorithms.
Poly1305 authentication algorithm.