mbedtls_ecdsa_write_signature_restartable() function
This function computes the ECDSA signature and writes it to a buffer, in a restartable way. \see \c mbedtls_ecdsa_write_signature()
Syntax
int mbedtls_ecdsa_write_signature_restartable( mbedtls_ecdsa_context *ctx,
mbedtls_md_type_t md_alg,
const unsigned char *hash,
size_t hlen,
unsigned char *sig,
size_t *slen,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng,
mbedtls_ecdsa_restart_ctx *rs_ctx );
Arguments
ctx
The ECDSA context to use. This must be initialized and have a group and private key bound to it, for example via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair().
md_alg
The message digest that was used to hash the message.
hash
The message hash to be signed. This must be a readable buffer of length \p blen Bytes.
hlen
The length of the hash \p hash in Bytes.
sig
The buffer to which to write the signature. This must be a writable buffer of length at least twice as large as the size of the curve used, plus 9. For example, 73 Bytes if a 256-bit curve is used. A buffer length of #MBEDTLS_ECDSA_MAX_LEN is always safe.
slen
The address at which to store the actual length of the signature written. Must not be \c NULL.
f_rng
The RNG function. This must not be \c NULL if #MBEDTLS_ECDSA_DETERMINISTIC is unset. Otherwise, it is unused and may be set to \c NULL.
p_rng
The RNG context to be passed to \p f_rng. This may be \c NULL if \p f_rng is \c NULL or doesn't use a context.
rs_ctx
The restart context to use. This may be \c NULL to disable restarting. If it is not \c NULL, it must point to an initialized restart context.
Return value
\c 0 on success. #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of operations was reached: see \c mbedtls_ecp_set_max_ops(). Another \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Notes
This function is like \c mbedtls_ecdsa_write_signature() but it can return early and restart according to the limit set with \c mbedtls_ecp_set_max_ops() to reduce blocking.