Mbed TLS v3.5.0
include
psa
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
19
*
20
* Licensed under the Apache License, Version 2.0 (the "License"); you may
21
* not use this file except in compliance with the License.
22
* You may obtain a copy of the License at
23
*
24
* http://www.apache.org/licenses/LICENSE-2.0
25
*
26
* Unless required by applicable law or agreed to in writing, software
27
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
* See the License for the specific language governing permissions and
30
* limitations under the License.
31
*/
32
33
#ifndef PSA_CRYPTO_BUILTIN_COMPOSITES_H
34
#define PSA_CRYPTO_BUILTIN_COMPOSITES_H
35
#include "
mbedtls/private_access.h
"
36
37
#include <
psa/crypto_driver_common.h
>
38
39
#include "
mbedtls/cmac.h
"
40
#include "
mbedtls/gcm.h
"
41
#include "
mbedtls/ccm.h
"
42
#include "
mbedtls/chachapoly.h
"
43
44
/*
45
* MAC multi-part operation definitions.
46
*/
47
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || \
48
defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC)
49
#define MBEDTLS_PSA_BUILTIN_MAC
50
#endif
51
52
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
53
typedef
struct
{
55
psa_algorithm_t
MBEDTLS_PRIVATE
(alg);
57
struct
psa_hash_operation_s
hash_ctx;
59
uint8_t
MBEDTLS_PRIVATE
(opad)[
PSA_HMAC_MAX_HASH_BLOCK_SIZE
];
60
}
mbedtls_psa_hmac_operation_t
;
61
62
#define MBEDTLS_PSA_HMAC_OPERATION_INIT { 0, PSA_HASH_OPERATION_INIT, { 0 } }
63
#endif
/* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
64
65
typedef
struct
{
66
psa_algorithm_t
MBEDTLS_PRIVATE
(alg);
67
union
{
68
unsigned
MBEDTLS_PRIVATE
(dummy);
/* Make the union non-empty even with no supported algorithms. */
69
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
70
mbedtls_psa_hmac_operation_t
MBEDTLS_PRIVATE
(hmac);
71
#endif
/* MBEDTLS_PSA_BUILTIN_ALG_HMAC */
72
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || defined(PSA_CRYPTO_DRIVER_TEST)
73
mbedtls_cipher_context_t
MBEDTLS_PRIVATE
(cmac);
74
#endif
/* MBEDTLS_PSA_BUILTIN_ALG_CMAC */
75
}
MBEDTLS_PRIVATE
(ctx);
76
}
mbedtls_psa_mac_operation_t
;
77
78
#define MBEDTLS_PSA_MAC_OPERATION_INIT { 0, { 0 } }
79
80
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) || \
81
defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) || \
82
defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
83
#define MBEDTLS_PSA_BUILTIN_AEAD 1
84
#endif
85
86
/* Context structure for the Mbed TLS AEAD implementation. */
87
typedef
struct
{
88
psa_algorithm_t
MBEDTLS_PRIVATE
(alg);
89
psa_key_type_t
MBEDTLS_PRIVATE
(key_type);
90
91
unsigned
int
MBEDTLS_PRIVATE
(is_encrypt) : 1;
92
93
uint8_t
MBEDTLS_PRIVATE
(tag_length);
94
95
union
{
96
unsigned
dummy
;
/* Enable easier initializing of the union. */
97
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM)
98
mbedtls_ccm_context
MBEDTLS_PRIVATE
(ccm);
99
#endif
/* MBEDTLS_PSA_BUILTIN_ALG_CCM */
100
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
101
mbedtls_gcm_context
MBEDTLS_PRIVATE
(gcm);
102
#endif
/* MBEDTLS_PSA_BUILTIN_ALG_GCM */
103
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
104
mbedtls_chachapoly_context
MBEDTLS_PRIVATE
(chachapoly);
105
#endif
/* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
106
107
} ctx;
108
109
}
mbedtls_psa_aead_operation_t
;
110
111
#define MBEDTLS_PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
112
113
#include "
mbedtls/ecdsa.h
"
114
115
/* Context structure for the Mbed TLS interruptible sign hash implementation. */
116
typedef
struct
{
117
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
118
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
119
defined(MBEDTLS_ECP_RESTARTABLE)
120
mbedtls_ecdsa_context
*
MBEDTLS_PRIVATE
(ctx);
121
mbedtls_ecdsa_restart_ctx
MBEDTLS_PRIVATE
(restart_ctx);
122
123
uint32_t
MBEDTLS_PRIVATE
(num_ops);
124
125
size_t
MBEDTLS_PRIVATE
(coordinate_bytes);
126
psa_algorithm_t
MBEDTLS_PRIVATE
(alg);
127
mbedtls_md_type_t
MBEDTLS_PRIVATE
(md_alg);
128
uint8_t
MBEDTLS_PRIVATE
(hash)[
PSA_BITS_TO_BYTES
(
PSA_VENDOR_ECC_MAX_CURVE_BITS
)];
129
size_t
MBEDTLS_PRIVATE
(hash_length);
130
131
#else
132
/* Make the struct non-empty if algs not supported. */
133
unsigned
MBEDTLS_PRIVATE
(dummy);
134
135
#endif
/* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
136
* defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
137
* defined( MBEDTLS_ECP_RESTARTABLE ) */
138
}
mbedtls_psa_sign_hash_interruptible_operation_t
;
139
140
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
141
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
142
defined(MBEDTLS_ECP_RESTARTABLE)
143
#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 }
144
#else
145
#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
146
#endif
147
148
/* Context structure for the Mbed TLS interruptible verify hash
149
* implementation.*/
150
typedef
struct
{
151
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
152
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
153
defined(MBEDTLS_ECP_RESTARTABLE)
154
155
mbedtls_ecdsa_context
*
MBEDTLS_PRIVATE
(ctx);
156
mbedtls_ecdsa_restart_ctx
MBEDTLS_PRIVATE
(restart_ctx);
157
158
uint32_t
MBEDTLS_PRIVATE
(num_ops);
159
160
uint8_t
MBEDTLS_PRIVATE
(hash)[
PSA_BITS_TO_BYTES
(
PSA_VENDOR_ECC_MAX_CURVE_BITS
)];
161
size_t
MBEDTLS_PRIVATE
(hash_length);
162
163
mbedtls_mpi
MBEDTLS_PRIVATE
(r);
164
mbedtls_mpi
MBEDTLS_PRIVATE
(s);
165
166
#else
167
/* Make the struct non-empty if algs not supported. */
168
unsigned
MBEDTLS_PRIVATE
(dummy);
169
170
#endif
/* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
171
* defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
172
* defined( MBEDTLS_ECP_RESTARTABLE ) */
173
174
}
mbedtls_psa_verify_hash_interruptible_operation_t
;
175
176
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
177
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
178
defined(MBEDTLS_ECP_RESTARTABLE)
179
#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, \
180
{ 0 } }
181
#else
182
#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
183
#endif
184
185
186
/* EC-JPAKE operation definitions */
187
188
#include "
mbedtls/ecjpake.h
"
189
190
#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
191
#define MBEDTLS_PSA_BUILTIN_PAKE 1
192
#endif
193
194
/* Note: the format for mbedtls_ecjpake_read/write function has an extra
195
* length byte for each step, plus an extra 3 bytes for ECParameters in the
196
* server's 2nd round. */
197
#define MBEDTLS_PSA_JPAKE_BUFFER_SIZE ((3 + 1 + 65 + 1 + 65 + 1 + 32) * 2)
198
199
typedef
struct
{
200
psa_algorithm_t
MBEDTLS_PRIVATE
(alg);
201
202
uint8_t *
MBEDTLS_PRIVATE
(password);
203
size_t
MBEDTLS_PRIVATE
(password_len);
204
#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
205
mbedtls_ecjpake_role
MBEDTLS_PRIVATE
(role);
206
uint8_t
MBEDTLS_PRIVATE
(buffer[
MBEDTLS_PSA_JPAKE_BUFFER_SIZE
]);
207
size_t
MBEDTLS_PRIVATE
(buffer_length);
208
size_t
MBEDTLS_PRIVATE
(buffer_offset);
209
#endif
210
/* Context structure for the Mbed TLS EC-JPAKE implementation. */
211
union
{
212
unsigned
int
MBEDTLS_PRIVATE
(dummy);
213
#if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE)
214
mbedtls_ecjpake_context
MBEDTLS_PRIVATE
(jpake);
215
#endif
216
}
MBEDTLS_PRIVATE
(ctx);
217
218
}
mbedtls_psa_pake_operation_t
;
219
220
#define MBEDTLS_PSA_PAKE_OPERATION_INIT { { 0 } }
221
222
#endif
/* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
ccm.h
This file provides an API for the CCM authenticated encryption mode for block ciphers.
chachapoly.h
This file contains the AEAD-ChaCha20-Poly1305 definitions and functions.
cmac.h
This file contains CMAC definitions and functions.
MBEDTLS_PSA_JPAKE_BUFFER_SIZE
#define MBEDTLS_PSA_JPAKE_BUFFER_SIZE
Definition:
crypto_builtin_composites.h:197
crypto_driver_common.h
Definitions for all PSA crypto drivers.
PSA_HMAC_MAX_HASH_BLOCK_SIZE
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE
Definition:
crypto_sizes.h:134
PSA_VENDOR_ECC_MAX_CURVE_BITS
#define PSA_VENDOR_ECC_MAX_CURVE_BITS
Definition:
crypto_sizes.h:247
PSA_BITS_TO_BYTES
#define PSA_BITS_TO_BYTES(bits)
Definition:
crypto_sizes.h:52
ecdsa.h
This file contains ECDSA definitions and functions.
mbedtls_ecdsa_restart_ctx
void mbedtls_ecdsa_restart_ctx
Definition:
ecdsa.h:123
ecjpake.h
Elliptic curve J-PAKE.
mbedtls_ecjpake_role
mbedtls_ecjpake_role
Definition:
ecjpake.h:54
gcm.h
This file contains GCM definitions and functions.
psa_key_type_t
uint16_t psa_key_type_t
Encoding of a key type.
Definition:
crypto_types.h:83
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition:
crypto_types.h:139
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition:
md.h:173
private_access.h
Macro wrapper for struct's members.
MBEDTLS_PRIVATE
#define MBEDTLS_PRIVATE(member)
Definition:
private_access.h:27
mbedtls_ccm_context
The CCM context-type definition. The CCM context is passed to the APIs called.
Definition:
ccm.h:77
mbedtls_chachapoly_context
Definition:
chachapoly.h:60
mbedtls_cipher_context_t
Definition:
cipher.h:328
mbedtls_ecjpake_context
Definition:
ecjpake.h:72
mbedtls_ecp_keypair
The ECP key-pair structure.
Definition:
ecp.h:439
mbedtls_gcm_context
The GCM context structure.
Definition:
gcm.h:60
mbedtls_mpi
MPI structure.
Definition:
bignum.h:219
mbedtls_psa_aead_operation_t
Definition:
crypto_builtin_composites.h:87
mbedtls_psa_aead_operation_t::dummy
unsigned dummy
Definition:
crypto_builtin_composites.h:96
mbedtls_psa_hmac_operation_t
Definition:
crypto_builtin_composites.h:53
mbedtls_psa_mac_operation_t
Definition:
crypto_builtin_composites.h:65
mbedtls_psa_pake_operation_t
Definition:
crypto_builtin_composites.h:199
mbedtls_psa_sign_hash_interruptible_operation_t
Definition:
crypto_builtin_composites.h:116
mbedtls_psa_verify_hash_interruptible_operation_t
Definition:
crypto_builtin_composites.h:150
psa_hash_operation_s
Definition:
crypto_struct.h:77
Generated on Mon Oct 9 2023 14:50:50 for Mbed TLS v3.5.0 by
1.9.4