Mbed TLS v2.28.8
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 is 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  * definition 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 
25 
26 /*
27  * Hash multi-part operation definitions.
28  */
29 
30 #include "mbedtls/md2.h"
31 #include "mbedtls/md4.h"
32 #include "mbedtls/md5.h"
33 #include "mbedtls/ripemd160.h"
34 #include "mbedtls/sha1.h"
35 #include "mbedtls/sha256.h"
36 #include "mbedtls/sha512.h"
37 
38 #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD2) || \
39  defined(MBEDTLS_PSA_BUILTIN_ALG_MD4) || \
40  defined(MBEDTLS_PSA_BUILTIN_ALG_MD5) || \
41  defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160) || \
42  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1) || \
43  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224) || \
44  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) || \
45  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384) || \
46  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512)
47 #define MBEDTLS_PSA_BUILTIN_HASH
48 #endif
49 
50 typedef struct {
52  union {
53  unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
54 #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD2)
56 #endif
57 #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD4)
59 #endif
60 #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
62 #endif
63 #if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
65 #endif
66 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
68 #endif
69 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) || \
70  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
72 #endif
73 #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512) || \
74  defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
76 #endif
77  } ctx;
79 
80 #define MBEDTLS_PSA_HASH_OPERATION_INIT { 0, { 0 } }
81 
82 /*
83  * Cipher multi-part operation definitions.
84  */
85 
86 #include "mbedtls/cipher.h"
87 
88 #if defined(MBEDTLS_PSA_BUILTIN_ALG_STREAM_CIPHER) || \
89  defined(MBEDTLS_PSA_BUILTIN_ALG_CTR) || \
90  defined(MBEDTLS_PSA_BUILTIN_ALG_CFB) || \
91  defined(MBEDTLS_PSA_BUILTIN_ALG_OFB) || \
92  defined(MBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING) || \
93  defined(MBEDTLS_PSA_BUILTIN_ALG_CBC_NO_PADDING) || \
94  defined(MBEDTLS_PSA_BUILTIN_ALG_CBC_PKCS7)
95 #define MBEDTLS_PSA_BUILTIN_CIPHER 1
96 #endif
97 
98 typedef struct {
99  /* Context structure for the Mbed TLS cipher implementation. */
101  uint8_t iv_length;
102  uint8_t block_length;
103  union {
104  unsigned int dummy;
106  } ctx;
108 
109 #define MBEDTLS_PSA_CIPHER_OPERATION_INIT { 0, 0, 0, { 0 } }
110 
111 #endif /* PSA_CRYPTO_BUILTIN_PRIMITIVES_H */
mbedtls_sha1_context
The SHA-1 context structure.
Definition: sha1.h:51
mbedtls_md5_context
MD5 context structure.
Definition: md5.h:46
mbedtls_psa_hash_operation_t::md4
mbedtls_md4_context md4
Definition: crypto_builtin_primitives.h:58
crypto_driver_common.h
Definitions for all PSA crypto drivers.
mbedtls_psa_hash_operation_t::md2
mbedtls_md2_context md2
Definition: crypto_builtin_primitives.h:55
sha1.h
This file contains SHA-1 definitions and functions.
sha512.h
This file contains SHA-384 and SHA-512 definitions and functions.
mbedtls_psa_hash_operation_t::dummy
unsigned dummy
Definition: crypto_builtin_primitives.h:53
mbedtls_psa_cipher_operation_t::alg
psa_algorithm_t alg
Definition: crypto_builtin_primitives.h:100
mbedtls_ripemd160_context
RIPEMD-160 context structure.
Definition: ripemd160.h:38
mbedtls_psa_cipher_operation_t::cipher
mbedtls_cipher_context_t cipher
Definition: crypto_builtin_primitives.h:105
mbedtls_psa_cipher_operation_t::iv_length
uint8_t iv_length
Definition: crypto_builtin_primitives.h:101
mbedtls_psa_hash_operation_t::sha256
mbedtls_sha256_context sha256
Definition: crypto_builtin_primitives.h:71
mbedtls_psa_hash_operation_t::alg
psa_algorithm_t alg
Definition: crypto_builtin_primitives.h:51
mbedtls_psa_hash_operation_t::sha512
mbedtls_sha512_context sha512
Definition: crypto_builtin_primitives.h:75
mbedtls_psa_cipher_operation_t::dummy
unsigned int dummy
Definition: crypto_builtin_primitives.h:104
mbedtls_psa_cipher_operation_t
Definition: crypto_builtin_primitives.h:98
mbedtls_sha512_context
The SHA-512 context structure.
Definition: sha512.h:45
cipher.h
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
mbedtls_psa_hash_operation_t
Definition: crypto_builtin_primitives.h:50
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:125
ripemd160.h
RIPE MD-160 message digest.
sha256.h
This file contains SHA-224 and SHA-256 definitions and functions.
md4.h
MD4 message digest algorithm (hash function)
md5.h
MD5 message digest algorithm (hash function)
md2.h
MD2 message digest algorithm (hash function)
mbedtls_psa_cipher_operation_t::block_length
uint8_t block_length
Definition: crypto_builtin_primitives.h:102
mbedtls_sha256_context
The SHA-256 context structure.
Definition: sha256.h:46
mbedtls_cipher_context_t
Definition: cipher.h:305
mbedtls_psa_hash_operation_t::ripemd160
mbedtls_ripemd160_context ripemd160
Definition: crypto_builtin_primitives.h:64
mbedtls_psa_hash_operation_t::md5
mbedtls_md5_context md5
Definition: crypto_builtin_primitives.h:61
mbedtls_psa_hash_operation_t::sha1
mbedtls_sha1_context sha1
Definition: crypto_builtin_primitives.h:67
mbedtls_md2_context
MD2 context structure.
Definition: md2.h:46
mbedtls_md4_context
MD4 context structure.
Definition: md4.h:47