nrfxlib API 0.1.0
Loading...
Searching...
No Matches
ocrypto_chacha20_poly1305.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 - 2024 Nordic Semiconductor ASA
3 * Copyright (c) since 2013 Oberon microsystems AG
4 *
5 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6 */
7
8
24#ifndef OCRYPTO_CHACHA20_POLY1305_INC_H
25#define OCRYPTO_CHACHA20_POLY1305_INC_H
26
27#include <stdint.h>
28#include <stddef.h>
29#include "ocrypto_chacha20.h"
30#include "ocrypto_poly1305.h"
31
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
41#define ocrypto_chacha20_poly1305_KEY_BYTES (32)
42
46#define ocrypto_chacha20_poly1305_NONCE_BYTES_MAX (12)
47
51#define ocrypto_chacha20_poly1305_TAG_BYTES (16)
52
53
55typedef struct {
56 ocrypto_chacha20_ctx enc_ctx;
57 ocrypto_poly1305_ctx auth_ctx;
58 size_t msg_len;
59 size_t aad_len;
60} ocrypto_chacha20_poly1305_ctx;
107 ocrypto_chacha20_poly1305_ctx *ctx,
108 const uint8_t *n, size_t n_len,
109 const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]);
110
129 ocrypto_chacha20_poly1305_ctx *ctx,
130 const uint8_t *a, size_t a_len);
131
154 ocrypto_chacha20_poly1305_ctx *ctx,
155 uint8_t *c,
156 const uint8_t *m, size_t m_len);
157
180 ocrypto_chacha20_poly1305_ctx *ctx,
181 uint8_t *m,
182 const uint8_t *c, size_t c_len);
183
193 ocrypto_chacha20_poly1305_ctx *ctx,
195
208 ocrypto_chacha20_poly1305_ctx *ctx,
209 const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES]);
241 uint8_t *c,
242 const uint8_t *m, size_t m_len,
243 const uint8_t *a, size_t a_len,
244 const uint8_t *n, size_t n_len,
245 const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]);
246
271 const uint8_t tag[ocrypto_chacha20_poly1305_TAG_BYTES],
272 uint8_t *m,
273 const uint8_t *c, size_t c_len,
274 const uint8_t *a, size_t a_len,
275 const uint8_t *n, size_t n_len,
276 const uint8_t k[ocrypto_chacha20_poly1305_KEY_BYTES]);
277
278#ifdef __cplusplus
279}
280#endif
281
282#endif
283
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:41
#define ocrypto_chacha20_poly1305_TAG_BYTES
Definition: ocrypto_chacha20_poly1305.h:51
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)])