Function esp_idf_hal::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(_: *mut c_void, _: *mut u8, _: usize) -> i32>,
    p_rng: *mut c_void,
    olen: *mut usize,
    input: *const u8,
    output: *mut u8,
    output_max_len: usize,
) -> i32
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.

\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.