nrfxlib API 2.8.99
Loading...
Searching...
No Matches
ocrypto_aes_gcm.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_GCM_H
28#define OCRYPTO_AES_GCM_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 m[16];
46 uint8_t position; // Current position in cipher.
47 uint8_t length; // Data length added to x.
48 uint8_t key_size; // Key size (16, 24, or 32 bytes).
49 size_t ct_len; // Total ciphertext length
50 size_t aa_len; // Total aad length.
51} ocrypto_aes_gcm_ctx;
75void ocrypto_aes_gcm_init(ocrypto_aes_gcm_ctx *ctx, const uint8_t *key, size_t size, const uint8_t iv[12]);
76
86void ocrypto_aes_gcm_init_iv(ocrypto_aes_gcm_ctx* ctx, const uint8_t* iv, size_t iv_len);
87
104void ocrypto_aes_gcm_update_aad(ocrypto_aes_gcm_ctx *ctx, const uint8_t *aa, size_t aa_len);
105
122void ocrypto_aes_gcm_update_enc(ocrypto_aes_gcm_ctx *ctx, uint8_t* ct, const uint8_t* pt, size_t pt_len);
123
140void ocrypto_aes_gcm_update_dec(ocrypto_aes_gcm_ctx *ctx, uint8_t* pt, const uint8_t* ct, size_t ct_len);
141
151void ocrypto_aes_gcm_final_enc(ocrypto_aes_gcm_ctx *ctx, uint8_t *tag, size_t tag_len);
152
165int ocrypto_aes_gcm_final_dec(ocrypto_aes_gcm_ctx *ctx, const uint8_t *tag, size_t tag_len);
166
187 uint8_t* ct, uint8_t *tag, size_t tag_len, const uint8_t* pt, size_t pt_len,
188 const uint8_t *key, size_t size, const uint8_t iv[12], const uint8_t *aa, size_t aa_len);
189
210 uint8_t* pt, const uint8_t *tag, size_t tag_len, const uint8_t* ct, size_t ct_len,
211 const uint8_t *key, size_t size, const uint8_t iv[12], const uint8_t *aa, size_t aa_len);
212
213
214#ifdef __cplusplus
215}
216#endif
217
218#endif
219
void ocrypto_aes_gcm_update_aad(ocrypto_aes_gcm_ctx *ctx, const uint8_t *aa, size_t aa_len)
void ocrypto_aes_gcm_update_enc(ocrypto_aes_gcm_ctx *ctx, uint8_t *ct, const uint8_t *pt, size_t pt_len)
void ocrypto_aes_gcm_init(ocrypto_aes_gcm_ctx *ctx, const uint8_t *key, size_t size, const uint8_t iv[12])
void ocrypto_aes_gcm_final_enc(ocrypto_aes_gcm_ctx *ctx, uint8_t *tag, size_t tag_len)
int ocrypto_aes_gcm_final_dec(ocrypto_aes_gcm_ctx *ctx, const uint8_t *tag, size_t tag_len)
void ocrypto_aes_gcm_update_dec(ocrypto_aes_gcm_ctx *ctx, uint8_t *pt, const uint8_t *ct, size_t ct_len)
void ocrypto_aes_gcm_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 iv[12], const uint8_t *aa, size_t aa_len)
int ocrypto_aes_gcm_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 iv[12], const uint8_t *aa, size_t aa_len)
void ocrypto_aes_gcm_init_iv(ocrypto_aes_gcm_ctx *ctx, const uint8_t *iv, size_t iv_len)