blob: 8baa6b1b8b14f66a020022c897ecf448ecb1d2b4 [file] [log] [blame]
Manuel Pégourié-Gonnard2aea1412013-01-26 16:33:44 +01001/**
2 * \file ecdsa.h
3 *
4 * \brief Elliptic curve DSA
5 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02007 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
Manuel Pégourié-Gonnard2aea1412013-01-26 16:33:44 +010020 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000021 * This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard2aea1412013-01-26 16:33:44 +010022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#ifndef MBEDTLS_ECDSA_H
24#define MBEDTLS_ECDSA_H
Manuel Pégourié-Gonnard2aea1412013-01-26 16:33:44 +010025
Manuel Pégourié-Gonnardbdc96762013-10-03 11:50:39 +020026#include "ecp.h"
Manuel Pégourié-Gonnard887aa5b2014-04-04 13:57:20 +020027#include "md.h"
Manuel Pégourié-Gonnard4daaef72014-01-06 14:25:56 +010028
Manuel Pégourié-Gonnard63e93192015-03-31 11:15:48 +020029/*
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 */
Gilles Peskine9a8bb672017-11-02 17:09:49 +010043
44/**
45 * \brief Maximum ECDSA signature size for a given curve bit size
46 *
47 * \param bits Curve size in bits
48 * \return Maximum signature size in bytes
49 *
50 * \note This macro returns a compile-time constant if its argument
51 * is one. It may evaluate its argument multiple times; if
52 * this is a problem, call the function
53 * mbedtls_ecdsa_max_sig_len instead.
54 */
55#define MBEDTLS_ECDSA_MAX_SIG_LEN( bits ) \
56 ( /*T,L of SEQUENCE*/ ( ( bits ) >= 61 * 8 ? 3 : 2 ) + \
57 /*T,L of r,s*/ 2 * ( ( ( bits ) >= 127 * 8 ? 3 : 2 ) + \
58 /*V of r,s*/ ( ( bits ) + 8 ) / 8 ) )
59
60/**
61 * \brief Maximum ECDSA signature size for a given curve bit size
62 *
63 * \param bits Curve size in bits
64 * \return Maximum signature size in bytes
65 *
66 * \note If you need a compile-time constant, call the macro
67 * MBEDTLS_ECDSA_MAX_SIG_LEN instead.
68 */
69static inline size_t mbedtls_ecdsa_max_sig_len( size_t bits )
70{
71 return( MBEDTLS_ECDSA_MAX_SIG_LEN( bits ) );
72}
73
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020074#if MBEDTLS_ECP_MAX_BYTES > 124
75#error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN"
Manuel Pégourié-Gonnard63e93192015-03-31 11:15:48 +020076#endif
Manuel Pégourié-Gonnard5bf262d2015-03-31 11:46:01 +020077/** Maximum size of an ECDSA signature in bytes */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020078#define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) )
Manuel Pégourié-Gonnard63e93192015-03-31 11:15:48 +020079
Manuel Pégourié-Gonnardbec2f452013-06-27 10:17:07 +020080/**
81 * \brief ECDSA context structure
82 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020083typedef mbedtls_ecp_keypair mbedtls_ecdsa_context;
Manuel Pégourié-Gonnardbec2f452013-06-27 10:17:07 +020084
Manuel Pégourié-Gonnard2aea1412013-01-26 16:33:44 +010085#ifdef __cplusplus
86extern "C" {
87#endif
88
89/**
Manuel Pégourié-Gonnardb309ab22013-01-26 17:24:59 +010090 * \brief Compute ECDSA signature of a previously hashed message
91 *
Manuel Pégourié-Gonnardb8cfe3f2015-03-31 11:04:45 +020092 * \note The deterministic version is usually prefered.
93 *
Manuel Pégourié-Gonnardb309ab22013-01-26 17:24:59 +010094 * \param grp ECP group
95 * \param r First output integer
96 * \param s Second output integer
97 * \param d Private signing key
98 * \param buf Message hash
99 * \param blen Length of buf
100 * \param f_rng RNG function
101 * \param p_rng RNG parameter
102 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000103 * \note If the bitlength of the message hash is larger than the
104 * bitlength of the group order, then the hash is truncated as
105 * prescribed by SEC1 4.1.3 step 5.
106 *
Manuel Pégourié-Gonnardb309ab22013-01-26 17:24:59 +0100107 * \return 0 if successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200108 * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
Manuel Pégourié-Gonnardb309ab22013-01-26 17:24:59 +0100109 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200110int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
111 const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
Manuel Pégourié-Gonnardb309ab22013-01-26 17:24:59 +0100112 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
113
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200114#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
Manuel Pégourié-Gonnard4daaef72014-01-06 14:25:56 +0100115/**
Manuel Pégourié-Gonnardb8cfe3f2015-03-31 11:04:45 +0200116 * \brief Compute ECDSA signature of a previously hashed message,
117 * deterministic version (RFC 6979).
Manuel Pégourié-Gonnard4daaef72014-01-06 14:25:56 +0100118 *
119 * \param grp ECP group
120 * \param r First output integer
121 * \param s Second output integer
122 * \param d Private signing key
123 * \param buf Message hash
124 * \param blen Length of buf
125 * \param md_alg MD algorithm used to hash the message
126 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000127 * \note If the bitlength of the message hash is larger than the
128 * bitlength of the group order, then the hash is truncated as
129 * prescribed by SEC1 4.1.3 step 5.
130 *
Manuel Pégourié-Gonnard4daaef72014-01-06 14:25:56 +0100131 * \return 0 if successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200132 * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
Manuel Pégourié-Gonnard4daaef72014-01-06 14:25:56 +0100133 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200134int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
135 const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
136 mbedtls_md_type_t md_alg );
137#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
Manuel Pégourié-Gonnard4daaef72014-01-06 14:25:56 +0100138
Manuel Pégourié-Gonnardb309ab22013-01-26 17:24:59 +0100139/**
Manuel Pégourié-Gonnard3aeb5a72013-01-26 18:05:50 +0100140 * \brief Verify ECDSA signature of a previously hashed message
141 *
142 * \param grp ECP group
143 * \param buf Message hash
144 * \param blen Length of buf
145 * \param Q Public key to use for verification
146 * \param r First integer of the signature
147 * \param s Second integer of the signature
148 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000149 * \note If the bitlength of the message hash is larger than the
150 * bitlength of the group order, then the hash is truncated as
151 * prescribed by SEC1 4.1.4 step 3.
152 *
Manuel Pégourié-Gonnard3aeb5a72013-01-26 18:05:50 +0100153 * \return 0 if successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200154 * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid
155 * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
Manuel Pégourié-Gonnard3aeb5a72013-01-26 18:05:50 +0100156 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200157int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
Manuel Pégourié-Gonnard3aeb5a72013-01-26 18:05:50 +0100158 const unsigned char *buf, size_t blen,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200159 const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s);
Manuel Pégourié-Gonnard3aeb5a72013-01-26 18:05:50 +0100160
161/**
Manuel Pégourié-Gonnardaa431612013-08-09 17:10:27 +0200162 * \brief Compute ECDSA signature and write it to buffer,
163 * serialized as defined in RFC 4492 page 20.
Paul Bakker6838bd12013-09-30 13:56:38 +0200164 * (Not thread-safe to use same context in multiple threads)
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200165 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000166 * \note The deterministic version (RFC 6979) is used if
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200167 * MBEDTLS_ECDSA_DETERMINISTIC is defined.
Manuel Pégourié-Gonnarddfdcac92015-03-31 11:41:42 +0200168 *
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200169 * \param ctx ECDSA context
Manuel Pégourié-Gonnarddfdcac92015-03-31 11:41:42 +0200170 * \param md_alg Algorithm that was used to hash the message
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200171 * \param hash Message hash
172 * \param hlen Length of hash
173 * \param sig Buffer that will hold the signature
174 * \param slen Length of the signature written
175 * \param f_rng RNG function
176 * \param p_rng RNG parameter
177 *
Gilles Peskine9a8bb672017-11-02 17:09:49 +0100178 * \note The \c sig buffer must be at least
179 * `MBEDTLS_ECDSA_MAX_SIG_LEN(ctx->grp.pbits)` bytes long.
180 * MBEDTLS_ECDSA_MAX_LEN is always safe.
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200181 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000182 * \note If the bitlength of the message hash is larger than the
183 * bitlength of the group order, then the hash is truncated as
184 * prescribed by SEC1 4.1.3 step 5.
185 *
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200186 * \return 0 if successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200187 * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
188 * MBEDTLS_ERR_ASN1_XXX error code
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200189 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200190int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg,
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200191 const unsigned char *hash, size_t hlen,
192 unsigned char *sig, size_t *slen,
193 int (*f_rng)(void *, unsigned char *, size_t),
194 void *p_rng );
195
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200196#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
197#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
198#if defined(MBEDTLS_DEPRECATED_WARNING)
199#define MBEDTLS_DEPRECATED __attribute__((deprecated))
Manuel Pégourié-Gonnarddfdcac92015-03-31 11:41:42 +0200200#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200201#define MBEDTLS_DEPRECATED
Manuel Pégourié-Gonnarddfdcac92015-03-31 11:41:42 +0200202#endif
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100203/**
204 * \brief Compute ECDSA signature and write it to buffer,
205 * serialized as defined in RFC 4492 page 20.
206 * Deterministic version, RFC 6979.
207 * (Not thread-safe to use same context in multiple threads)
208 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200209 * \deprecated Superseded by mbedtls_ecdsa_write_signature() in 2.0.0
Manuel Pégourié-Gonnarddfdcac92015-03-31 11:41:42 +0200210 *
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100211 * \param ctx ECDSA context
212 * \param hash Message hash
213 * \param hlen Length of hash
214 * \param sig Buffer that will hold the signature
215 * \param slen Length of the signature written
216 * \param md_alg MD algorithm used to hash the message
217 *
Gilles Peskine9a8bb672017-11-02 17:09:49 +0100218 * \note The \c sig buffer must be at least
219 * `MBEDTLS_ECDSA_MAX_SIG_LEN(ctx->grp.pbits)` bytes long.
220 * MBEDTLS_ECDSA_MAX_LEN is always safe.
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100221 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000222 * \note If the bitlength of the message hash is larger than the
223 * bitlength of the group order, then the hash is truncated as
224 * prescribed by SEC1 4.1.3 step 5.
225 *
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100226 * \return 0 if successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200227 * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
228 * MBEDTLS_ERR_ASN1_XXX error code
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100229 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200230int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx,
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100231 const unsigned char *hash, size_t hlen,
232 unsigned char *sig, size_t *slen,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200233 mbedtls_md_type_t md_alg ) MBEDTLS_DEPRECATED;
234#undef MBEDTLS_DEPRECATED
235#endif /* MBEDTLS_DEPRECATED_REMOVED */
236#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
Manuel Pégourié-Gonnard937340b2014-01-06 10:27:16 +0100237
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200238/**
Andrzej Kurekc289bf12018-01-23 06:10:53 -0500239 * \brief Convert a signature from ASN.1 to a raw concatenation
240 * of {r,s}
241 *
242 * \param sig Signature to be converted
Andrzej Kurekb03bc432018-01-23 06:25:32 -0500243 * \param ssize Size of the signature
Andrzej Kurekc289bf12018-01-23 06:10:53 -0500244 * \param byte_len Length of a single number of the signature
Andrzej Kurekb03bc432018-01-23 06:25:32 -0500245 * \param buf Buffer pointer for the converted signature
246 * \param bufsize Size of the passed buffer
247 * \param buflen Size of the signature written to the buffer
Andrzej Kurekc289bf12018-01-23 06:10:53 -0500248 *
Andrzej Kurekb03bc432018-01-23 06:25:32 -0500249 * \note The size of the buffer \c bufsize should be at least
Andrzej Kurekc289bf12018-01-23 06:10:53 -0500250 * 2*byte_len bytes long, otherwise this function will
251 * return an error.
252 *
253 * \return 0 if successful, or a MBEDTLS_ERR_ECP_BAD_INPUT_DATA or
254 * MBEDTLS_ERR_ASN1_LENGTH_MISMATCH error code
255 *
256 */
257int mbedtls_ecdsa_signature_to_raw( const unsigned char *sig,
258 size_t ssize, uint16_t byte_len,
Andrzej Kurekdfedd822018-02-27 09:23:22 -0500259 unsigned char *buf, size_t* buflen,
260 size_t bufsize );
Andrzej Kurekc289bf12018-01-23 06:10:53 -0500261/**
Gilles Peskinebce41d32017-11-02 17:14:18 +0100262 * \brief Convert a signature from numbers to ASN.1
263 *
264 * \param r First number of the signature
265 * \param s Second number of the signature
266 * \param sig Buffer that will hold the signature
267 * \param slen Length of the signature written
268 * \param ssize Size of the sig buffer
269 *
270 * \note The size of the buffer \c ssize should be at least
271 * `MBEDTLS_ECDSA_MAX_SIG_LEN(grp->pbits)` bytes long if
272 * the signature was produced from curve \c grp,
273 * otherwise this function will return an error.
274 *
275 * \return 0 if successful,
276 * or a MBEDTLS_ERR_MPI_XXX or MBEDTLS_ERR_ASN1_XXX error code
277 *
278 */
Andrzej Kurekc289bf12018-01-23 06:10:53 -0500279int mbedtls_ecdsa_signature_to_asn1( const mbedtls_mpi *r,
280 const mbedtls_mpi *s, unsigned char *sig,
281 size_t *slen, size_t ssize );
Gilles Peskinebce41d32017-11-02 17:14:18 +0100282
283/**
Andrzej Kurekb91a3932018-03-01 09:09:55 -0500284 * \brief Convert a signature from a raw representation to ASN.1
285 *
286 * \param r First number of the signature
287 * \param s Second number of the signature
288 * \param num_len Length of each number in bytes
289 * \param sig Buffer that will hold the signature
290 * \param slen Length of the signature written
291 * \param ssize Size of the sig buffer
292 *
293 * \note The size of the buffer \c ssize should be at least
294 * `MBEDTLS_ECDSA_MAX_SIG_LEN(grp->pbits)` bytes long if
295 * the signature was produced from curve \c grp,
296 * otherwise this function will return an error.
297 *
298 * \return 0 if successful,
299 * or a MBEDTLS_ERR_MPI_XXX or MBEDTLS_ERR_ASN1_XXX error code
300 *
301 */
302int mbedtls_raw_ecdsa_signature_to_asn1(const unsigned char *r,
303 const unsigned char *s, uint16_t num_len,
304 unsigned char *sig, size_t *slen, size_t ssize );
305
306/**
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200307 * \brief Read and verify an ECDSA signature
308 *
309 * \param ctx ECDSA context
310 * \param hash Message hash
311 * \param hlen Size of hash
312 * \param sig Signature to read and verify
313 * \param slen Size of sig
314 *
Janos Follath0a5154b2017-03-10 11:31:41 +0000315 * \note If the bitlength of the message hash is larger than the
316 * bitlength of the group order, then the hash is truncated as
317 * prescribed by SEC1 4.1.4 step 3.
318 *
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200319 * \return 0 if successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200320 * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
321 * MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
Manuel Pégourié-Gonnard35e95dd2014-04-08 12:17:41 +0200322 * valid but its actual length is less than siglen,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200323 * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX error code
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200324 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200325int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx,
Manuel Pégourié-Gonnardb694b482013-08-08 13:30:57 +0200326 const unsigned char *hash, size_t hlen,
327 const unsigned char *sig, size_t slen );
328
329/**
Manuel Pégourié-Gonnard8eebd012013-08-09 16:21:34 +0200330 * \brief Generate an ECDSA keypair on the given curve
331 *
332 * \param ctx ECDSA context in which the keypair should be stored
Paul Bakkerdcbfdcc2013-09-10 16:16:50 +0200333 * \param gid Group (elliptic curve) to use. One of the various
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200334 * MBEDTLS_ECP_DP_XXX macros depending on configuration.
Manuel Pégourié-Gonnard8eebd012013-08-09 16:21:34 +0200335 * \param f_rng RNG function
336 * \param p_rng RNG parameter
337 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200338 * \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code.
Manuel Pégourié-Gonnard8eebd012013-08-09 16:21:34 +0200339 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200340int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid,
Manuel Pégourié-Gonnard8eebd012013-08-09 16:21:34 +0200341 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
342
343/**
Manuel Pégourié-Gonnardf4999932013-08-12 17:02:59 +0200344 * \brief Set an ECDSA context from an EC key pair
345 *
346 * \param ctx ECDSA context to set
347 * \param key EC key to use
348 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200349 * \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code.
Manuel Pégourié-Gonnardf4999932013-08-12 17:02:59 +0200350 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200351int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key );
Manuel Pégourié-Gonnardf4999932013-08-12 17:02:59 +0200352
353/**
Manuel Pégourié-Gonnard7c8934e2013-06-27 12:54:02 +0200354 * \brief Initialize context
355 *
356 * \param ctx Context to initialize
357 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200358void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx );
Manuel Pégourié-Gonnard7c8934e2013-06-27 12:54:02 +0200359
360/**
361 * \brief Free context
362 *
363 * \param ctx Context to free
364 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200365void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx );
Manuel Pégourié-Gonnard7c8934e2013-06-27 12:54:02 +0200366
Manuel Pégourié-Gonnard2aea1412013-01-26 16:33:44 +0100367#ifdef __cplusplus
368}
369#endif
370
Paul Bakker9af723c2014-05-01 13:03:14 +0200371#endif /* ecdsa.h */