Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 TU Dresden
3 * Copyright (C) 2021 HAW Hamburg
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
10#pragma once
11
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include "crypto/psa/riot_ciphers.h"
29#include "kernel_defines.h"
30#include "psa/algorithm.h"
31
32#if IS_USED(MODULE_PERIPH_CIPHER_AES_128_CBC)
33#include "psa_periph_aes_ctx.h"
34#endif
35
36#if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A)
37#include "atca_params.h"
38#endif
39
44typedef enum {
45 PSA_CRYPTO_DRIVER_DECRYPT,
46 PSA_CRYPTO_DRIVER_ENCRYPT
48
52typedef union {
53#if IS_USED(MODULE_PSA_CIPHER_AES_128_ECB) ||\
54 IS_USED(MODULE_PSA_CIPHER_AES_128_CBC) ||\
55 defined(DOXYGEN)
57#endif
58#if IS_USED(MODULE_PSA_CIPHER_AES_192_CBC) || defined(DOXYGEN)
59 psa_cipher_aes_192_ctx_t aes_192;
60#endif
61#if IS_USED(MODULE_PSA_CIPHER_AES_256_CBC) || defined(DOXYGEN)
62 psa_cipher_aes_256_ctx_t aes_256;
63#endif
65
70typedef struct {
74 unsigned dummy;
75 #if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A) || defined(DOXYGEN)
76 atca_aes_cbc_ctx_t atca_aes_cbc;
77 #endif
78 } drv_ctx;
80
85 uint8_t iv_required : 1;
86 uint8_t iv_set : 1;
92#if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A) || defined(DOXYGEN)
94#endif
96};
97
129
134#define PSA_CIPHER_OPERATION_INIT { 0 }
135
142{
144
145 return v;
146}
147
148#ifdef __cplusplus
149}
150#endif
151
Algorithm definitions for the PSA Crypto API.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition algorithm.h:38
Default configuration for Microchip CryptoAuth devices.
Common macros and compiler attributes/pragmas configuration.
CryptoCell 310 driver specific AES contexts.
SaSiAesUserContext_t psa_cipher_aes_128_ctx_t
Map driver specific AES context to PSA context.
Structure storing a cipher operation context.
Definition types.h:84
uint8_t iv_required
True if algorithm requires IV.
Definition types.h:85
psa_algorithm_t alg
Operation algorithm.
Definition types.h:88
uint8_t default_iv_length
Default IV length for algorithm.
Definition types.h:87
union psa_cipher_operation_s::cipher_context backend_ctx
Backend specific cipher context.
uint8_t iv_set
True if IV was already set.
Definition types.h:86
Structure containing the secure element specific cipher contexts needed by the application.
Definition types.h:70
psa_encrypt_or_decrypt_t direction
Direction of this cipher operation.
Definition types.h:71
static psa_cipher_operation_t psa_cipher_operation_init(void)
Return an initial value for a cipher operation object.
Definition types.h:141
struct psa_cipher_operation_s psa_cipher_operation_t
The type of the state object for multi-part cipher operations.
Definition types.h:128
#define PSA_CIPHER_OPERATION_INIT
This macro returns a suitable initializer for a cipher operation object of type psa_cipher_operation_...
Definition types.h:134
psa_encrypt_or_decrypt_t
For encrypt-decrypt functions, whether the operation is an encryption or a decryption.
Definition types.h:44
Structure containing the cipher contexts needed by the application.
Definition types.h:52
psa_cipher_aes_192_ctx_t aes_192
AES 192 context.
Definition types.h:59
psa_cipher_aes_256_ctx_t aes_256
AES 256 context.
Definition types.h:62
psa_cipher_aes_128_ctx_t aes_128
AES 128 context.
Definition types.h:56
Union containing cipher contexts for the executing backend.
Definition types.h:90
psa_cipher_context_t cipher_ctx
Cipher context.
Definition types.h:91
psa_se_cipher_context_t se_ctx
SE Cipher context.
Definition types.h:93
Structure containing a driver specific cipher context.
Definition types.h:73
atca_aes_cbc_ctx_t atca_aes_cbc
ATCA AES CBC context.
Definition types.h:76
unsigned dummy
Make the union non-empty even with no supported algorithms.
Definition types.h:74