Function esp_idf_sys::mbedtls_rsa_pkcs1_decrypt

source ·
pub unsafe extern "C" fn mbedtls_rsa_pkcs1_decrypt(
    ctx: *mut mbedtls_rsa_context,
    f_rng: Option<unsafe extern "C" fn(arg1: *mut c_void, arg2: *mut c_uchar, arg3: usize) -> c_int>,
    p_rng: *mut c_void,
    olen: *mut usize,
    input: *const c_uchar,
    output: *mut c_uchar,
    output_max_len: usize,
) -> c_int
Expand description

\brief This function performs an RSA operation, then removes the message padding.

            It is the generic wrapper for performing a PKCS#1 decryption
            operation.

\warning When \p ctx->padding is set to #MBEDTLS_RSA_PKCS_V15, mbedtls_rsa_rsaes_pkcs1_v15_decrypt() is called, which is an inherently dangerous function (CWE-242).

\note The output buffer length \c output_max_len should be as large as the size \p ctx->len of \p ctx->N (for example, 128 Bytes if RSA-1024 is used) to be able to hold an arbitrary decrypted message. If it is not large enough to hold the decryption of the particular ciphertext provided, the function returns \c MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.

\param ctx The initialized RSA context to use. \param f_rng The RNG function. This is used for blinding and is mandatory; see mbedtls_rsa_private() for more. \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL if \p f_rng doesn’t need a context. \param olen The address at which to store the length of the plaintext. This must not be \c NULL. \param input The ciphertext buffer. This must be a readable buffer of length \c ctx->len Bytes. For example, \c 256 Bytes for an 2048-bit RSA modulus. \param output The buffer used to hold the plaintext. This must be a writable buffer of length \p output_max_len Bytes. \param output_max_len The length in Bytes of the output buffer \p output.

\return \c 0 on success. \return An \c MBEDTLS_ERR_RSA_XXX error code on failure.