mbed TLS v2.2.0
ecdsa.h
Go to the documentation of this file.
1 
23 #ifndef MBEDTLS_ECDSA_H
24 #define MBEDTLS_ECDSA_H
25 
26 #include "ecp.h"
27 #include "md.h"
28 
29 /*
30  * RFC 4492 page 20:
31  *
32  * Ecdsa-Sig-Value ::= SEQUENCE {
33  * r INTEGER,
34  * s INTEGER
35  * }
36  *
37  * Size is at most
38  * 1 (tag) + 1 (len) + 1 (initial 0) + ECP_MAX_BYTES for each of r and s,
39  * twice that + 1 (tag) + 2 (len) for the sequence
40  * (assuming ECP_MAX_BYTES is less than 126 for r and s,
41  * and less than 124 (total len <= 255) for the sequence)
42  */
43 #if MBEDTLS_ECP_MAX_BYTES > 124
44 #error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN"
45 #endif
46 
47 #define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) )
48 
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
76  const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
77  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
78 
79 #if defined(MBEDTLS_ECDSA_DETERMINISTIC)
80 
95 int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
96  const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
97  mbedtls_md_type_t md_alg );
98 #endif /* MBEDTLS_ECDSA_DETERMINISTIC */
99 
115  const unsigned char *buf, size_t blen,
116  const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s);
117 
144  const unsigned char *hash, size_t hlen,
145  unsigned char *sig, size_t *slen,
146  int (*f_rng)(void *, unsigned char *, size_t),
147  void *p_rng );
148 
149 #if defined(MBEDTLS_ECDSA_DETERMINISTIC)
150 #if ! defined(MBEDTLS_DEPRECATED_REMOVED)
151 #if defined(MBEDTLS_DEPRECATED_WARNING)
152 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
153 #else
154 #define MBEDTLS_DEPRECATED
155 #endif
156 
179 int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx,
180  const unsigned char *hash, size_t hlen,
181  unsigned char *sig, size_t *slen,
183 #undef MBEDTLS_DEPRECATED
184 #endif /* MBEDTLS_DEPRECATED_REMOVED */
185 #endif /* MBEDTLS_ECDSA_DETERMINISTIC */
186 
203  const unsigned char *hash, size_t hlen,
204  const unsigned char *sig, size_t slen );
205 
218  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
219 
229 
236 
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif /* ecdsa.h */
void mbedtls_ecdsa_free(mbedtls_ecdsa_context *ctx)
Free context.
Elliptic curves over GF(p)
ECP key pair structure.
Definition: ecp.h:163
void mbedtls_ecdsa_init(mbedtls_ecdsa_context *ctx)
Initialize context.
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)
Verify ECDSA signature of a previously hashed message.
ECP group structure.
Definition: ecp.h:136
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)
Compute ECDSA signature of a previously hashed message.
int mbedtls_ecdsa_from_keypair(mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key)
Set an ECDSA context from an EC key pair.
#define MBEDTLS_DEPRECATED
Definition: md.h:125
mbedtls_ecp_keypair mbedtls_ecdsa_context
ECDSA context structure.
Definition: ecdsa.h:52
mbedtls_ecp_group_id
Domain parameters (curve, subgroup and generator) identifiers.
Definition: ecp.h:60
int mbedtls_ecdsa_genkey(mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Generate an ECDSA keypair on the given curve.
Generic message digest wrapper.
MPI structure.
Definition: bignum.h:143
int mbedtls_ecdsa_read_signature(mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen)
Read and verify an ECDSA signature.
ECP point structure (jacobian coordinates)
Definition: ecp.h:104
mbedtls_md_type_t
Definition: md.h:39
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)
Compute ECDSA signature and write it to buffer, serialized as defined in RFC 4492 page 20...