Function esp_idf_svc::sys::mbedtls_pk_sign

source ยท
pub unsafe extern "C" fn mbedtls_pk_sign(
    ctx: *mut mbedtls_pk_context,
    md_alg: u32,
    hash: *const u8,
    hash_len: usize,
    sig: *mut u8,
    sig_size: usize,
    sig_len: *mut usize,
    f_rng: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut u8, _: usize) -> i32>,
    p_rng: *mut c_void,
) -> i32
Expand description

\brief Make signature, including padding if relevant.

\param ctx The PK context to use. It must have been set up with a private key. \param md_alg Hash algorithm used (see notes) \param hash Hash of the message to sign \param hash_len Hash length \param sig Place to write the signature. It must have enough room for the signature. #MBEDTLS_PK_SIGNATURE_MAX_SIZE is always enough. You may use a smaller buffer if it is large enough given the key type. \param sig_size The size of the \p sig buffer in bytes. \param sig_len On successful return, the number of bytes written to \p sig. \param f_rng RNG function, must not be \c NULL. \param p_rng RNG parameter

\note For keys of type #MBEDTLS_PK_RSA, the signature algorithm is either PKCS#1 v1.5 or PSS (using the largest possible salt length up to the hash length), depending on the padding mode in the underlying RSA context. For a pk object constructed by parsing, this is PKCS#1 v1.5 by default. Use mbedtls_pk_verify_ext() to explicitly select a different algorithm.

\return 0 on success, or a specific error code.

\note For RSA, md_alg may be MBEDTLS_MD_NONE if hash_len != 0. For ECDSA, md_alg may never be MBEDTLS_MD_NONE.