mbed TLS v1.3.11
ecdsa.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_ECDSA_H
25 #define POLARSSL_ECDSA_H
26 
27 #include "ecp.h"
28 #include "md.h"
29 
35 typedef struct
36 {
38  mpi d;
40  mpi r;
41  mpi s;
42 }
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
64 int ecdsa_sign( ecp_group *grp, mpi *r, mpi *s,
65  const mpi *d, const unsigned char *buf, size_t blen,
66  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
67 
68 #if defined(POLARSSL_ECDSA_DETERMINISTIC)
69 
84 int ecdsa_sign_det( ecp_group *grp, mpi *r, mpi *s,
85  const mpi *d, const unsigned char *buf, size_t blen,
86  md_type_t md_alg );
87 #endif /* POLARSSL_ECDSA_DETERMINISTIC */
88 
103 int ecdsa_verify( ecp_group *grp,
104  const unsigned char *buf, size_t blen,
105  const ecp_point *Q, const mpi *r, const mpi *s);
106 
129  const unsigned char *hash, size_t hlen,
130  unsigned char *sig, size_t *slen,
131  int (*f_rng)(void *, unsigned char *, size_t),
132  void *p_rng );
133 
134 #if defined(POLARSSL_ECDSA_DETERMINISTIC)
135 
157  const unsigned char *hash, size_t hlen,
158  unsigned char *sig, size_t *slen,
159  md_type_t md_alg );
160 #endif /* POLARSSL_ECDSA_DETERMINISTIC */
161 
178  const unsigned char *hash, size_t hlen,
179  const unsigned char *sig, size_t slen );
180 
193  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
194 
203 int ecdsa_from_keypair( ecdsa_context *ctx, const ecp_keypair *key );
204 
210 void ecdsa_init( ecdsa_context *ctx );
211 
217 void ecdsa_free( ecdsa_context *ctx );
218 
224 int ecdsa_self_test( int verbose );
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
230 #endif /* ecdsa.h */
int ecdsa_from_keypair(ecdsa_context *ctx, const ecp_keypair *key)
Set an ECDSA context from an EC key pair.
int ecdsa_verify(ecp_group *grp, const unsigned char *buf, size_t blen, const ecp_point *Q, const mpi *r, const mpi *s)
Verify ECDSA signature of a previously hashed message.
Elliptic curves over GF(p)
int ecdsa_write_signature(ecdsa_context *ctx, 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...
int ecdsa_sign(ecp_group *grp, mpi *r, mpi *s, const 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.
ECP group structure.
Definition: ecp.h:133
int ecdsa_self_test(int verbose)
Checkup routine.
ecp_group grp
Definition: ecdsa.h:37
ECP key pair structure.
Definition: ecp.h:160
MPI structure.
Definition: bignum.h:182
md_type_t
Definition: md.h:48
ECP point structure (jacobian coordinates)
Definition: ecp.h:101
ECDSA context structure.
Definition: ecdsa.h:35
int ecdsa_read_signature(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 Q
Definition: ecdsa.h:39
void ecdsa_init(ecdsa_context *ctx)
Initialize context.
Generic message digest wrapper.
ecp_group_id
Domain parameters (curve, subgroup and generator) identifiers.
Definition: ecp.h:54
int ecdsa_genkey(ecdsa_context *ctx, ecp_group_id gid, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Generate an ECDSA keypair on the given curve.
int ecdsa_sign_det(ecp_group *grp, mpi *r, mpi *s, const mpi *d, const unsigned char *buf, size_t blen, md_type_t md_alg)
Compute ECDSA signature of a previously hashed message (deterministic version)
void ecdsa_free(ecdsa_context *ctx)
Free context.
int ecdsa_write_signature_det(ecdsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, md_type_t md_alg)
Compute ECDSA signature and write it to buffer, serialized as defined in RFC 4492 page 20...