Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 1 | /* |
Maulik Patel | 28659c4 | 2021-01-06 14:09:22 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2021, Arm Limited. All rights reserved. |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 7 | /** |
| 8 | * \file psa/crypto_compat.h |
| 9 | * |
| 10 | * \brief PSA cryptography module: Backward compatibility aliases |
| 11 | * |
| 12 | * This header declares alternative names for macro and functions. |
| 13 | * New application code should not use these names. |
| 14 | * These names may be removed in a future version of Mbed Crypto. |
| 15 | * |
| 16 | * \note This file may not be included directly. Applications must |
| 17 | * include psa/crypto.h. |
| 18 | */ |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 19 | |
| 20 | #ifndef PSA_CRYPTO_COMPAT_H |
| 21 | #define PSA_CRYPTO_COMPAT_H |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Maulik Patel | 28659c4 | 2021-01-06 14:09:22 +0000 | [diff] [blame] | 27 | /* |
| 28 | * To support both openless APIs and psa_open_key() temporarily, define |
| 29 | * psa_key_handle_t to be equal to psa_key_id_t. Do not mark the |
| 30 | * type and its utility macros and functions deprecated yet. This will be done |
| 31 | * in a subsequent phase. |
| 32 | */ |
| 33 | typedef psa_key_id_t psa_key_handle_t; |
| 34 | |
| 35 | /** Check whether an handle is null. |
| 36 | * |
| 37 | * \param handle Handle |
| 38 | * |
| 39 | * \return Non-zero if the handle is null, zero otherwise. |
| 40 | */ |
| 41 | static inline int psa_key_handle_is_null(psa_key_handle_t handle) |
| 42 | { |
| 43 | return(handle == 0); |
| 44 | } |
| 45 | |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 46 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
| 47 | |
| 48 | /* |
| 49 | * Mechanism for declaring deprecated values |
| 50 | */ |
| 51 | #if defined(MBEDTLS_DEPRECATED_WARNING) && !defined(MBEDTLS_PSA_DEPRECATED) |
| 52 | #define MBEDTLS_PSA_DEPRECATED __attribute__((deprecated)) |
| 53 | #else |
| 54 | #define MBEDTLS_PSA_DEPRECATED |
| 55 | #endif |
| 56 | |
| 57 | typedef MBEDTLS_PSA_DEPRECATED size_t mbedtls_deprecated_size_t; |
| 58 | typedef MBEDTLS_PSA_DEPRECATED psa_status_t mbedtls_deprecated_psa_status_t; |
| 59 | typedef MBEDTLS_PSA_DEPRECATED psa_key_usage_t mbedtls_deprecated_psa_key_usage_t; |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 60 | typedef MBEDTLS_PSA_DEPRECATED psa_ecc_family_t mbedtls_deprecated_psa_ecc_family_t; |
| 61 | typedef MBEDTLS_PSA_DEPRECATED psa_dh_family_t mbedtls_deprecated_psa_dh_family_t; |
| 62 | typedef MBEDTLS_PSA_DEPRECATED psa_ecc_family_t psa_ecc_curve_t; |
| 63 | typedef MBEDTLS_PSA_DEPRECATED psa_dh_family_t psa_dh_group_t; |
Maulik Patel | 28659c4 | 2021-01-06 14:09:22 +0000 | [diff] [blame] | 64 | typedef MBEDTLS_PSA_DEPRECATED psa_algorithm_t mbedtls_deprecated_psa_algorithm_t; |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 65 | |
| 66 | #define PSA_KEY_TYPE_GET_CURVE PSA_KEY_TYPE_ECC_GET_FAMILY |
| 67 | #define PSA_KEY_TYPE_GET_GROUP PSA_KEY_TYPE_DH_GET_FAMILY |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 68 | |
| 69 | #define MBEDTLS_DEPRECATED_CONSTANT( type, value ) \ |
| 70 | ( (mbedtls_deprecated_##type) ( value ) ) |
| 71 | |
| 72 | /* |
| 73 | * Deprecated PSA Crypto error code definitions (PSA Crypto API <= 1.0 beta2) |
| 74 | */ |
| 75 | #define PSA_ERROR_UNKNOWN_ERROR \ |
| 76 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_GENERIC_ERROR ) |
| 77 | #define PSA_ERROR_OCCUPIED_SLOT \ |
| 78 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_ALREADY_EXISTS ) |
| 79 | #define PSA_ERROR_EMPTY_SLOT \ |
| 80 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_DOES_NOT_EXIST ) |
| 81 | #define PSA_ERROR_INSUFFICIENT_CAPACITY \ |
| 82 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_INSUFFICIENT_DATA ) |
| 83 | #define PSA_ERROR_TAMPERING_DETECTED \ |
| 84 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_CORRUPTION_DETECTED ) |
| 85 | |
| 86 | /* |
| 87 | * Deprecated PSA Crypto numerical encodings (PSA Crypto API <= 1.0 beta3) |
| 88 | */ |
| 89 | #define PSA_KEY_USAGE_SIGN \ |
| 90 | MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_SIGN_HASH ) |
| 91 | #define PSA_KEY_USAGE_VERIFY \ |
| 92 | MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_VERIFY_HASH ) |
| 93 | |
| 94 | /* |
| 95 | * Deprecated PSA Crypto size calculation macros (PSA Crypto API <= 1.0 beta3) |
| 96 | */ |
| 97 | #define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \ |
| 98 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGNATURE_MAX_SIZE ) |
| 99 | #define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) \ |
| 100 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) ) |
Maulik Patel | 13b27cf | 2021-05-14 11:44:53 +0100 | [diff] [blame^] | 101 | #define PSA_KEY_EXPORT_MAX_SIZE( key_type, key_bits ) \ |
| 102 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_EXPORT_KEY_OUTPUT_SIZE( key_type, key_bits ) ) |
| 103 | #define PSA_BLOCK_CIPHER_BLOCK_SIZE( type ) \ |
| 104 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_BLOCK_CIPHER_BLOCK_LENGTH( type ) ) |
| 105 | #define PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE \ |
| 106 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE ) |
| 107 | #define PSA_HASH_SIZE( alg ) \ |
| 108 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_HASH_LENGTH( alg ) ) |
| 109 | #define PSA_MAC_FINAL_SIZE( key_type, key_bits, alg ) \ |
| 110 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_MAC_LENGTH( key_type, key_bits, alg ) ) |
| 111 | #define PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN \ |
| 112 | MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE ) |
Soby Mathew | fd247c4 | 2020-02-24 10:23:43 +0000 | [diff] [blame] | 113 | /* |
| 114 | * Deprecated PSA Crypto function names (PSA Crypto API <= 1.0 beta3) |
| 115 | */ |
| 116 | MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_sign( psa_key_handle_t key, |
| 117 | psa_algorithm_t alg, |
| 118 | const uint8_t *hash, |
| 119 | size_t hash_length, |
| 120 | uint8_t *signature, |
| 121 | size_t signature_size, |
| 122 | size_t *signature_length ); |
| 123 | |
| 124 | MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_verify( psa_key_handle_t key, |
| 125 | psa_algorithm_t alg, |
| 126 | const uint8_t *hash, |
| 127 | size_t hash_length, |
| 128 | const uint8_t *signature, |
| 129 | size_t signature_length ); |
| 130 | |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 131 | |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 132 | /* |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 133 | * Size-specific elliptic curve families. |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 134 | */ |
| 135 | #define PSA_ECC_CURVE_SECP160K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 136 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 137 | #define PSA_ECC_CURVE_SECP192K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 138 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 139 | #define PSA_ECC_CURVE_SECP224K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 140 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 141 | #define PSA_ECC_CURVE_SECP256K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 142 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 143 | #define PSA_ECC_CURVE_SECP160R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 144 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 145 | #define PSA_ECC_CURVE_SECP192R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 146 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 147 | #define PSA_ECC_CURVE_SECP224R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 148 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 149 | #define PSA_ECC_CURVE_SECP256R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 150 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 151 | #define PSA_ECC_CURVE_SECP384R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 152 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 153 | #define PSA_ECC_CURVE_SECP521R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 154 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 155 | #define PSA_ECC_CURVE_SECP160R2 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 156 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 157 | #define PSA_ECC_CURVE_SECT163K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 158 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 159 | #define PSA_ECC_CURVE_SECT233K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 160 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 161 | #define PSA_ECC_CURVE_SECT239K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 162 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 163 | #define PSA_ECC_CURVE_SECT283K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 164 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 165 | #define PSA_ECC_CURVE_SECT409K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 166 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 167 | #define PSA_ECC_CURVE_SECT571K1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 168 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 169 | #define PSA_ECC_CURVE_SECT163R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 170 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 171 | #define PSA_ECC_CURVE_SECT193R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 172 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 173 | #define PSA_ECC_CURVE_SECT233R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 174 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 175 | #define PSA_ECC_CURVE_SECT283R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 176 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 177 | #define PSA_ECC_CURVE_SECT409R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 178 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 179 | #define PSA_ECC_CURVE_SECT571R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 180 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 181 | #define PSA_ECC_CURVE_SECT163R2 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 182 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 183 | #define PSA_ECC_CURVE_SECT193R2 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 184 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 185 | #define PSA_ECC_CURVE_BRAINPOOL_P256R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 186 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 187 | #define PSA_ECC_CURVE_BRAINPOOL_P384R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 188 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 189 | #define PSA_ECC_CURVE_BRAINPOOL_P512R1 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 190 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 191 | #define PSA_ECC_CURVE_CURVE25519 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 192 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 193 | #define PSA_ECC_CURVE_CURVE448 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 194 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 195 | |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 196 | /* |
| 197 | * Curves that changed name due to PSA specification. |
| 198 | */ |
| 199 | #define PSA_ECC_CURVE_SECP_K1 \ |
| 200 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 ) |
| 201 | #define PSA_ECC_CURVE_SECP_R1 \ |
| 202 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 ) |
| 203 | #define PSA_ECC_CURVE_SECP_R2 \ |
| 204 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 ) |
| 205 | #define PSA_ECC_CURVE_SECT_K1 \ |
| 206 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 ) |
| 207 | #define PSA_ECC_CURVE_SECT_R1 \ |
| 208 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 ) |
| 209 | #define PSA_ECC_CURVE_SECT_R2 \ |
| 210 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 ) |
| 211 | #define PSA_ECC_CURVE_BRAINPOOL_P_R1 \ |
| 212 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 ) |
| 213 | #define PSA_ECC_CURVE_MONTGOMERY \ |
| 214 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY ) |
| 215 | |
| 216 | /* |
| 217 | * Finite-field Diffie-Hellman families. |
| 218 | */ |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 219 | #define PSA_DH_GROUP_FFDHE2048 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 220 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 221 | #define PSA_DH_GROUP_FFDHE3072 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 222 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 223 | #define PSA_DH_GROUP_FFDHE4096 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 224 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 225 | #define PSA_DH_GROUP_FFDHE6144 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 226 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 227 | #define PSA_DH_GROUP_FFDHE8192 \ |
Summer Qin | 0e5b2e0 | 2020-10-22 11:23:39 +0800 | [diff] [blame] | 228 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 ) |
| 229 | |
| 230 | /* |
| 231 | * Diffie-Hellman families that changed name due to PSA specification. |
| 232 | */ |
| 233 | #define PSA_DH_GROUP_RFC7919 \ |
| 234 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 ) |
| 235 | #define PSA_DH_GROUP_CUSTOM \ |
| 236 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_CUSTOM ) |
Soby Mathew | 07ef6e4 | 2020-07-20 21:09:23 +0100 | [diff] [blame] | 237 | |
Maulik Patel | 28659c4 | 2021-01-06 14:09:22 +0000 | [diff] [blame] | 238 | /* |
| 239 | * Deprecated PSA Crypto stream cipher algorithms (PSA Crypto API <= 1.0 beta3) |
| 240 | */ |
| 241 | #define PSA_ALG_ARC4 \ |
| 242 | MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER) |
| 243 | #define PSA_ALG_CHACHA20 \ |
| 244 | MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER) |
| 245 | |
Maulik Patel | 13b27cf | 2021-05-14 11:44:53 +0100 | [diff] [blame^] | 246 | /* |
| 247 | * Renamed AEAD tag length macros (PSA Crypto API <= 1.0 beta3) |
| 248 | */ |
| 249 | #define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH( aead_alg ) \ |
| 250 | MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( aead_alg ) ) |
| 251 | #define PSA_ALG_AEAD_WITH_TAG_LENGTH( aead_alg, tag_length ) \ |
| 252 | MBEDTLS_DEPRECATED_CONSTANT( psa_algorithm_t, PSA_ALG_AEAD_WITH_SHORTENED_TAG( aead_alg, tag_length ) ) |
| 253 | |
| 254 | |
Maulik Patel | 28659c4 | 2021-01-06 14:09:22 +0000 | [diff] [blame] | 255 | #endif /* MBEDTLS_DEPRECATED_REMOVED */ |
| 256 | |
| 257 | /** Open a handle to an existing persistent key. |
| 258 | * |
| 259 | * Open a handle to a persistent key. A key is persistent if it was created |
| 260 | * with a lifetime other than #PSA_KEY_LIFETIME_VOLATILE. A persistent key |
| 261 | * always has a nonzero key identifier, set with psa_set_key_id() when |
| 262 | * creating the key. Implementations may provide additional pre-provisioned |
| 263 | * keys that can be opened with psa_open_key(). Such keys have an application |
| 264 | * key identifier in the vendor range, as documented in the description of |
| 265 | * #psa_key_id_t. |
| 266 | * |
| 267 | * The application must eventually close the handle with psa_close_key() or |
| 268 | * psa_destroy_key() to release associated resources. If the application dies |
| 269 | * without calling one of these functions, the implementation should perform |
| 270 | * the equivalent of a call to psa_close_key(). |
| 271 | * |
| 272 | * Some implementations permit an application to open the same key multiple |
| 273 | * times. If this is successful, each call to psa_open_key() will return a |
| 274 | * different key handle. |
| 275 | * |
| 276 | * \note This API is not part of the PSA Cryptography API Release 1.0.0 |
| 277 | * specification. It was defined in the 1.0 Beta 3 version of the |
| 278 | * specification but was removed in the 1.0.0 released version. This API is |
| 279 | * kept for the time being to not break applications relying on it. It is not |
| 280 | * deprecated yet but will be in the near future. |
| 281 | * |
| 282 | * \note Applications that rely on opening a key multiple times will not be |
| 283 | * portable to implementations that only permit a single key handle to be |
| 284 | * opened. See also :ref:\`key-handles\`. |
| 285 | * |
| 286 | * |
| 287 | * \param id The persistent identifier of the key. |
| 288 | * \param[out] key On success, a handle to the key. |
| 289 | * |
| 290 | * \retval #PSA_SUCCESS |
| 291 | * Success. The application can now use the value of `*handle` |
| 292 | * to access the key. |
| 293 | * \retval #PSA_ERROR_INSUFFICIENT_MEMORY |
| 294 | * The implementation does not have sufficient resources to open the |
| 295 | * key. This can be due to reaching an implementation limit on the |
| 296 | * number of open keys, the number of open key handles, or available |
| 297 | * memory. |
| 298 | * \retval #PSA_ERROR_DOES_NOT_EXIST |
| 299 | * There is no persistent key with key identifier \p id. |
| 300 | * \retval #PSA_ERROR_INVALID_ARGUMENT |
| 301 | * \p id is not a valid persistent key identifier. |
| 302 | * \retval #PSA_ERROR_NOT_PERMITTED |
| 303 | * The specified key exists, but the application does not have the |
| 304 | * permission to access it. Note that this specification does not |
| 305 | * define any way to create such a key, but it may be possible |
| 306 | * through implementation-specific means. |
| 307 | * \retval #PSA_ERROR_COMMUNICATION_FAILURE |
| 308 | * \retval #PSA_ERROR_CORRUPTION_DETECTED |
| 309 | * \retval #PSA_ERROR_STORAGE_FAILURE |
Maulik Patel | 13b27cf | 2021-05-14 11:44:53 +0100 | [diff] [blame^] | 310 | * \retval #PSA_ERROR_DATA_INVALID |
| 311 | * \retval #PSA_ERROR_DATA_CORRUPT |
Maulik Patel | 28659c4 | 2021-01-06 14:09:22 +0000 | [diff] [blame] | 312 | * \retval #PSA_ERROR_BAD_STATE |
| 313 | * The library has not been previously initialized by psa_crypto_init(). |
| 314 | * It is implementation-dependent whether a failure to initialize |
| 315 | * results in this error code. |
| 316 | */ |
| 317 | psa_status_t psa_open_key(psa_key_id_t id, |
| 318 | psa_key_id_t *key); |
| 319 | |
| 320 | /** Close a key handle. |
| 321 | * |
| 322 | * If the handle designates a volatile key, this will destroy the key material |
| 323 | * and free all associated resources, just like psa_destroy_key(). |
| 324 | * |
| 325 | * If this is the last open handle to a persistent key, then closing the handle |
| 326 | * will free all resources associated with the key in volatile memory. The key |
| 327 | * data in persistent storage is not affected and can be opened again later |
| 328 | * with a call to psa_open_key(). |
| 329 | * |
| 330 | * Closing the key handle makes the handle invalid, and the key handle |
| 331 | * must not be used again by the application. |
| 332 | * |
| 333 | * \note This API is not part of the PSA Cryptography API Release 1.0.0 |
| 334 | * specification. It was defined in the 1.0 Beta 3 version of the |
| 335 | * specification but was removed in the 1.0.0 released version. This API is |
| 336 | * kept for the time being to not break applications relying on it. It is not |
| 337 | * deprecated yet but will be in the near future. |
| 338 | * |
| 339 | * \note If the key handle was used to set up an active |
| 340 | * :ref:\`multipart operation <multipart-operations>\`, then closing the |
| 341 | * key handle can cause the multipart operation to fail. Applications should |
| 342 | * maintain the key handle until after the multipart operation has finished. |
| 343 | * |
| 344 | * \param key The key to close. |
| 345 | * If this is \c 0, do nothing and return \c PSA_SUCCESS. |
| 346 | * |
| 347 | * \retval #PSA_SUCCESS |
| 348 | * \p handle was a valid handle or \c 0. It is now closed. |
| 349 | * \retval #PSA_ERROR_INVALID_HANDLE |
| 350 | * \p handle is not a valid handle nor \c 0. |
| 351 | * \retval #PSA_ERROR_COMMUNICATION_FAILURE |
| 352 | * \retval #PSA_ERROR_CORRUPTION_DETECTED |
| 353 | * \retval #PSA_ERROR_BAD_STATE |
| 354 | * The library has not been previously initialized by psa_crypto_init(). |
| 355 | * It is implementation-dependent whether a failure to initialize |
| 356 | * results in this error code. |
| 357 | */ |
| 358 | psa_status_t psa_close_key(psa_key_id_t key); |
| 359 | |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 360 | #ifdef __cplusplus |
| 361 | } |
| 362 | #endif |
| 363 | |
| 364 | #endif /* PSA_CRYPTO_COMPAT_H */ |