Mbed TLS v3.6.3
crypto_builtin_primitives.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 do not
5  * rely on other algorithms, i.e. are 'primitive' 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_PRIMITIVES_H
22 #define PSA_CRYPTO_BUILTIN_PRIMITIVES_H
23 #include "mbedtls/private_access.h"
24 
26 
27 /*
28  * Hash multi-part operation definitions.
29  */
30 
31 #include "mbedtls/md5.h"
32 #include "mbedtls/ripemd160.h"
33 #include "mbedtls/sha1.h"
34 #include "mbedtls/sha256.h"
35 #include "mbedtls/sha512.h"
36 #include "mbedtls/sha3.h"
37 
38 #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5) || \
39  defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160) || \
40  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1) || \
41  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224) || \
42  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) || \
43  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384) || \
44  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512) || \
45  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_224) || \
46  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_256) || \
47  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_384) || \
48  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_512)
49 #define MBEDTLS_PSA_BUILTIN_HASH
50 #endif
51 
52 typedef struct {
54  union {
55  unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
56 #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
58 #endif
59 #if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
61 #endif
62 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
64 #endif
65 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) || \
66  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
68 #endif
69 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512) || \
70  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
72 #endif
73 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_224) || \
74  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_256) || \
75  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_384) || \
76  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA3_512)
78 #endif
81 
82 #define MBEDTLS_PSA_HASH_OPERATION_INIT { 0, { 0 } }
83 
84 /*
85  * Cipher multi-part operation definitions.
86  */
87 
88 #include "mbedtls/cipher.h"
89 
90 #if defined(MBEDTLS_PSA_BUILTIN_ALG_STREAM_CIPHER) || \
91  defined(MBEDTLS_PSA_BUILTIN_ALG_CTR) || \
92  defined(MBEDTLS_PSA_BUILTIN_ALG_CFB) || \
93  defined(MBEDTLS_PSA_BUILTIN_ALG_OFB) || \
94  defined(MBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING) || \
95  defined(MBEDTLS_PSA_BUILTIN_ALG_CBC_NO_PADDING) || \
96  defined(MBEDTLS_PSA_BUILTIN_ALG_CBC_PKCS7) || \
97  defined(MBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG)
98 #define MBEDTLS_PSA_BUILTIN_CIPHER 1
99 #endif
100 
101 typedef struct {
102  /* Context structure for the Mbed TLS cipher implementation. */
104  uint8_t MBEDTLS_PRIVATE(iv_length);
105  uint8_t MBEDTLS_PRIVATE(block_length);
106  union {
107  unsigned int MBEDTLS_PRIVATE(dummy);
111 
112 #define MBEDTLS_PSA_CIPHER_OPERATION_INIT { 0, 0, 0, { 0 } }
113 
114 #endif /* PSA_CRYPTO_BUILTIN_PRIMITIVES_H */
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
Definitions for all PSA crypto drivers.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:134
MD5 message digest algorithm (hash function)
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
RIPE MD-160 message digest.
This file contains SHA-1 definitions and functions.
This file contains SHA-224 and SHA-256 definitions and functions.
This file contains SHA-3 definitions and functions.
This file contains SHA-384 and SHA-512 definitions and functions.
MD5 context structure.
Definition: md5.h:39
mbedtls_ripemd160_context ripemd160
RIPEMD-160 context structure.
Definition: ripemd160.h:30
The SHA-1 context structure.
Definition: sha1.h:45
The SHA-256 context structure.
Definition: sha256.h:40
The SHA-3 context structure.
Definition: sha3.h:50
The SHA-512 context structure.
Definition: sha512.h:39