mbed TLS v2.23.0: crypto_compat.h Source File

mbed TLS v2.23.0

crypto_compat.h
Go to the documentation of this file.
1
13 /*
14 * Copyright (C) 2019, ARM Limited, All Rights Reserved
15 * SPDX-License-Identifier: Apache-2.0
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License"); you may
18 * not use this file except in compliance with the License.
19 * You may obtain a copy of the License at
20 *
21 * http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 *
29 * This file is part of mbed TLS (https://tls.mbed.org)
30 */
31
32 #ifndef PSA_CRYPTO_COMPAT_H
33 #define PSA_CRYPTO_COMPAT_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
40
41 /*
42 * Mechanism for declaring deprecated values
43 */
44 #if defined(MBEDTLS_DEPRECATED_WARNING) && !defined(MBEDTLS_PSA_DEPRECATED)
45 #define MBEDTLS_PSA_DEPRECATED __attribute__((deprecated))
46 #else
47 #define MBEDTLS_PSA_DEPRECATED
48 #endif
49
50 typedef MBEDTLS_PSA_DEPRECATED size_t mbedtls_deprecated_size_t;
51 typedef MBEDTLS_PSA_DEPRECATED psa_status_t mbedtls_deprecated_psa_status_t;
52 typedef MBEDTLS_PSA_DEPRECATED psa_key_usage_t mbedtls_deprecated_psa_key_usage_t;
53 typedef MBEDTLS_PSA_DEPRECATED psa_ecc_curve_t mbedtls_deprecated_psa_ecc_curve_t;
54 typedef MBEDTLS_PSA_DEPRECATED psa_dh_group_t mbedtls_deprecated_psa_dh_group_t;
55
56 #define MBEDTLS_DEPRECATED_CONSTANT( type, value ) \
57 ( (mbedtls_deprecated_##type) ( value ) )
58
59 /*
60 * Deprecated PSA Crypto error code definitions (PSA Crypto API <= 1.0 beta2)
61 */
62 #define PSA_ERROR_UNKNOWN_ERROR \
63 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_GENERIC_ERROR )
64 #define PSA_ERROR_OCCUPIED_SLOT \
65 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_ALREADY_EXISTS )
66 #define PSA_ERROR_EMPTY_SLOT \
67 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_DOES_NOT_EXIST )
68 #define PSA_ERROR_INSUFFICIENT_CAPACITY \
69 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_INSUFFICIENT_DATA )
70 #define PSA_ERROR_TAMPERING_DETECTED \
71 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_CORRUPTION_DETECTED )
72
73 /*
74 * Deprecated PSA Crypto numerical encodings (PSA Crypto API <= 1.0 beta3)
75 */
76 #define PSA_KEY_USAGE_SIGN \
77 MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_SIGN_HASH )
78 #define PSA_KEY_USAGE_VERIFY \
79 MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_VERIFY_HASH )
80
81 /*
82 * Deprecated PSA Crypto size calculation macros (PSA Crypto API <= 1.0 beta3)
83 */
84 #define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \
85 MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGNATURE_MAX_SIZE )
86 #define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) \
87 MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) )
88
89 /*
90 * Deprecated PSA Crypto function names (PSA Crypto API <= 1.0 beta3)
91 */
92 MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_sign( psa_key_handle_t key,
93 psa_algorithm_t alg,
94 const uint8_t *hash,
95 size_t hash_length,
96 uint8_t *signature,
97 size_t signature_size,
98 size_t *signature_length )
99 {
100 return psa_sign_hash( key, alg, hash, hash_length, signature, signature_size, signature_length );
101 }
102
103 MBEDTLS_PSA_DEPRECATED static inline psa_status_t psa_asymmetric_verify( psa_key_handle_t key,
104 psa_algorithm_t alg,
105 const uint8_t *hash,
106 size_t hash_length,
107 const uint8_t *signature,
108 size_t signature_length )
109 {
110 return psa_verify_hash( key, alg, hash, hash_length, signature, signature_length );
111 }
112
113
114
115 #endif /* MBEDTLS_DEPRECATED_REMOVED */
116
117 /*
118 * Size-specific elliptic curve and Diffie-Hellman group names
119 */
120 #define PSA_ECC_CURVE_SECP160K1 \
121 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 )
122 #define PSA_ECC_CURVE_SECP192K1 \
123 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 )
124 #define PSA_ECC_CURVE_SECP224K1 \
125 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 )
126 #define PSA_ECC_CURVE_SECP256K1 \
127 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 )
128 #define PSA_ECC_CURVE_SECP160R1 \
129 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 )
130 #define PSA_ECC_CURVE_SECP192R1 \
131 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 )
132 #define PSA_ECC_CURVE_SECP224R1 \
133 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 )
134 #define PSA_ECC_CURVE_SECP256R1 \
135 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 )
136 #define PSA_ECC_CURVE_SECP384R1 \
137 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 )
138 #define PSA_ECC_CURVE_SECP521R1 \
139 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 )
140 #define PSA_ECC_CURVE_SECP160R2 \
141 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R2 )
142 #define PSA_ECC_CURVE_SECT163K1 \
143 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 )
144 #define PSA_ECC_CURVE_SECT233K1 \
145 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 )
146 #define PSA_ECC_CURVE_SECT239K1 \
147 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 )
148 #define PSA_ECC_CURVE_SECT283K1 \
149 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 )
150 #define PSA_ECC_CURVE_SECT409K1 \
151 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 )
152 #define PSA_ECC_CURVE_SECT571K1 \
153 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 )
154 #define PSA_ECC_CURVE_SECT163R1 \
155 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 )
156 #define PSA_ECC_CURVE_SECT193R1 \
157 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 )
158 #define PSA_ECC_CURVE_SECT233R1 \
159 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 )
160 #define PSA_ECC_CURVE_SECT283R1 \
161 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 )
162 #define PSA_ECC_CURVE_SECT409R1 \
163 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 )
164 #define PSA_ECC_CURVE_SECT571R1 \
165 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 )
166 #define PSA_ECC_CURVE_SECT163R2 \
167 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R2 )
168 #define PSA_ECC_CURVE_SECT193R2 \
169 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R2 )
170 #define PSA_ECC_CURVE_BRAINPOOL_P256R1 \
171 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_BRAINPOOL_P_R1 )
172 #define PSA_ECC_CURVE_BRAINPOOL_P384R1 \
173 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_BRAINPOOL_P_R1 )
174 #define PSA_ECC_CURVE_BRAINPOOL_P512R1 \
175 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_BRAINPOOL_P_R1 )
176 #define PSA_ECC_CURVE_CURVE25519 \
177 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_MONTGOMERY )
178 #define PSA_ECC_CURVE_CURVE448 \
179 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_MONTGOMERY )
180
181 #define PSA_DH_GROUP_FFDHE2048 \
182 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 )
183 #define PSA_DH_GROUP_FFDHE3072 \
184 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 )
185 #define PSA_DH_GROUP_FFDHE4096 \
186 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 )
187 #define PSA_DH_GROUP_FFDHE6144 \
188 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 )
189 #define PSA_DH_GROUP_FFDHE8192 \
190 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 )
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif /* PSA_CRYPTO_COMPAT_H */
MBEDTLS_PSA_DEPRECATED
#define MBEDTLS_PSA_DEPRECATED
Definition: crypto_compat.h:47
psa_status_t
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:55
psa_ecc_curve_t
uint8_t psa_ecc_curve_t
Definition: crypto_types.h:77
mbedtls_deprecated_psa_ecc_curve_t
MBEDTLS_PSA_DEPRECATED psa_ecc_curve_t mbedtls_deprecated_psa_ecc_curve_t
Definition: crypto_compat.h:53
mbedtls_deprecated_size_t
MBEDTLS_PSA_DEPRECATED size_t mbedtls_deprecated_size_t
Definition: crypto_compat.h:50
psa_sign_hash
psa_status_t psa_sign_hash(psa_key_handle_t handle, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
Sign a hash or short message with a private key.
mbedtls_deprecated_psa_status_t
MBEDTLS_PSA_DEPRECATED psa_status_t mbedtls_deprecated_psa_status_t
Definition: crypto_compat.h:51
mbedtls_deprecated_psa_dh_group_t
MBEDTLS_PSA_DEPRECATED psa_dh_group_t mbedtls_deprecated_psa_dh_group_t
Definition: crypto_compat.h:54
psa_key_usage_t
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition: crypto_types.h:248
mbedtls_deprecated_psa_key_usage_t
MBEDTLS_PSA_DEPRECATED psa_key_usage_t mbedtls_deprecated_psa_key_usage_t
Definition: crypto_compat.h:52
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:98
psa_asymmetric_verify
static MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_verify(psa_key_handle_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)
Definition: crypto_compat.h:103
psa_verify_hash
psa_status_t psa_verify_hash(psa_key_handle_t handle, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)
Verify the signature a hash or short message using a public key.
psa_asymmetric_sign
static MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_sign(psa_key_handle_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
Definition: crypto_compat.h:92
psa_key_handle_t
uint16_t psa_key_handle_t
Definition: crypto_platform.h:50
psa_dh_group_t
uint8_t psa_dh_group_t
Definition: crypto_types.h:88