nrfxlib API 2.8.99
Loading...
Searching...
No Matches
ocrypto_chacha20.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
29#ifndef OCRYPTO_CHACHA20_H
30#define OCRYPTO_CHACHA20_H
31
32#include <stddef.h>
33#include <stdint.h>
34
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40
44#define ocrypto_chacha20_KEY_BYTES (32)
45
49#define ocrypto_chacha20_NONCE_BYTES_MAX (12)
50
51
53typedef struct {
54 uint32_t x[16]; // generator state
55 uint8_t cipher[64];
56 uint8_t position; // Current position in cipher.
57} ocrypto_chacha20_ctx;
94 ocrypto_chacha20_ctx *ctx,
95 const uint8_t *n, size_t n_len,
96 const uint8_t key[ocrypto_chacha20_KEY_BYTES],
97 uint32_t count);
98
117 ocrypto_chacha20_ctx *ctx,
118 uint8_t *c,
119 const uint8_t *m, size_t m_len);
146 uint8_t *c,
147 const uint8_t *m, size_t m_len,
148 const uint8_t *n, size_t n_len,
149 const uint8_t key[ocrypto_chacha20_KEY_BYTES],
150 uint32_t count);
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif
157
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:44
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)