Manuel Pégourié-Gonnard | 36fb12e | 2023-03-28 11:33:23 +0200 | [diff] [blame^] | 1 | /** |
| 2 | * Translation between MD and PSA identifiers (algorithms, errors). |
| 3 | * |
| 4 | * Note: this internal module will go away when everything becomes based on |
| 5 | * PSA Crypto; it is a helper for the transition period. |
| 6 | * |
| 7 | * Copyright The Mbed TLS Contributors |
| 8 | * SPDX-License-Identifier: Apache-2.0 |
| 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. |
| 12 | * You may obtain a copy of the License at |
| 13 | * |
| 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | * |
| 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | * See the License for the specific language governing permissions and |
| 20 | * limitations under the License. |
| 21 | */ |
| 22 | #ifndef MBEDTLS_MD_PSA_H |
| 23 | #define MBEDTLS_MD_PSA_H |
| 24 | |
| 25 | #include "common.h" |
| 26 | |
| 27 | #include "mbedtls/md.h" |
| 28 | #include "psa/crypto.h" |
| 29 | |
| 30 | /** |
| 31 | * \brief This function returns the PSA algorithm identifier |
| 32 | * associated with the given digest type. |
| 33 | * |
| 34 | * \param md_type The type of digest to search for. |
| 35 | * |
| 36 | * \return The PSA algorithm identifier associated with \p md_type. |
| 37 | * \return PSA_ALG_NONE if the algorithm is not supported. |
| 38 | */ |
| 39 | psa_algorithm_t mbedtls_md_psa_alg_from_type(mbedtls_md_type_t md_type); |
| 40 | |
| 41 | /** |
| 42 | * \brief This function returns the given digest type |
| 43 | * associated with the PSA algorithm identifier. |
| 44 | * |
| 45 | * \param psa_alg The PSA algorithm identifier to search for. |
| 46 | * |
| 47 | * \return The MD type associated with \p psa_alg. |
| 48 | * \return MBEDTLS_MD_NONE if the algorithm is not supported. |
| 49 | */ |
| 50 | mbedtls_md_type_t mbedtls_md_type_from_psa_alg(psa_algorithm_t psa_alg); |
| 51 | |
| 52 | /** Convert PSA status to MD error code. |
| 53 | * |
| 54 | * \param status PSA status. |
| 55 | * |
| 56 | * \return The corresponding MD error code, |
| 57 | */ |
| 58 | int mbedtls_md_error_from_psa(psa_status_t status); |
| 59 | |
| 60 | #endif /* MBEDTLS_MD_PSA_H */ |