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 | /* |
| 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 | |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 39 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
| 40 | |
Gilles Peskine | 0168f2f | 2019-11-29 12:22:32 +0100 | [diff] [blame] | 41 | /* |
| 42 | * Mechanism for declaring deprecated values |
| 43 | */ |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 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 | |
Gilles Peskine | 4151094 | 2019-11-26 16:10:58 +0100 | [diff] [blame] | 50 | typedef MBEDTLS_PSA_DEPRECATED size_t mbedtls_deprecated_size_t; |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 51 | typedef MBEDTLS_PSA_DEPRECATED psa_status_t mbedtls_deprecated_psa_status_t; |
Gilles Peskine | 4151094 | 2019-11-26 16:10:58 +0100 | [diff] [blame] | 52 | typedef MBEDTLS_PSA_DEPRECATED psa_key_usage_t mbedtls_deprecated_psa_key_usage_t; |
Gilles Peskine | b87b719 | 2019-12-04 16:24:10 +0100 | [diff] [blame^] | 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; |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 55 | |
| 56 | #define MBEDTLS_DEPRECATED_CONSTANT( type, value ) \ |
| 57 | ( (mbedtls_deprecated_##type) ( value ) ) |
| 58 | |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 59 | /* |
Gilles Peskine | 0168f2f | 2019-11-29 12:22:32 +0100 | [diff] [blame] | 60 | * Deprecated PSA Crypto error code definitions (PSA Crypto API <= 1.0 beta2) |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 61 | */ |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 62 | #define PSA_ERROR_UNKNOWN_ERROR \ |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 63 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_GENERIC_ERROR ) |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 64 | #define PSA_ERROR_OCCUPIED_SLOT \ |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 65 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_ALREADY_EXISTS ) |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 66 | #define PSA_ERROR_EMPTY_SLOT \ |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 67 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_DOES_NOT_EXIST ) |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 68 | #define PSA_ERROR_INSUFFICIENT_CAPACITY \ |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 69 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_INSUFFICIENT_DATA ) |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 70 | #define PSA_ERROR_TAMPERING_DETECTED \ |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 71 | MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_CORRUPTION_DETECTED ) |
| 72 | |
Gilles Peskine | 4151094 | 2019-11-26 16:10:58 +0100 | [diff] [blame] | 73 | /* |
Gilles Peskine | 0168f2f | 2019-11-29 12:22:32 +0100 | [diff] [blame] | 74 | * Deprecated PSA Crypto numerical encodings (PSA Crypto API <= 1.0 beta3) |
Gilles Peskine | 4151094 | 2019-11-26 16:10:58 +0100 | [diff] [blame] | 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 | /* |
Gilles Peskine | 0168f2f | 2019-11-29 12:22:32 +0100 | [diff] [blame] | 82 | * Deprecated PSA Crypto size calculation macros (PSA Crypto API <= 1.0 beta3) |
Gilles Peskine | 4151094 | 2019-11-26 16:10:58 +0100 | [diff] [blame] | 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 | /* |
Gilles Peskine | 0168f2f | 2019-11-29 12:22:32 +0100 | [diff] [blame] | 90 | * Deprecated PSA Crypto function names (PSA Crypto API <= 1.0 beta3) |
Gilles Peskine | 4151094 | 2019-11-26 16:10:58 +0100 | [diff] [blame] | 91 | */ |
| 92 | /* Make these macros and not wrappers so that there is no cost to |
| 93 | * applications that don't use the deprecated names. |
| 94 | * |
| 95 | * Put backslash-newline after "#define" to bypass check-names.sh which |
| 96 | * would otherwise complain about lowercase macro names. |
| 97 | */ |
| 98 | #define \ |
| 99 | psa_asymmetric_sign( key, alg, hash, hash_length, signature, signature_size, signature_length ) \ |
| 100 | ( (mbedtls_deprecated_psa_status_t) psa_sign_hash( key, alg, hash, hash_length, signature, signature_size, signature_length ) ) |
| 101 | #define \ |
| 102 | psa_asymmetric_verify( key, alg, hash, hash_length, signature, signature_length ) \ |
| 103 | ( (mbedtls_deprecated_psa_status_t) psa_verify_hash( key, alg, hash, hash_length, signature, signature_length ) ) |
| 104 | |
Gilles Peskine | 7b0ab6d | 2019-11-26 16:32:12 +0100 | [diff] [blame] | 105 | #endif /* MBEDTLS_DEPRECATED_REMOVED */ |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 106 | |
Gilles Peskine | 45c29ce | 2019-12-03 17:56:11 +0100 | [diff] [blame] | 107 | /* |
| 108 | * Size-specific elliptic curve and Diffie-Hellman group names |
| 109 | */ |
Gilles Peskine | b87b719 | 2019-12-04 16:24:10 +0100 | [diff] [blame^] | 110 | #define PSA_ECC_CURVE_SECP160K1 \ |
| 111 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 ) |
| 112 | #define PSA_ECC_CURVE_SECP192K1 \ |
| 113 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 ) |
| 114 | #define PSA_ECC_CURVE_SECP224K1 \ |
| 115 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 ) |
| 116 | #define PSA_ECC_CURVE_SECP256K1 \ |
| 117 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_K1 ) |
| 118 | #define PSA_ECC_CURVE_SECP160R1 \ |
| 119 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 ) |
| 120 | #define PSA_ECC_CURVE_SECP192R1 \ |
| 121 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 ) |
| 122 | #define PSA_ECC_CURVE_SECP224R1 \ |
| 123 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 ) |
| 124 | #define PSA_ECC_CURVE_SECP256R1 \ |
| 125 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 ) |
| 126 | #define PSA_ECC_CURVE_SECP384R1 \ |
| 127 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 ) |
| 128 | #define PSA_ECC_CURVE_SECP521R1 \ |
| 129 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R1 ) |
| 130 | #define PSA_ECC_CURVE_SECP160R2 \ |
| 131 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECP_R2 ) |
| 132 | #define PSA_ECC_CURVE_SECT163K1 \ |
| 133 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 ) |
| 134 | #define PSA_ECC_CURVE_SECT233K1 \ |
| 135 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 ) |
| 136 | #define PSA_ECC_CURVE_SECT239K1 \ |
| 137 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 ) |
| 138 | #define PSA_ECC_CURVE_SECT283K1 \ |
| 139 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 ) |
| 140 | #define PSA_ECC_CURVE_SECT409K1 \ |
| 141 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 ) |
| 142 | #define PSA_ECC_CURVE_SECT571K1 \ |
| 143 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_K1 ) |
| 144 | #define PSA_ECC_CURVE_SECT163R1 \ |
| 145 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 ) |
| 146 | #define PSA_ECC_CURVE_SECT193R1 \ |
| 147 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 ) |
| 148 | #define PSA_ECC_CURVE_SECT233R1 \ |
| 149 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 ) |
| 150 | #define PSA_ECC_CURVE_SECT283R1 \ |
| 151 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 ) |
| 152 | #define PSA_ECC_CURVE_SECT409R1 \ |
| 153 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 ) |
| 154 | #define PSA_ECC_CURVE_SECT571R1 \ |
| 155 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R1 ) |
| 156 | #define PSA_ECC_CURVE_SECT163R2 \ |
| 157 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R2 ) |
| 158 | #define PSA_ECC_CURVE_SECT193R2 \ |
| 159 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_SECT_R2 ) |
| 160 | #define PSA_ECC_CURVE_BRAINPOOL_P256R1 \ |
| 161 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_BRAINPOOL_P_R1 ) |
| 162 | #define PSA_ECC_CURVE_BRAINPOOL_P384R1 \ |
| 163 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_BRAINPOOL_P_R1 ) |
| 164 | #define PSA_ECC_CURVE_BRAINPOOL_P512R1 \ |
| 165 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_BRAINPOOL_P_R1 ) |
| 166 | #define PSA_ECC_CURVE_CURVE25519 \ |
| 167 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_MONTGOMERY ) |
| 168 | #define PSA_ECC_CURVE_CURVE448 \ |
| 169 | MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_curve_t, PSA_ECC_CURVE_MONTGOMERY ) |
Gilles Peskine | 45c29ce | 2019-12-03 17:56:11 +0100 | [diff] [blame] | 170 | |
Gilles Peskine | b87b719 | 2019-12-04 16:24:10 +0100 | [diff] [blame^] | 171 | #define PSA_DH_GROUP_FFDHE2048 \ |
| 172 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 ) |
| 173 | #define PSA_DH_GROUP_FFDHE3072 \ |
| 174 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 ) |
| 175 | #define PSA_DH_GROUP_FFDHE4096 \ |
| 176 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 ) |
| 177 | #define PSA_DH_GROUP_FFDHE6144 \ |
| 178 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 ) |
| 179 | #define PSA_DH_GROUP_FFDHE8192 \ |
| 180 | MBEDTLS_DEPRECATED_CONSTANT( psa_dh_group_t, PSA_DH_GROUP_RFC7919 ) |
Gilles Peskine | 45c29ce | 2019-12-03 17:56:11 +0100 | [diff] [blame] | 181 | |
Gilles Peskine | 7a894f2 | 2019-11-26 16:06:46 +0100 | [diff] [blame] | 182 | #ifdef __cplusplus |
| 183 | } |
| 184 | #endif |
| 185 | |
| 186 | #endif /* PSA_CRYPTO_COMPAT_H */ |