Mbed TLS v3.5.2
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#include "mbedtls/gcm.h"
29#include "mbedtls/ccm.h"
30#include "mbedtls/chachapoly.h"
31
32/*
33 * MAC multi-part operation definitions.
34 */
35#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || \
36 defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC)
37#define MBEDTLS_PSA_BUILTIN_MAC
38#endif
39
40#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
49
50#define MBEDTLS_PSA_HMAC_OPERATION_INIT { 0, PSA_HASH_OPERATION_INIT, { 0 } }
51#endif /* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
52
53typedef struct {
55 union {
56 unsigned MBEDTLS_PRIVATE(dummy); /* Make the union non-empty even with no supported algorithms. */
57#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
59#endif /* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
60#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
62#endif /* MBEDTLS_PSA_BUILTIN_ALG_CMAC */
65
66#define MBEDTLS_PSA_MAC_OPERATION_INIT { 0, { 0 } }
67
68#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) || \
69 defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) || \
70 defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
71#define MBEDTLS_PSA_BUILTIN_AEAD 1
72#endif
73
74/* Context structure for the Mbed TLS AEAD implementation. */
75typedef struct {
78
79 unsigned int MBEDTLS_PRIVATE(is_encrypt) : 1;
80
81 uint8_t MBEDTLS_PRIVATE(tag_length);
82
83 union {
84 unsigned dummy; /* Enable easier initializing of the union. */
85#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM)
87#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */
88#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
90#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */
91#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
93#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
94
95 } ctx;
96
98
99#define MBEDTLS_PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
100
101#include "mbedtls/ecdsa.h"
102
103/* Context structure for the Mbed TLS interruptible sign hash implementation. */
104typedef struct {
105#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
106 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
107 defined(MBEDTLS_ECP_RESTARTABLE)
110
111 uint32_t MBEDTLS_PRIVATE(num_ops);
112
113 size_t MBEDTLS_PRIVATE(coordinate_bytes);
117 size_t MBEDTLS_PRIVATE(hash_length);
118
119#else
120 /* Make the struct non-empty if algs not supported. */
121 unsigned MBEDTLS_PRIVATE(dummy);
122
123#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
124 * defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
125 * defined( MBEDTLS_ECP_RESTARTABLE ) */
127
128#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
129 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
130 defined(MBEDTLS_ECP_RESTARTABLE)
131#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 }
132#else
133#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
134#endif
135
136/* Context structure for the Mbed TLS interruptible verify hash
137 * implementation.*/
138typedef struct {
139#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
140 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
141 defined(MBEDTLS_ECP_RESTARTABLE)
142
145
146 uint32_t MBEDTLS_PRIVATE(num_ops);
147
149 size_t MBEDTLS_PRIVATE(hash_length);
150
153
154#else
155 /* Make the struct non-empty if algs not supported. */
156 unsigned MBEDTLS_PRIVATE(dummy);
157
158#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
159 * defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
160 * defined( MBEDTLS_ECP_RESTARTABLE ) */
161
163
164#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
165 defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
166 defined(MBEDTLS_ECP_RESTARTABLE)
167#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, \
168 { 0 } }
169#else
170#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
171#endif
172
173
174/* EC-JPAKE operation definitions */
175
176#include "mbedtls/ecjpake.h"
177
178#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
179#define MBEDTLS_PSA_BUILTIN_PAKE 1
180#endif
181
182/* Note: the format for mbedtls_ecjpake_read/write function has an extra
183 * length byte for each step, plus an extra 3 bytes for ECParameters in the
184 * server's 2nd round. */
185#define MBEDTLS_PSA_JPAKE_BUFFER_SIZE ((3 + 1 + 65 + 1 + 65 + 1 + 32) * 2)
186
187typedef struct {
189
190 uint8_t *MBEDTLS_PRIVATE(password);
191 size_t MBEDTLS_PRIVATE(password_len);
192#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
195 size_t MBEDTLS_PRIVATE(buffer_length);
196 size_t MBEDTLS_PRIVATE(buffer_offset);
197#endif
198 /* Context structure for the Mbed TLS EC-JPAKE implementation. */
199 union {
200 unsigned int MBEDTLS_PRIVATE(dummy);
201#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
203#endif
205
207
208#define MBEDTLS_PSA_PAKE_OPERATION_INIT { { 0 } }
209
210#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
#define PSA_VENDOR_ECC_MAX_CURVE_BITS
#define PSA_BITS_TO_BYTES(bits)
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.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
mbedtls_md_type_t
Supported message digests.
Definition md.h:161
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:65
The ECP key-pair structure.
Definition ecp.h:427
The GCM context structure.
Definition gcm.h:48
MPI structure.
Definition bignum.h:207