30#ifndef MBEDTLS_ECDSA_H
31#define MBEDTLS_ECDSA_H
33#if !defined(MBEDTLS_CONFIG_FILE)
36#include MBEDTLS_CONFIG_FILE
66#define MBEDTLS_ECDSA_MAX_SIG_LEN( bits ) \
67 ( ( ( bits ) >= 61 * 8 ? 3 : 2 ) + \
68 2 * ( ( ( bits ) >= 127 * 8 ? 3 : 2 ) + \
69 ( ( bits ) + 8 ) / 8 ) )
72#define MBEDTLS_ECDSA_MAX_LEN MBEDTLS_ECDSA_MAX_SIG_LEN( MBEDTLS_ECP_MAX_BITS )
87#if defined(MBEDTLS_ECP_RESTARTABLE)
94typedef struct mbedtls_ecdsa_restart_ver mbedtls_ecdsa_restart_ver_ctx;
101typedef struct mbedtls_ecdsa_restart_sig mbedtls_ecdsa_restart_sig_ctx;
103#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
109typedef struct mbedtls_ecdsa_restart_det mbedtls_ecdsa_restart_det_ctx;
117 mbedtls_ecp_restart_ctx ecp;
119 mbedtls_ecdsa_restart_ver_ctx *ver;
120 mbedtls_ecdsa_restart_sig_ctx *sig;
121#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
122 mbedtls_ecdsa_restart_det_ctx *det;
124} mbedtls_ecdsa_restart_ctx;
129typedef void mbedtls_ecdsa_restart_ctx;
180 const mbedtls_mpi *d,
const unsigned char *buf,
size_t blen,
181 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
183#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
184#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
185#if defined(MBEDTLS_DEPRECATED_WARNING)
186#define MBEDTLS_DEPRECATED __attribute__((deprecated))
188#define MBEDTLS_DEPRECATED
240 const unsigned char *buf,
size_t blen,
242#undef MBEDTLS_DEPRECATED
286 const unsigned char *buf,
size_t blen,
288 int (*f_rng_blind)(
void *,
unsigned char *,
size_t),
325 const unsigned char *buf,
size_t blen,
379 const unsigned char *hash,
size_t hlen,
380 unsigned char *sig,
size_t *slen,
381 int (*f_rng)(
void *,
unsigned char *,
size_t),
425 const unsigned char *hash,
size_t hlen,
426 unsigned char *sig,
size_t *slen,
427 int (*f_rng)(
void *,
unsigned char *,
size_t),
429 mbedtls_ecdsa_restart_ctx *rs_ctx );
431#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
432#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
433#if defined(MBEDTLS_DEPRECATED_WARNING)
434#define MBEDTLS_DEPRECATED __attribute__((deprecated))
436#define MBEDTLS_DEPRECATED
482 const unsigned char *hash,
size_t hlen,
483 unsigned char *sig,
size_t *slen,
485#undef MBEDTLS_DEPRECATED
517 const unsigned char *hash,
size_t hlen,
518 const unsigned char *sig,
size_t slen );
552 const unsigned char *hash,
size_t hlen,
553 const unsigned char *sig,
size_t slen,
554 mbedtls_ecdsa_restart_ctx *rs_ctx );
573 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
610#if defined(MBEDTLS_ECP_RESTARTABLE)
617void mbedtls_ecdsa_restart_init( mbedtls_ecdsa_restart_ctx *ctx );
626void mbedtls_ecdsa_restart_free( mbedtls_ecdsa_restart_ctx *ctx );
Configuration options (set of defines)
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)
This function computes the ECDSA signature and writes it to a buffer, in a restartable way.
int mbedtls_ecdsa_verify(mbedtls_ecp_group *grp, const unsigned char *buf, size_t blen, const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s)
This function verifies the ECDSA signature of a previously-hashed message.
void mbedtls_ecdsa_free(mbedtls_ecdsa_context *ctx)
This function frees an ECDSA context.
int mbedtls_ecdsa_from_keypair(mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key)
This function sets up an ECDSA context from an EC key pair.
int mbedtls_ecdsa_write_signature(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)
This function computes the ECDSA signature and writes it to a buffer, serialized as defined in RFC-44...
int mbedtls_ecdsa_read_signature_restartable(mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen, mbedtls_ecdsa_restart_ctx *rs_ctx)
This function reads and verifies an ECDSA signature, in a restartable way.
int mbedtls_ecdsa_read_signature(mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen)
This function reads and verifies an ECDSA signature.
mbedtls_ecp_keypair mbedtls_ecdsa_context
The ECDSA context structure.
int mbedtls_ecdsa_genkey(mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an ECDSA keypair on the given curve.
int mbedtls_ecdsa_can_do(mbedtls_ecp_group_id gid)
This function checks whether a given group can be used for ECDSA.
void mbedtls_ecdsa_init(mbedtls_ecdsa_context *ctx)
This function initializes an ECDSA context.
int mbedtls_ecdsa_sign(mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function computes the ECDSA signature of a previously-hashed message.
mbedtls_ecp_group_id
Domain-parameter identifiers: curve, subgroup, and generator.
mbedtls_md_type_t
Supported message digests.
This file provides an API for Elliptic Curves over GF(P) (ECP).
This file contains the generic message-digest wrapper.
The ECP key-pair structure.
The ECP point structure, in Jacobian coordinates.