Mbed TLS v3.6.3
Loading...
Searching...
No Matches
crypto_builtin_composites.h
Go to the documentation of this file.
1/*
2 * Context structure declaration of the Mbed TLS software-based PSA drivers
3 * called through the PSA Crypto driver dispatch layer.
4 * This file contains the context structures of those algorithms which need to
5 * rely on other algorithms, i.e. are 'composite' algorithms.
6 *
7 * \note This file may not be included directly. Applications must
8 * include psa/crypto.h.
9 *
10 * \note This header and its content are not part of the Mbed TLS API and
11 * applications must not depend on it. Its main purpose is to define the
12 * multi-part state objects of the Mbed TLS software-based PSA drivers. The
13 * definitions of these objects are then used by crypto_struct.h to define the
14 * implementation-defined types of PSA multi-part state objects.
15 */
16/*
17 * Copyright The Mbed TLS Contributors
18 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
19 */
20
21#ifndef PSA_CRYPTO_BUILTIN_COMPOSITES_H
22#define PSA_CRYPTO_BUILTIN_COMPOSITES_H
24
26
27#include "mbedtls/cmac.h"
28#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
29#include "mbedtls/gcm.h"
30#endif
31#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM)
32#include "mbedtls/ccm.h"
33#endif
34#include "mbedtls/chachapoly.h"
35
36/*
37 * MAC multi-part operation definitions.
38 */
39#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || \
40 defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC)
41#define MBEDTLS_PSA_BUILTIN_MAC
42#endif
43
44#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
45typedef struct {
49 struct psa_hash_operation_s hash_ctx;
53
54#define MBEDTLS_PSA_HMAC_OPERATION_INIT { 0, PSA_HASH_OPERATION_INIT, { 0 } }
55#endif /* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
56
57typedef struct {
59 union {
60 unsigned MBEDTLS_PRIVATE(dummy); /* Make the union non-empty even with no supported algorithms. */
61#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
63#endif /* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
64#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
66#endif /* MBEDTLS_PSA_BUILTIN_ALG_CMAC */
69
70#define MBEDTLS_PSA_MAC_OPERATION_INIT { 0, { 0 } }
71
72#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) || \
73 defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) || \
74 defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
75#define MBEDTLS_PSA_BUILTIN_AEAD 1
76#endif
77
78/* Context structure for the Mbed TLS AEAD implementation. */
79typedef struct {
82
83 unsigned int MBEDTLS_PRIVATE(is_encrypt) : 1;
84
85 uint8_t MBEDTLS_PRIVATE(tag_length);
86
87 union {
88 unsigned dummy; /* Enable easier initializing of the union. */
89#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM)
91#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */
92#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
94#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */
95#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
97#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
98
99 } ctx;
100
102
103#define MBEDTLS_PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
104
105#include "mbedtls/ecdsa.h"
106
107/* Context structure for the Mbed TLS interruptible sign hash implementation. */
108typedef struct {
109#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
110 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
111 defined(MBEDTLS_ECP_RESTARTABLE)
114
115 uint32_t MBEDTLS_PRIVATE(num_ops);
116
117 size_t MBEDTLS_PRIVATE(coordinate_bytes);
121 size_t MBEDTLS_PRIVATE(hash_length);
122
123#else
124 /* Make the struct non-empty if algs not supported. */
125 unsigned MBEDTLS_PRIVATE(dummy);
126
127#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
128 * defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
129 * defined( MBEDTLS_ECP_RESTARTABLE ) */
131
132#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
133 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
134 defined(MBEDTLS_ECP_RESTARTABLE)
135#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 }
136#else
137#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
138#endif
139
140/* Context structure for the Mbed TLS interruptible verify hash
141 * implementation.*/
142typedef struct {
143#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
144 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
145 defined(MBEDTLS_ECP_RESTARTABLE)
146
149
150 uint32_t MBEDTLS_PRIVATE(num_ops);
151
153 size_t MBEDTLS_PRIVATE(hash_length);
154
157
158#else
159 /* Make the struct non-empty if algs not supported. */
160 unsigned MBEDTLS_PRIVATE(dummy);
161
162#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
163 * defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
164 * defined( MBEDTLS_ECP_RESTARTABLE ) */
165
167
168#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
169 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
170 defined(MBEDTLS_ECP_RESTARTABLE)
171#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, \
172 { 0 } }
173#else
174#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
175#endif
176
177
178/* EC-JPAKE operation definitions */
179
180#include "mbedtls/ecjpake.h"
181
182#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
183#define MBEDTLS_PSA_BUILTIN_PAKE 1
184#endif
185
186/* Note: the format for mbedtls_ecjpake_read/write function has an extra
187 * length byte for each step, plus an extra 3 bytes for ECParameters in the
188 * server's 2nd round. */
189#define MBEDTLS_PSA_JPAKE_BUFFER_SIZE ((3 + 1 + 65 + 1 + 65 + 1 + 32) * 2)
190
191typedef struct {
193
194 uint8_t *MBEDTLS_PRIVATE(password);
195 size_t MBEDTLS_PRIVATE(password_len);
196#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
199 size_t MBEDTLS_PRIVATE(buffer_length);
200 size_t MBEDTLS_PRIVATE(buffer_offset);
201#endif
202 /* Context structure for the Mbed TLS EC-JPAKE implementation. */
203 union {
204 unsigned int MBEDTLS_PRIVATE(dummy);
205#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
207#endif
209
211
212#define MBEDTLS_PSA_PAKE_OPERATION_INIT { { 0 } }
213
214#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
This file provides an API for the CCM authenticated encryption mode for block ciphers.
This file contains the AEAD-ChaCha20-Poly1305 definitions and functions.
This file contains CMAC definitions and functions.
#define MBEDTLS_PSA_JPAKE_BUFFER_SIZE
Definitions for all PSA crypto drivers.
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE
Definition: crypto_sizes.h:122
#define PSA_VENDOR_ECC_MAX_CURVE_BITS
Definition: crypto_sizes.h:245
#define PSA_BITS_TO_BYTES(bits)
Definition: crypto_sizes.h:40
This file contains ECDSA definitions and functions.
void mbedtls_ecdsa_restart_ctx
Definition: ecdsa.h:111
Elliptic curve J-PAKE.
mbedtls_ecjpake_role
Definition: ecjpake.h:42
This file contains GCM definitions and functions.
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:78
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:134
mbedtls_md_type_t
Supported message digests.
Definition: md.h:47
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
The CCM context-type definition. The CCM context is passed to the APIs called.
Definition: ccm.h:69
The ECP key-pair structure.
Definition: ecp.h:428
The GCM context structure.
Definition: gcm.h:58
MPI structure.
Definition: bignum.h:207