Skip to main content

mbedtls_pkcs12_pbe_ext

Function mbedtls_pkcs12_pbe_ext 

Source
pub unsafe extern "C" fn mbedtls_pkcs12_pbe_ext(
    pbe_params: *mut mbedtls_asn1_buf,
    mode: c_int,
    cipher_type: mbedtls_cipher_type_t,
    md_type: mbedtls_md_type_t,
    pwd: *const c_uchar,
    pwdlen: usize,
    data: *const c_uchar,
    len: usize,
    output: *mut c_uchar,
    output_size: usize,
    output_len: *mut usize,
) -> c_int
Expand description

\brief PKCS12 Password Based function (encryption / decryption) for cipher-based and mbedtls_md-based PBE’s

\warning When decrypting: - This function validates the CBC padding and returns #MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH if the padding is invalid. Note that this can help active adversaries attempting to brute-forcing the password. Note also that there is no guarantee that an invalid password will be detected (the chances of a valid padding with a random password are about 1/255).

\param pbe_params an ASN1 buffer containing the pkcs-12 PbeParams structure \param mode either #MBEDTLS_PKCS12_PBE_ENCRYPT or #MBEDTLS_PKCS12_PBE_DECRYPT \param cipher_type the cipher used \param md_type the mbedtls_md used \param pwd Latin1-encoded password used. This may only be \c NULL when \p pwdlen is 0. No null terminator should be used. \param pwdlen length of the password (may be 0) \param data the input data \param len data length \param output Output buffer. On success, it contains the encrypted or decrypted data, possibly followed by the CBC padding. On failure, the content is indeterminate. For decryption, there must be enough room for \p len bytes. For encryption, there must be enough room for \p len + 1 bytes, rounded up to the block size of the block cipher identified by \p pbe_params. \param output_size size of output buffer. This must be big enough to accommodate for output plus padding data. \param output_len On success, length of actual data written to the output buffer.

\return 0 if successful, or a MBEDTLS_ERR_XXX code