Tomi Fontanilles | 573dc23 | 2023-12-10 14:57:51 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file rsa_internal.h |
| 3 | * |
| 4 | * \brief Internal-only RSA public-key cryptosystem API. |
| 5 | * |
| 6 | * This file declares RSA-related functions that are to be used |
| 7 | * only from within the Mbed TLS library itself. |
| 8 | * |
| 9 | */ |
| 10 | /* |
| 11 | * Copyright The Mbed TLS Contributors |
| 12 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 13 | */ |
| 14 | #ifndef MBEDTLS_RSA_INTERNAL_H |
| 15 | #define MBEDTLS_RSA_INTERNAL_H |
| 16 | |
| 17 | #include "mbedtls/rsa.h" |
| 18 | |
Valerio Setti | b328c44 | 2024-01-23 10:48:45 +0100 | [diff] [blame] | 19 | /** |
| 20 | * \brief |
| 21 | * |
| 22 | * \param rsa |
| 23 | * \param key |
| 24 | * \param keylen |
| 25 | * \return int |
| 26 | */ |
| 27 | int mbedtls_rsa_key_parse(mbedtls_rsa_context *rsa, const unsigned char *key, size_t keylen); |
| 28 | |
| 29 | /** |
| 30 | * \brief |
| 31 | * |
| 32 | * \param rsa |
| 33 | * \param p |
| 34 | * \param end |
| 35 | * \return int |
| 36 | */ |
| 37 | int mbedtls_rsa_pubkey_parse(mbedtls_rsa_context *rsa, unsigned char **p, |
| 38 | const unsigned char *end); |
| 39 | |
| 40 | /** |
| 41 | * \brief |
| 42 | * |
| 43 | * \param p |
| 44 | * \param start |
| 45 | * \param rsa |
| 46 | * \return int |
| 47 | */ |
| 48 | int mbedtls_rsa_key_write(const mbedtls_rsa_context *rsa, unsigned char *start, |
| 49 | unsigned char **p); |
| 50 | |
| 51 | /** |
| 52 | * \brief |
| 53 | * |
| 54 | * \param p |
| 55 | * \param start |
| 56 | * \param rsa |
| 57 | * \return int |
| 58 | */ |
| 59 | int mbedtls_rsa_pubkey_write(const mbedtls_rsa_context *rsa, unsigned char *start, |
| 60 | unsigned char **p); |
| 61 | |
Tomi Fontanilles | 573dc23 | 2023-12-10 14:57:51 +0200 | [diff] [blame] | 62 | #if defined(MBEDTLS_PKCS1_V21) |
| 63 | /** |
| 64 | * \brief This function is analogue to \c mbedtls_rsa_rsassa_pss_sign(). |
| 65 | * The only difference between them is that this function is more flexible |
| 66 | * on the parameters of \p ctx that are set with \c mbedtls_rsa_set_padding(). |
| 67 | * |
| 68 | * \note Compared to its counterpart, this function: |
| 69 | * - does not check the padding setting of \p ctx. |
| 70 | * - allows the hash_id of \p ctx to be MBEDTLS_MD_NONE, |
| 71 | * in which case it uses \p md_alg as the hash_id. |
| 72 | * |
| 73 | * \note Refer to \c mbedtls_rsa_rsassa_pss_sign() for a description |
| 74 | * of the functioning and parameters of this function. |
| 75 | */ |
| 76 | int mbedtls_rsa_rsassa_pss_sign_no_mode_check(mbedtls_rsa_context *ctx, |
| 77 | int (*f_rng)(void *, unsigned char *, size_t), |
| 78 | void *p_rng, |
| 79 | mbedtls_md_type_t md_alg, |
| 80 | unsigned int hashlen, |
| 81 | const unsigned char *hash, |
| 82 | unsigned char *sig); |
| 83 | #endif /* MBEDTLS_PKCS1_V21 */ |
| 84 | |
| 85 | #endif /* rsa_internal.h */ |