PolarSSL v1.3.4
ecdsa.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_ECDSA_H
28 #define POLARSSL_ECDSA_H
29 
30 #include "ecp.h"
31 
32 #if defined(POLARSSL_ECDSA_DETERMINISTIC)
33 #include "polarssl/md.h"
34 #endif
35 
41 typedef struct
42 {
44  mpi d;
46  mpi r;
47  mpi s;
48 }
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
70 int ecdsa_sign( ecp_group *grp, mpi *r, mpi *s,
71  const mpi *d, const unsigned char *buf, size_t blen,
72  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
73 
74 #if defined(POLARSSL_ECDSA_DETERMINISTIC)
75 
90 int ecdsa_sign_det( ecp_group *grp, mpi *r, mpi *s,
91  const mpi *d, const unsigned char *buf, size_t blen,
92  md_type_t md_alg );
93 #endif
94 
109 int ecdsa_verify( ecp_group *grp,
110  const unsigned char *buf, size_t blen,
111  const ecp_point *Q, const mpi *r, const mpi *s);
112 
135  const unsigned char *hash, size_t hlen,
136  unsigned char *sig, size_t *slen,
137  int (*f_rng)(void *, unsigned char *, size_t),
138  void *p_rng );
139 
140 #if defined(POLARSSL_ECDSA_DETERMINISTIC)
141 
163  const unsigned char *hash, size_t hlen,
164  unsigned char *sig, size_t *slen,
165  md_type_t md_alg );
166 #endif
167 
182  const unsigned char *hash, size_t hlen,
183  const unsigned char *sig, size_t slen );
184 
197  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
198 
207 int ecdsa_from_keypair( ecdsa_context *ctx, const ecp_keypair *key );
208 
214 void ecdsa_init( ecdsa_context *ctx );
215 
221 void ecdsa_free( ecdsa_context *ctx );
222 
228 int ecdsa_self_test( int verbose );
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
234 #endif
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:132
int ecdsa_self_test(int verbose)
Checkup routine.
ecp_group grp
Definition: ecdsa.h:43
ECP key pair structure.
Definition: ecp.h:159
MPI structure.
Definition: bignum.h:177
md_type_t
Definition: md.h:51
ECP point structure (jacobian coordinates)
Definition: ecp.h:103
ECDSA context structure.
Definition: ecdsa.h:41
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:45
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:56
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...