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