mbedtls_ecdsa_sign() function
This function computes the ECDSA signature of a previously-hashed message. \see ecp.h
Arguments
grp
The context for the elliptic curve to use. This must be initialized and have group parameters set, for example through mbedtls_ecp_group_load().
r
The MPI context in which to store the first part the signature. This must be initialized.
s
The MPI context in which to store the second part the signature. This must be initialized.
d
The private signing key. This must be initialized.
buf
The content to be signed. This is usually the hash of the original data to be signed. This must be a readable buffer of length \p blen Bytes. It may be \c NULL if \p blen is zero.
blen
The length of \p buf in Bytes.
f_rng
The RNG function. This must not be \c NULL.
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 parameter.
Return value
\c 0 on success. An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code on failure.
Notes
The deterministic version implemented in mbedtls_ecdsa_sign_det() is usually preferred. If the bitlength of the message hash is larger than the bitlength of the group order, then the hash is truncated as defined in Standards for Efficient Cryptography Group (SECG): SEC1 Elliptic Curve Cryptography, section 4.1.3, step 5.