RetroArch
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 
80  const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
81  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
82 
83 #if defined(MBEDTLS_ECDSA_DETERMINISTIC)
84 
104  const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
105  mbedtls_md_type_t md_alg );
106 #endif /* MBEDTLS_ECDSA_DETERMINISTIC */
107 
127  const unsigned char *buf, size_t blen,
128  const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s);
129 
160  const unsigned char *hash, size_t hlen,
161  unsigned char *sig, size_t *slen,
162  int (*f_rng)(void *, unsigned char *, size_t),
163  void *p_rng );
164 
165 #if defined(MBEDTLS_ECDSA_DETERMINISTIC)
166 #if ! defined(MBEDTLS_DEPRECATED_REMOVED)
167 #if defined(MBEDTLS_DEPRECATED_WARNING)
168 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
169 #else
170 #define MBEDTLS_DEPRECATED
171 #endif
172 
200  const unsigned char *hash, size_t hlen,
201  unsigned char *sig, size_t *slen,
203 #undef MBEDTLS_DEPRECATED
204 #endif /* MBEDTLS_DEPRECATED_REMOVED */
205 #endif /* MBEDTLS_ECDSA_DETERMINISTIC */
206 
227  const unsigned char *hash, size_t hlen,
228  const unsigned char *sig, size_t slen );
229 
242  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
243 
253 
260 
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif /* ecdsa.h */
Elliptic curves over GF(p)
#define MBEDTLS_DEPRECATED
Definition: ecdsa.h:170
ECP group structure.
Definition: ecp.h:138
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
GLdouble GLdouble GLdouble r
Definition: glext.h:6406
GLdouble s
Definition: glext.h:6390
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.
Definition: ecdsa.c:199
mbedtls_md_type_t
Definition: md.h:39
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.
Definition: ecdsa.c:72
void mbedtls_ecdsa_free(mbedtls_ecdsa_context *ctx)
Free context.
Definition: ecdsa.c:443
AVFormatContext * ctx
Definition: record_ffmpeg.c:247
int mbedtls_ecdsa_sign_det(mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, mbedtls_md_type_t md_alg)
Compute ECDSA signature of a previously hashed message, deterministic version (RFC 6979).
Definition: ecdsa.c:161
Generic message digest wrapper.
mbedtls_ecp_keypair mbedtls_ecdsa_context
ECDSA context structure.
Definition: ecdsa.h:52
int mbedtls_ecdsa_write_signature_det(mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, mbedtls_md_type_t md_alg) MBEDTLS_DEPRECATED
Compute ECDSA signature and write it to buffer, serialized as defined in RFC 4492 page 20....
Definition: ecdsa.c:344
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....
Definition: ecdsa.c:308
ECP point structure (jacobian coordinates)
Definition: ecp.h:106
MPI structure.
Definition: bignum.h:179
static const size_t slen[MAX_TESTS]
Definition: pkcs5.c:314
int mbedtls_ecdsa_from_keypair(mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key)
Set an ECDSA context from an EC key pair.
Definition: ecdsa.c:418
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.
Definition: ecdsa.c:357
void mbedtls_ecdsa_init(mbedtls_ecdsa_context *ctx)
Initialize context.
Definition: ecdsa.c:435
mbedtls_ecp_group_id
Definition: ecp.h:62
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.
Definition: ecdsa.c:408
ECP key pair structure.
Definition: ecp.h:165