nrfxlib API 0.1.0
Loading...
Searching...
No Matches
ocrypto_aes_ccm.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
27#ifndef OCRYPTO_AES_CCM_H
28#define OCRYPTO_AES_CCM_H
29
30#include <stddef.h>
31#include <stdint.h>
32
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38
40typedef struct {
41 uint32_t xkey[60];
42 uint8_t counter[16];
43 uint8_t cipher[16];
44 uint8_t x[16];
45 uint8_t position; // Current position in cipher.
46 uint8_t length; // Data length added to x.
47 uint8_t cnt_pos; // Count position in counter.
48 uint8_t key_size; // Key size (16, 24, or 32 bytes).
49 size_t pt_len; // Total plaintext length.
50 size_t aa_len; // Total aad length.
51} ocrypto_aes_ccm_ctx;
79void ocrypto_aes_ccm_init(ocrypto_aes_ccm_ctx *ctx, const uint8_t *key, size_t size,
80 const uint8_t *nonce, size_t n_len, size_t tag_len, size_t pt_len, size_t aa_len);
81
82
99void ocrypto_aes_ccm_update_aad(ocrypto_aes_ccm_ctx *ctx, const uint8_t *aa, size_t aa_len);
100
117void ocrypto_aes_ccm_update_enc(ocrypto_aes_ccm_ctx *ctx, uint8_t* ct, const uint8_t* pt, size_t pt_len);
118
135void ocrypto_aes_ccm_update_dec(ocrypto_aes_ccm_ctx *ctx, uint8_t* pt, const uint8_t* ct, size_t ct_len);
136
137
147void ocrypto_aes_ccm_final_enc(ocrypto_aes_ccm_ctx *ctx, uint8_t *tag, size_t tag_len);
148
161int ocrypto_aes_ccm_final_dec(ocrypto_aes_ccm_ctx *ctx, const uint8_t *tag, size_t tag_len);
162
184 uint8_t *ct,
185 uint8_t *tag, size_t tag_len,
186 const uint8_t *pt, size_t pt_len,
187 const uint8_t *key, size_t size,
188 const uint8_t *nonce, size_t n_len,
189 const uint8_t *aa, size_t aa_len);
190
212 uint8_t *pt,
213 const uint8_t *tag, size_t tag_len,
214 const uint8_t *ct, size_t ct_len,
215 const uint8_t *key, size_t size,
216 const uint8_t *nonce, size_t n_len,
217 const uint8_t *aa, size_t aa_len);
218
219
220#ifdef __cplusplus
221}
222#endif
223
224#endif
225
void ocrypto_aes_ccm_update_aad(ocrypto_aes_ccm_ctx *ctx, const uint8_t *aa, size_t aa_len)
void ocrypto_aes_ccm_update_enc(ocrypto_aes_ccm_ctx *ctx, uint8_t *ct, const uint8_t *pt, size_t pt_len)
int ocrypto_aes_ccm_decrypt(uint8_t *pt, const uint8_t *tag, size_t tag_len, const uint8_t *ct, size_t ct_len, const uint8_t *key, size_t size, const uint8_t *nonce, size_t n_len, const uint8_t *aa, size_t aa_len)
void ocrypto_aes_ccm_update_dec(ocrypto_aes_ccm_ctx *ctx, uint8_t *pt, const uint8_t *ct, size_t ct_len)
void ocrypto_aes_ccm_final_enc(ocrypto_aes_ccm_ctx *ctx, uint8_t *tag, size_t tag_len)
int ocrypto_aes_ccm_final_dec(ocrypto_aes_ccm_ctx *ctx, const uint8_t *tag, size_t tag_len)
void ocrypto_aes_ccm_encrypt(uint8_t *ct, uint8_t *tag, size_t tag_len, const uint8_t *pt, size_t pt_len, const uint8_t *key, size_t size, const uint8_t *nonce, size_t n_len, const uint8_t *aa, size_t aa_len)
void ocrypto_aes_ccm_init(ocrypto_aes_ccm_ctx *ctx, const uint8_t *key, size_t size, const uint8_t *nonce, size_t n_len, size_t tag_len, size_t pt_len, size_t aa_len)