30#ifndef PSA_CRYPTO_COMPAT_H
31#define PSA_CRYPTO_COMPAT_H
45#define PSA_KEY_HANDLE_INIT MBEDTLS_SVC_KEY_ID_INIT
53static inline int psa_key_handle_is_null( psa_key_handle_t handle )
55 return( mbedtls_svc_key_id_is_null( handle ) );
58#if !defined(MBEDTLS_DEPRECATED_REMOVED)
63#if defined(MBEDTLS_DEPRECATED_WARNING) && !defined(MBEDTLS_PSA_DEPRECATED)
64#define MBEDTLS_PSA_DEPRECATED __attribute__((deprecated))
66#define MBEDTLS_PSA_DEPRECATED
69typedef MBEDTLS_PSA_DEPRECATED
size_t mbedtls_deprecated_size_t;
70typedef MBEDTLS_PSA_DEPRECATED
psa_status_t mbedtls_deprecated_psa_status_t;
71typedef MBEDTLS_PSA_DEPRECATED
psa_key_usage_t mbedtls_deprecated_psa_key_usage_t;
72typedef MBEDTLS_PSA_DEPRECATED
psa_ecc_family_t mbedtls_deprecated_psa_ecc_family_t;
73typedef MBEDTLS_PSA_DEPRECATED
psa_dh_family_t mbedtls_deprecated_psa_dh_family_t;
76typedef MBEDTLS_PSA_DEPRECATED
psa_algorithm_t mbedtls_deprecated_psa_algorithm_t;
78#define PSA_KEY_TYPE_GET_CURVE PSA_KEY_TYPE_ECC_GET_FAMILY
79#define PSA_KEY_TYPE_GET_GROUP PSA_KEY_TYPE_DH_GET_FAMILY
81#define MBEDTLS_DEPRECATED_CONSTANT( type, value ) \
82 ( (mbedtls_deprecated_##type) ( value ) )
90#define PSA_ERROR_UNKNOWN_ERROR \
91 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_GENERIC_ERROR )
95#define PSA_ERROR_OCCUPIED_SLOT \
96 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_ALREADY_EXISTS )
100#define PSA_ERROR_EMPTY_SLOT \
101 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_DOES_NOT_EXIST )
105#define PSA_ERROR_INSUFFICIENT_CAPACITY \
106 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_INSUFFICIENT_DATA )
110#define PSA_ERROR_TAMPERING_DETECTED \
111 MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_CORRUPTION_DETECTED )
116#define PSA_KEY_USAGE_SIGN \
117 MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_SIGN_HASH )
118#define PSA_KEY_USAGE_VERIFY \
119 MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_VERIFY_HASH )
124#define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \
125 MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGNATURE_MAX_SIZE )
126#define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) \
127 MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) )
132MBEDTLS_PSA_DEPRECATED
static inline psa_status_t psa_asymmetric_sign( psa_key_handle_t key,
137 size_t signature_size,
138 size_t *signature_length )
140 return psa_sign_hash( key, alg, hash, hash_length, signature, signature_size, signature_length );
143MBEDTLS_PSA_DEPRECATED
static inline psa_status_t psa_asymmetric_verify( psa_key_handle_t key,
147 const uint8_t *signature,
148 size_t signature_length )
150 return psa_verify_hash( key, alg, hash, hash_length, signature, signature_length );
156#define PSA_ECC_CURVE_SECP160K1 \
157 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
158#define PSA_ECC_CURVE_SECP192K1 \
159 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
160#define PSA_ECC_CURVE_SECP224K1 \
161 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
162#define PSA_ECC_CURVE_SECP256K1 \
163 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
164#define PSA_ECC_CURVE_SECP160R1 \
165 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
166#define PSA_ECC_CURVE_SECP192R1 \
167 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
168#define PSA_ECC_CURVE_SECP224R1 \
169 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
170#define PSA_ECC_CURVE_SECP256R1 \
171 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
172#define PSA_ECC_CURVE_SECP384R1 \
173 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
174#define PSA_ECC_CURVE_SECP521R1 \
175 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
176#define PSA_ECC_CURVE_SECP160R2 \
177 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 )
178#define PSA_ECC_CURVE_SECT163K1 \
179 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
180#define PSA_ECC_CURVE_SECT233K1 \
181 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
182#define PSA_ECC_CURVE_SECT239K1 \
183 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
184#define PSA_ECC_CURVE_SECT283K1 \
185 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
186#define PSA_ECC_CURVE_SECT409K1 \
187 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
188#define PSA_ECC_CURVE_SECT571K1 \
189 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
190#define PSA_ECC_CURVE_SECT163R1 \
191 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
192#define PSA_ECC_CURVE_SECT193R1 \
193 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
194#define PSA_ECC_CURVE_SECT233R1 \
195 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
196#define PSA_ECC_CURVE_SECT283R1 \
197 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
198#define PSA_ECC_CURVE_SECT409R1 \
199 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
200#define PSA_ECC_CURVE_SECT571R1 \
201 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
202#define PSA_ECC_CURVE_SECT163R2 \
203 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
204#define PSA_ECC_CURVE_SECT193R2 \
205 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
206#define PSA_ECC_CURVE_BRAINPOOL_P256R1 \
207 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
208#define PSA_ECC_CURVE_BRAINPOOL_P384R1 \
209 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
210#define PSA_ECC_CURVE_BRAINPOOL_P512R1 \
211 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
212#define PSA_ECC_CURVE_CURVE25519 \
213 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
214#define PSA_ECC_CURVE_CURVE448 \
215 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
220#define PSA_ECC_CURVE_SECP_K1 \
221 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
222#define PSA_ECC_CURVE_SECP_R1 \
223 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
224#define PSA_ECC_CURVE_SECP_R2 \
225 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 )
226#define PSA_ECC_CURVE_SECT_K1 \
227 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
228#define PSA_ECC_CURVE_SECT_R1 \
229 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
230#define PSA_ECC_CURVE_SECT_R2 \
231 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
232#define PSA_ECC_CURVE_BRAINPOOL_P_R1 \
233 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
234#define PSA_ECC_CURVE_MONTGOMERY \
235 MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
240#define PSA_DH_GROUP_FFDHE2048 \
241 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
242#define PSA_DH_GROUP_FFDHE3072 \
243 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
244#define PSA_DH_GROUP_FFDHE4096 \
245 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
246#define PSA_DH_GROUP_FFDHE6144 \
247 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
248#define PSA_DH_GROUP_FFDHE8192 \
249 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
254#define PSA_DH_GROUP_RFC7919 \
255 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
256#define PSA_DH_GROUP_CUSTOM \
257 MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_CUSTOM )
262#define PSA_ALG_ARC4 \
263 MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_STREAM_CIPHER )
264#define PSA_ALG_CHACHA20 \
265 MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_STREAM_CIPHER )
328 psa_key_handle_t *handle );
psa_status_t psa_open_key(mbedtls_svc_key_id_t key, psa_key_handle_t *handle)
Open a handle to an existing persistent key.
psa_status_t psa_close_key(psa_key_handle_t handle)
Close a key handle.
psa_status_t psa_sign_hash(mbedtls_svc_key_id_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)
Sign a hash or short message with a private key.
psa_status_t psa_verify_hash(mbedtls_svc_key_id_t key, 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.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
uint8_t psa_ecc_family_t
The type of PSA elliptic curve family identifiers.
uint8_t psa_dh_family_t
The type of PSA Diffie-Hellman group family identifiers.
int32_t psa_status_t
Function return status.
psa_key_id_t mbedtls_svc_key_id_t
Identifier for persistent keys.
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.