nrfxlib API 3.3.99
Loading...
Searching...
No Matches
ocrypto_chacha20.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
37#ifndef OCRYPTO_CHACHA20_H
38#define OCRYPTO_CHACHA20_H
39
40#include <stddef.h>
41#include <stdint.h>
42
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48
52#define ocrypto_chacha20_KEY_BYTES (32)
53
57#define ocrypto_chacha20_NONCE_BYTES_MAX (12)
58
59
61typedef struct {
62 uint32_t x[16]; // generator state
63 uint8_t cipher[64];
64 uint8_t position; // Current position in cipher.
65} ocrypto_chacha20_ctx;
105 ocrypto_chacha20_ctx *ctx,
106 const uint8_t *n, size_t n_len,
107 const uint8_t key[ocrypto_chacha20_KEY_BYTES],
108 uint32_t count);
109
131 ocrypto_chacha20_ctx *ctx,
132 uint8_t *c,
133 const uint8_t *m, size_t m_len);
161 uint8_t *c,
162 const uint8_t *m, size_t m_len,
163 const uint8_t *n, size_t n_len,
164 const uint8_t key[ocrypto_chacha20_KEY_BYTES],
165 uint32_t count);
166
167#ifdef __cplusplus
168}
169#endif
170
171#endif
172
void ocrypto_chacha20_init(ocrypto_chacha20_ctx *ctx, const uint8_t *n, size_t n_len, const uint8_t key[(32)], uint32_t count)
#define ocrypto_chacha20_KEY_BYTES
Definition ocrypto_chacha20.h:52
void ocrypto_chacha20_encode(uint8_t *c, const uint8_t *m, size_t m_len, const uint8_t *n, size_t n_len, const uint8_t key[(32)], uint32_t count)
void ocrypto_chacha20_update(ocrypto_chacha20_ctx *ctx, uint8_t *c, const uint8_t *m, size_t m_len)