crypto_struct.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include "crypto_types.h"
27 #include "crypto_sizes.h"
28 #include "crypto_contexts.h"
29 
30 #if IS_USED(MODULE_PSA_AEAD) || defined(DOXYGEN)
37  int dummy;
38 };
39 
44 #define PSA_AEAD_OPERATION_INIT { 0 }
45 
51 static inline struct psa_aead_operation_s psa_aead_operation_init(void)
52 {
54 
55  return v;
56 }
57 #endif /* MODULE_PSA_AEAD */
58 
59 #if IS_USED(MODULE_PSA_CIPHER) || defined(DOXYGEN)
64  uint8_t iv_required : 1;
65  uint8_t iv_set : 1;
70  psa_cipher_context_t cipher_ctx;
71 #if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A) || defined(DOXYGEN)
72  psa_se_cipher_context_t se_ctx;
73 #endif
75 };
76 
81 #define PSA_CIPHER_OPERATION_INIT { 0 }
82 
88 static inline struct psa_cipher_operation_s psa_cipher_operation_init(void)
89 {
91 
92  return v;
93 }
94 #endif /* MODULE_PSA_CIPHER */
95 
96 #if IS_USED(MODULE_PSA_KEY_DERIVATION) || defined(DOXYGEN)
101 #define PSA_KEY_DERIVATION_OPERATION_INIT { 0 }
102 
109  int dummy;
110 };
111 
118 {
120 
121  return v;
122 }
123 #endif /* MODULE_PSA_KEY_DERIVATION */
124 
125 #if IS_USED(MODULE_PSA_HASH) || defined(DOXYGEN)
131 #if IS_USED(MODULE_PSA_HASH)
132  psa_hash_context_t ctx;
133 #endif
134 };
135 
140 #define PSA_HASH_OPERATION_INIT { 0 }
141 
147 static inline struct psa_hash_operation_s psa_hash_operation_init(void)
148 {
150 
151  return v;
152 }
153 #endif /* MODULE_PSA_HASH */
154 
155 #if IS_USED(MODULE_PSA_MAC) || defined(DOXYGEN)
160 #define PSA_MAC_OPERATION_INIT { 0 }
161 
168  int dummy;
169 };
170 
176 static inline struct psa_mac_operation_s psa_mac_operation_init(void)
177 {
179 
180  return v;
181 }
182 #endif /* MODULE_PSA_MAC */
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: algorithm.h:38
Context definitions for PSA Crypto.
Size definitions for PSA Crypto.
#define PSA_CIPHER_OPERATION_INIT
This macro returns a suitable initializer for a cipher operation object of type psa_cipher_operation_...
Definition: crypto_struct.h:81
#define PSA_MAC_OPERATION_INIT
This macro returns a suitable initializer for a MAC operation object of type psa_mac_operation_t.
static struct psa_aead_operation_s psa_aead_operation_init(void)
Return an initial value for an AEAD operation object.
Definition: crypto_struct.h:51
#define PSA_KEY_DERIVATION_OPERATION_INIT
This macro returns a suitable initializer for a key derivation operation object of type psa_key_deriv...
#define PSA_HASH_OPERATION_INIT
This macro returns a suitable initializer for a hash operation object of type psa_hash_operation_t.
static struct psa_cipher_operation_s psa_cipher_operation_init(void)
Return an initial value for a cipher operation object.
Definition: crypto_struct.h:88
static struct psa_mac_operation_s psa_mac_operation_init(void)
Return an initial value for a MAC operation object.
static struct psa_hash_operation_s psa_hash_operation_init(void)
Return an initial value for a hash operation object.
static struct psa_key_derivation_operation_s psa_key_derivation_operation_init(void)
Return an initial value for a key derivation operation object.
#define PSA_AEAD_OPERATION_INIT
This macro returns a suitable initializer for an AEAD operation object of type psa_aead_operation_t.
Definition: crypto_struct.h:44
Type definitions for PSA Crypto.
Structure storing an AEAD operation context.
Definition: crypto_struct.h:36
int dummy
Not implemented, yet.
Definition: crypto_struct.h:37
Structure storing a cipher operation context.
Definition: crypto_struct.h:63
uint8_t iv_required
True if algorithm requires IV.
Definition: crypto_struct.h:64
psa_algorithm_t alg
Operation algorithm.
Definition: crypto_struct.h:67
uint8_t default_iv_length
Default IV length for algorithm.
Definition: crypto_struct.h:66
union psa_cipher_operation_s::cipher_context backend_ctx
Backend specific cipher context.
uint8_t iv_set
True if IV was already set.
Definition: crypto_struct.h:65
Structure containing a hash context and algorithm.
psa_algorithm_t alg
Operation algorithm.
Structure storing a key derivation context.
int dummy
Not implemented yet.
Structure storing a MAC operation context.
int dummy
Not yet implemented.
Union containing cipher contexts for the executing backend.
Definition: crypto_struct.h:69
psa_cipher_context_t cipher_ctx
Cipher context.
Definition: crypto_struct.h:70
psa_se_cipher_context_t se_ctx
SE Cipher context.
Definition: crypto_struct.h:72