PolarSSL v1.3.1
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 
37 typedef struct
38 {
40  mpi d;
42  mpi r;
43  mpi s;
44 }
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
66 int ecdsa_sign( ecp_group *grp, mpi *r, mpi *s,
67  const mpi *d, const unsigned char *buf, size_t blen,
68  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
69 
84 int ecdsa_verify( ecp_group *grp,
85  const unsigned char *buf, size_t blen,
86  const ecp_point *Q, const mpi *r, const mpi *s);
87 
110  const unsigned char *hash, size_t hlen,
111  unsigned char *sig, size_t *slen,
112  int (*f_rng)(void *, unsigned char *, size_t),
113  void *p_rng );
114 
129  const unsigned char *hash, size_t hlen,
130  const unsigned char *sig, size_t slen );
131 
144  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
145 
154 int ecdsa_from_keypair( ecdsa_context *ctx, const ecp_keypair *key );
155 
161 void ecdsa_init( ecdsa_context *ctx );
162 
168 void ecdsa_free( ecdsa_context *ctx );
169 
175 int ecdsa_self_test( int verbose );
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #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:117
int ecdsa_self_test(int verbose)
Checkup routine.
ecp_group grp
Definition: ecdsa.h:39
ECP key pair structure.
Definition: ecp.h:144
MPI structure.
Definition: bignum.h:168
ECP point structure (jacobian coordinates)
Definition: ecp.h:94
ECDSA context structure.
Definition: ecdsa.h:37
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:41
void ecdsa_init(ecdsa_context *ctx)
Initialize context.
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.
void ecdsa_free(ecdsa_context *ctx)
Free context.