2012-10-31 09:26:55 +01:00
|
|
|
/**
|
|
|
|
* \file ecp.h
|
|
|
|
*
|
|
|
|
* \brief Elliptic curves over GF(p)
|
|
|
|
*
|
2015-07-27 11:11:48 +02:00
|
|
|
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
2015-09-04 14:21:07 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2012-10-31 09:26:55 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2012-10-31 09:26:55 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-10-31 09:26:55 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2012-10-31 09:26:55 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
2012-10-31 09:26:55 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#ifndef MBEDTLS_ECP_H
|
|
|
|
#define MBEDTLS_ECP_H
|
2012-10-31 09:26:55 +01:00
|
|
|
|
2013-10-03 11:50:39 +02:00
|
|
|
#include "bignum.h"
|
2012-10-31 09:26:55 +01:00
|
|
|
|
|
|
|
/*
|
2012-11-05 10:06:12 +01:00
|
|
|
* ECP error codes
|
2012-10-31 09:26:55 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */
|
|
|
|
#define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00 /**< The buffer is too small to write to. */
|
|
|
|
#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80 /**< Requested curve not available. */
|
|
|
|
#define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00 /**< The signature is not valid. */
|
2015-05-28 09:33:39 +02:00
|
|
|
#define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 /**< Memory allocation failed. */
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as (ephemeral) key, failed. */
|
|
|
|
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */
|
|
|
|
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */
|
2012-11-02 09:40:25 +01:00
|
|
|
|
2013-06-27 14:29:21 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-16 16:19:53 +02:00
|
|
|
/**
|
|
|
|
* Domain parameters (curve, subgroup and generator) identifiers.
|
|
|
|
*
|
|
|
|
* Only curves over prime fields are supported.
|
|
|
|
*
|
|
|
|
* \warning This library does not support validation of arbitrary domain
|
|
|
|
* parameters. Therefore, only well-known domain parameters from trusted
|
2015-05-11 18:46:47 +02:00
|
|
|
* sources should be used. See mbedtls_ecp_group_load().
|
2013-09-16 16:19:53 +02:00
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
MBEDTLS_ECP_DP_NONE = 0,
|
|
|
|
MBEDTLS_ECP_DP_SECP192R1, /*!< 192-bits NIST curve */
|
|
|
|
MBEDTLS_ECP_DP_SECP224R1, /*!< 224-bits NIST curve */
|
|
|
|
MBEDTLS_ECP_DP_SECP256R1, /*!< 256-bits NIST curve */
|
|
|
|
MBEDTLS_ECP_DP_SECP384R1, /*!< 384-bits NIST curve */
|
|
|
|
MBEDTLS_ECP_DP_SECP521R1, /*!< 521-bits NIST curve */
|
|
|
|
MBEDTLS_ECP_DP_BP256R1, /*!< 256-bits Brainpool curve */
|
|
|
|
MBEDTLS_ECP_DP_BP384R1, /*!< 384-bits Brainpool curve */
|
|
|
|
MBEDTLS_ECP_DP_BP512R1, /*!< 512-bits Brainpool curve */
|
2015-06-23 00:18:41 +02:00
|
|
|
MBEDTLS_ECP_DP_CURVE25519, /*!< Curve25519 */
|
2015-04-08 12:49:31 +02:00
|
|
|
MBEDTLS_ECP_DP_SECP192K1, /*!< 192-bits "Koblitz" curve */
|
|
|
|
MBEDTLS_ECP_DP_SECP224K1, /*!< 224-bits "Koblitz" curve */
|
|
|
|
MBEDTLS_ECP_DP_SECP256K1, /*!< 256-bits "Koblitz" curve */
|
|
|
|
} mbedtls_ecp_group_id;
|
2013-09-16 16:19:53 +02:00
|
|
|
|
2013-09-23 18:14:50 +02:00
|
|
|
/**
|
2013-12-03 14:12:26 +01:00
|
|
|
* Number of supported curves (plus one for NONE).
|
|
|
|
*
|
|
|
|
* (Montgomery curves excluded for now.)
|
2013-09-23 18:14:50 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_DP_MAX 12
|
2013-09-23 18:14:50 +02:00
|
|
|
|
2013-09-16 17:30:04 +02:00
|
|
|
/**
|
2013-09-18 15:31:24 +02:00
|
|
|
* Curve information for use by other modules
|
2013-09-16 17:30:04 +02:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_group_id grp_id; /*!< Internal identifier */
|
2015-06-18 15:45:05 +02:00
|
|
|
uint16_t tls_id; /*!< TLS NamedCurve identifier */
|
|
|
|
uint16_t bit_size; /*!< Curve size in bits */
|
|
|
|
const char *name; /*!< Human-friendly name */
|
2015-04-08 12:49:31 +02:00
|
|
|
} mbedtls_ecp_curve_info;
|
2013-09-16 17:30:04 +02:00
|
|
|
|
2012-10-31 09:26:55 +01:00
|
|
|
/**
|
2012-11-19 20:16:28 +01:00
|
|
|
* \brief ECP point structure (jacobian coordinates)
|
2012-11-02 18:14:40 +01:00
|
|
|
*
|
2012-11-19 20:16:28 +01:00
|
|
|
* \note All functions expect and return points satisfying
|
|
|
|
* the following condition: Z == 0 or Z == 1. (Other
|
|
|
|
* values of Z are used by internal functions only.)
|
|
|
|
* The point is zero, or "at infinity", if Z == 0.
|
|
|
|
* Otherwise, X and Y are its standard (affine) coordinates.
|
2012-10-31 09:26:55 +01:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_mpi X; /*!< the point's X coordinate */
|
|
|
|
mbedtls_mpi Y; /*!< the point's Y coordinate */
|
|
|
|
mbedtls_mpi Z; /*!< the point's Z coordinate */
|
2012-10-31 09:26:55 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_point;
|
2012-10-31 09:26:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief ECP group structure
|
|
|
|
*
|
2013-12-05 10:26:01 +01:00
|
|
|
* We consider two types of curves equations:
|
|
|
|
* 1. Short Weierstrass y^2 = x^3 + A x + B mod P (SEC1 + RFC 4492)
|
2015-06-23 00:18:41 +02:00
|
|
|
* 2. Montgomery, y^2 = x^3 + A x^2 + x mod P (Curve25519 + draft)
|
2013-12-05 10:26:01 +01:00
|
|
|
* In both cases, a generator G for a prime-order subgroup is fixed. In the
|
|
|
|
* short weierstrass, this subgroup is actually the whole curve, and its
|
|
|
|
* cardinal is denoted by N.
|
2012-11-18 13:19:07 +01:00
|
|
|
*
|
2014-03-31 11:55:42 +02:00
|
|
|
* In the case of Short Weierstrass curves, our code requires that N is an odd
|
2015-04-08 12:49:31 +02:00
|
|
|
* prime. (Use odd in mbedtls_ecp_mul() and prime in mbedtls_ecdsa_sign() for blinding.)
|
2014-03-31 11:55:42 +02:00
|
|
|
*
|
2013-12-05 10:26:01 +01:00
|
|
|
* In the case of Montgomery curves, we don't store A but (A + 2) / 4 which is
|
2014-04-08 17:35:40 +02:00
|
|
|
* the quantity actually used in the formulas. Also, nbits is not the size of N
|
2013-12-05 10:26:01 +01:00
|
|
|
* but the required size for private keys.
|
2012-11-18 13:19:07 +01:00
|
|
|
*
|
2013-09-16 18:56:28 +02:00
|
|
|
* If modp is NULL, reduction modulo P is done using a generic algorithm.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Otherwise, it must point to a function that takes an mbedtls_mpi in the range
|
2013-09-16 18:56:28 +02:00
|
|
|
* 0..2^(2*pbits)-1 and transforms it in-place in an integer of little more
|
|
|
|
* than pbits, so that the integer may be efficiently brought in the 0..P-1
|
|
|
|
* range by a few additions or substractions. It must return 0 on success and
|
|
|
|
* non-zero on failure.
|
2012-10-31 09:26:55 +01:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_group_id id; /*!< internal group identifier */
|
|
|
|
mbedtls_mpi P; /*!< prime modulus of the base field */
|
|
|
|
mbedtls_mpi A; /*!< 1. A in the equation, or 2. (A + 2) / 4 */
|
|
|
|
mbedtls_mpi B; /*!< 1. B in the equation, or 2. unused */
|
|
|
|
mbedtls_ecp_point G; /*!< generator of the (sub)group used */
|
|
|
|
mbedtls_mpi N; /*!< 1. the order of G, or 2. unused */
|
2013-10-08 13:11:30 +02:00
|
|
|
size_t pbits; /*!< number of bits in P */
|
2013-12-05 10:26:01 +01:00
|
|
|
size_t nbits; /*!< number of bits in 1. P, or 2. private keys */
|
2013-12-06 12:51:50 +01:00
|
|
|
unsigned int h; /*!< internal: 1 if the constants are static */
|
2015-04-08 12:49:31 +02:00
|
|
|
int (*modp)(mbedtls_mpi *); /*!< function for fast reduction mod P */
|
|
|
|
int (*t_pre)(mbedtls_ecp_point *, void *); /*!< unused */
|
|
|
|
int (*t_post)(mbedtls_ecp_point *, void *); /*!< unused */
|
2013-12-05 10:26:01 +01:00
|
|
|
void *t_data; /*!< unused */
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_point *T; /*!< pre-computed points for ecp_mul_comb() */
|
2013-10-08 13:11:30 +02:00
|
|
|
size_t T_size; /*!< number for pre-computed points */
|
2012-10-31 09:26:55 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_group;
|
2012-10-31 09:26:55 +01:00
|
|
|
|
2013-07-01 13:40:52 +02:00
|
|
|
/**
|
|
|
|
* \brief ECP key pair structure
|
|
|
|
*
|
|
|
|
* A generic key pair that could be used for ECDSA, fixed ECDH, etc.
|
2013-08-14 18:16:50 +02:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \note Members purposefully in the same order as struc mbedtls_ecdsa_context.
|
2013-07-01 13:40:52 +02:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_group grp; /*!< Elliptic curve and base point */
|
|
|
|
mbedtls_mpi d; /*!< our secret value */
|
|
|
|
mbedtls_ecp_point Q; /*!< our public value */
|
2013-07-01 13:40:52 +02:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_ecp_keypair;
|
2013-07-01 13:40:52 +02:00
|
|
|
|
2014-04-25 11:11:10 +02:00
|
|
|
/**
|
|
|
|
* \name SECTION: Module settings
|
|
|
|
*
|
|
|
|
* The configuration options you can set for this module are in this section.
|
|
|
|
* Either change them in config.h or define them on the compiler command line.
|
|
|
|
* \{
|
|
|
|
*/
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_ECP_MAX_BITS)
|
2012-11-21 13:00:58 +01:00
|
|
|
/**
|
2013-08-08 13:30:57 +02:00
|
|
|
* Maximum size of the groups (that is, of N and P)
|
2012-11-21 13:00:58 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */
|
2013-12-11 16:02:58 +01:00
|
|
|
#endif
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 )
|
|
|
|
#define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 )
|
2012-11-21 13:00:58 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_ECP_WINDOW_SIZE)
|
2012-11-17 19:54:20 +01:00
|
|
|
/*
|
2013-11-20 18:39:55 +01:00
|
|
|
* Maximum "window" size used for point multiplication.
|
|
|
|
* Default: 6.
|
|
|
|
* Minimum value: 2. Maximum value: 7.
|
2012-11-17 19:54:20 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
|
2013-12-30 18:41:16 +01:00
|
|
|
* points used for point multiplication. This value is directly tied to EC
|
|
|
|
* peak memory usage, so decreasing it by one should roughly cut memory usage
|
|
|
|
* by two (if large curves are in use).
|
|
|
|
*
|
|
|
|
* Reduction in size may reduce speed, but larger curves are impacted first.
|
|
|
|
* Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
|
|
|
|
* w-size: 6 5 4 3 2
|
|
|
|
* 521 145 141 135 120 97
|
|
|
|
* 384 214 209 198 177 146
|
|
|
|
* 256 320 320 303 262 226
|
2014-04-25 11:11:10 +02:00
|
|
|
|
2013-12-30 18:41:16 +01:00
|
|
|
* 224 475 475 453 398 342
|
|
|
|
* 192 640 640 633 587 476
|
2012-11-17 19:54:20 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */
|
|
|
|
#endif /* MBEDTLS_ECP_WINDOW_SIZE */
|
2013-12-30 18:41:16 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
|
2013-12-30 18:41:16 +01:00
|
|
|
/*
|
|
|
|
* Trade memory for speed on fixed-point multiplication.
|
|
|
|
*
|
|
|
|
* This speeds up repeated multiplication of the generator (that is, the
|
|
|
|
* multiplication in ECDSA signatures, and half of the multiplications in
|
|
|
|
* ECDSA verification and ECDHE) by a factor roughly 3 to 4.
|
|
|
|
*
|
|
|
|
* The cost is increasing EC peak memory usage by a factor roughly 2.
|
|
|
|
*
|
|
|
|
* Change this value to 0 to reduce peak memory usage.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */
|
|
|
|
#endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
|
2012-11-17 19:54:20 +01:00
|
|
|
|
2014-04-25 11:11:10 +02:00
|
|
|
/* \} name SECTION: Module settings */
|
|
|
|
|
2012-11-24 15:19:55 +01:00
|
|
|
/*
|
2013-02-09 19:00:07 +01:00
|
|
|
* Point formats, from RFC 4492's enum ECPointFormat
|
2012-11-24 15:19:55 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format */
|
|
|
|
#define MBEDTLS_ECP_PF_COMPRESSED 1 /**< Compressed point format */
|
2012-11-24 15:19:55 +01:00
|
|
|
|
2013-02-09 17:03:58 +01:00
|
|
|
/*
|
2013-02-09 19:00:07 +01:00
|
|
|
* Some other constants from RFC 4492
|
2013-02-09 17:03:58 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */
|
2013-02-09 17:03:58 +01:00
|
|
|
|
2013-09-18 15:31:24 +02:00
|
|
|
/**
|
2014-02-04 14:48:50 +01:00
|
|
|
* \brief Get the list of supported curves in order of preferrence
|
|
|
|
* (full information)
|
2013-09-18 15:31:24 +02:00
|
|
|
*
|
|
|
|
* \return A statically allocated array, the last entry is 0.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void );
|
2013-09-18 15:31:24 +02:00
|
|
|
|
2014-02-04 14:48:50 +01:00
|
|
|
/**
|
|
|
|
* \brief Get the list of supported curves in order of preferrence
|
|
|
|
* (grp_id only)
|
|
|
|
*
|
|
|
|
* \return A statically allocated array,
|
2015-04-08 12:49:31 +02:00
|
|
|
* terminated with MBEDTLS_ECP_DP_NONE.
|
2014-02-04 14:48:50 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void );
|
2014-02-04 14:48:50 +01:00
|
|
|
|
2013-10-23 20:19:57 +02:00
|
|
|
/**
|
|
|
|
* \brief Get curve information from an internal group identifier
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \param grp_id A MBEDTLS_ECP_DP_XXX value
|
2013-10-23 20:19:57 +02:00
|
|
|
*
|
|
|
|
* \return The associated curve information or NULL
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id );
|
2013-10-23 20:19:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get curve information from a TLS NamedCurve value
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \param tls_id A MBEDTLS_ECP_DP_XXX value
|
2013-10-23 20:19:57 +02:00
|
|
|
*
|
|
|
|
* \return The associated curve information or NULL
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id );
|
2013-10-23 20:19:57 +02:00
|
|
|
|
2013-11-30 15:10:14 +01:00
|
|
|
/**
|
|
|
|
* \brief Get curve information from a human-readable name
|
|
|
|
*
|
|
|
|
* \param name The name
|
|
|
|
*
|
|
|
|
* \return The associated curve information or NULL
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name );
|
2013-11-30 15:10:14 +01:00
|
|
|
|
2012-11-02 18:14:40 +01:00
|
|
|
/**
|
2012-11-05 13:13:44 +01:00
|
|
|
* \brief Initialize a point (as zero)
|
2012-11-02 18:14:40 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_ecp_point_init( mbedtls_ecp_point *pt );
|
2012-11-02 18:14:40 +01:00
|
|
|
|
2012-11-05 17:27:54 +01:00
|
|
|
/**
|
|
|
|
* \brief Initialize a group (to something meaningless)
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_ecp_group_init( mbedtls_ecp_group *grp );
|
2012-11-05 17:27:54 +01:00
|
|
|
|
2013-07-01 13:40:52 +02:00
|
|
|
/**
|
|
|
|
* \brief Initialize a key pair (as an invalid one)
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key );
|
2013-07-01 13:40:52 +02:00
|
|
|
|
2012-11-02 09:40:25 +01:00
|
|
|
/**
|
|
|
|
* \brief Free the components of a point
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_ecp_point_free( mbedtls_ecp_point *pt );
|
2012-11-02 09:40:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Free the components of an ECP group
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_ecp_group_free( mbedtls_ecp_group *grp );
|
2012-11-02 09:40:25 +01:00
|
|
|
|
2013-07-01 13:40:52 +02:00
|
|
|
/**
|
|
|
|
* \brief Free the components of a key pair
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key );
|
2013-07-01 13:40:52 +02:00
|
|
|
|
2012-11-02 18:14:40 +01:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Copy the contents of point Q into P
|
2012-11-19 20:16:28 +01:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param P Destination point
|
|
|
|
* \param Q Source point
|
2013-01-26 16:05:22 +01:00
|
|
|
*
|
2012-11-19 20:16:28 +01:00
|
|
|
* \return 0 if successful,
|
2015-05-28 09:33:39 +02:00
|
|
|
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
|
2012-11-02 18:14:40 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q );
|
2012-11-02 18:14:40 +01:00
|
|
|
|
2013-01-26 16:05:22 +01:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Copy the contents of a group object
|
2013-01-26 16:05:22 +01:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param dst Destination group
|
|
|
|
* \param src Source group
|
2013-01-26 16:05:22 +01:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \return 0 if successful,
|
2015-05-28 09:33:39 +02:00
|
|
|
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
|
2013-01-26 16:05:22 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src );
|
2013-01-26 16:05:22 +01:00
|
|
|
|
2012-11-02 09:40:25 +01:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Set a point to zero
|
2012-11-02 09:40:25 +01:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param pt Destination point
|
2012-11-02 09:40:25 +01:00
|
|
|
*
|
2012-11-05 10:06:12 +01:00
|
|
|
* \return 0 if successful,
|
2015-05-28 09:33:39 +02:00
|
|
|
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
|
2012-11-02 09:40:25 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt );
|
2012-11-02 09:40:25 +01:00
|
|
|
|
2013-08-12 15:44:31 +02:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Tell if a point is zero
|
2013-08-12 15:44:31 +02:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param pt Point to test
|
2013-08-12 15:44:31 +02:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \return 1 if point is zero, 0 otherwise
|
2013-08-12 15:44:31 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt );
|
2013-08-12 15:44:31 +02:00
|
|
|
|
2012-11-05 13:13:44 +01:00
|
|
|
/**
|
|
|
|
* \brief Import a non-zero point from two ASCII strings
|
|
|
|
*
|
|
|
|
* \param P Destination point
|
|
|
|
* \param radix Input numeric base
|
|
|
|
* \param x First affine coordinate as a null-terminated string
|
|
|
|
* \param y Second affine coordinate as a null-terminated string
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code
|
2012-11-05 13:13:44 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix,
|
2012-11-05 13:13:44 +01:00
|
|
|
const char *x, const char *y );
|
|
|
|
|
2012-11-24 14:10:14 +01:00
|
|
|
/**
|
2012-11-24 15:19:55 +01:00
|
|
|
* \brief Export a point into unsigned binary data
|
2012-11-24 14:10:14 +01:00
|
|
|
*
|
2012-11-24 16:19:42 +01:00
|
|
|
* \param grp Group to which the point should belong
|
2012-11-24 14:10:14 +01:00
|
|
|
* \param P Point to export
|
2015-04-08 12:49:31 +02:00
|
|
|
* \param format Point format, should be a MBEDTLS_ECP_PF_XXX macro
|
2013-02-09 19:00:07 +01:00
|
|
|
* \param olen Length of the actual output
|
2012-11-24 14:10:14 +01:00
|
|
|
* \param buf Output buffer
|
|
|
|
* \param buflen Length of the output buffer
|
|
|
|
*
|
2013-02-09 19:00:07 +01:00
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* or MBEDTLS_ERR_ECP_BAD_INPUT_DATA
|
|
|
|
* or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
|
2012-11-24 14:10:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P,
|
2013-02-10 12:22:46 +01:00
|
|
|
int format, size_t *olen,
|
2013-02-10 10:58:48 +01:00
|
|
|
unsigned char *buf, size_t buflen );
|
2012-11-24 14:10:14 +01:00
|
|
|
|
2012-11-24 16:19:42 +01:00
|
|
|
/**
|
|
|
|
* \brief Import a point from unsigned binary data
|
|
|
|
*
|
|
|
|
* \param grp Group to which the point should belong
|
|
|
|
* \param P Point to import
|
|
|
|
* \param buf Input buffer
|
|
|
|
* \param ilen Actual length of input
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid,
|
2015-05-28 09:33:39 +02:00
|
|
|
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format
|
2014-03-19 16:18:38 +01:00
|
|
|
* is not implemented.
|
2012-11-24 16:19:42 +01:00
|
|
|
*
|
|
|
|
* \note This function does NOT check that the point actually
|
2015-04-08 12:49:31 +02:00
|
|
|
* belongs to the given group, see mbedtls_ecp_check_pubkey() for
|
2012-11-24 16:19:42 +01:00
|
|
|
* that.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P,
|
2013-02-10 10:58:48 +01:00
|
|
|
const unsigned char *buf, size_t ilen );
|
2013-02-09 17:03:58 +01:00
|
|
|
|
2012-11-07 20:24:05 +01:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Import a point from a TLS ECPoint record
|
2013-02-09 17:03:58 +01:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param grp ECP group used
|
|
|
|
* \param pt Destination point
|
|
|
|
* \param buf $(Start of input buffer)
|
2013-02-09 17:03:58 +01:00
|
|
|
* \param len Buffer length
|
|
|
|
*
|
2014-11-21 09:14:52 +01:00
|
|
|
* \note buf is updated to point right after the ECPoint on exit
|
|
|
|
*
|
2015-05-12 12:56:41 +02:00
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_MPI_XXX if initialization failed
|
|
|
|
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid
|
2012-11-07 20:24:05 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt,
|
2013-10-23 20:19:57 +02:00
|
|
|
const unsigned char **buf, size_t len );
|
2012-11-07 20:24:05 +01:00
|
|
|
|
2013-02-10 12:06:19 +01:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Export a point as a TLS ECPoint record
|
2013-02-10 12:06:19 +01:00
|
|
|
*
|
|
|
|
* \param grp ECP group used
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param pt Point to export
|
|
|
|
* \param format Export format
|
|
|
|
* \param olen length of data written
|
2013-02-10 12:06:19 +01:00
|
|
|
* \param buf Buffer to write to
|
|
|
|
* \param blen Buffer length
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* or MBEDTLS_ERR_ECP_BAD_INPUT_DATA
|
|
|
|
* or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
|
2013-02-10 12:06:19 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt,
|
2013-10-23 20:19:57 +02:00
|
|
|
int format, size_t *olen,
|
2013-02-10 12:06:19 +01:00
|
|
|
unsigned char *buf, size_t blen );
|
|
|
|
|
2013-09-16 16:19:53 +02:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Set a group using well-known domain parameters
|
2013-09-16 16:19:53 +02:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param grp Destination group
|
|
|
|
* \param index Index in the list of well-known domain parameters
|
2013-09-16 16:19:53 +02:00
|
|
|
*
|
2015-05-12 12:56:41 +02:00
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_MPI_XXX if initialization failed
|
|
|
|
* MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE for unkownn groups
|
2013-10-23 20:19:57 +02:00
|
|
|
*
|
2015-05-11 18:11:57 +02:00
|
|
|
* \note Index should be a value of RFC 4492's enum NamedCurve,
|
|
|
|
* usually in the form of a MBEDTLS_ECP_DP_XXX macro.
|
2013-09-16 16:19:53 +02:00
|
|
|
*/
|
2015-05-11 18:46:47 +02:00
|
|
|
int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id index );
|
2013-09-16 16:19:53 +02:00
|
|
|
|
2013-02-09 19:00:07 +01:00
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Set a group from a TLS ECParameters record
|
2013-02-09 19:00:07 +01:00
|
|
|
*
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param grp Destination group
|
|
|
|
* \param buf &(Start of input buffer)
|
2013-02-09 19:00:07 +01:00
|
|
|
* \param len Buffer length
|
|
|
|
*
|
2014-11-21 09:14:52 +01:00
|
|
|
* \note buf is updated to point right after ECParameters on exit
|
|
|
|
*
|
2015-05-12 12:56:41 +02:00
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_MPI_XXX if initialization failed
|
|
|
|
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid
|
2013-02-09 19:00:07 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len );
|
2013-02-09 19:00:07 +01:00
|
|
|
|
|
|
|
/**
|
2013-10-23 20:19:57 +02:00
|
|
|
* \brief Write the TLS ECParameters record for a group
|
2013-02-09 19:00:07 +01:00
|
|
|
*
|
|
|
|
* \param grp ECP group used
|
2013-10-23 20:19:57 +02:00
|
|
|
* \param olen Number of bytes actually written
|
2013-02-09 19:00:07 +01:00
|
|
|
* \param buf Buffer to write to
|
2013-09-10 16:16:50 +02:00
|
|
|
* \param blen Buffer length
|
2013-02-09 19:00:07 +01:00
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
|
2013-02-09 19:00:07 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen,
|
2013-02-10 12:22:46 +01:00
|
|
|
unsigned char *buf, size_t blen );
|
2013-02-09 19:00:07 +01:00
|
|
|
|
2012-10-31 09:26:55 +01:00
|
|
|
/**
|
|
|
|
* \brief Multiplication by an integer: R = m * P
|
2013-09-30 13:56:38 +02:00
|
|
|
* (Not thread-safe to use same group in multiple threads)
|
2012-10-31 09:26:55 +01:00
|
|
|
*
|
2015-05-11 18:40:45 +02:00
|
|
|
* \note In order to prevent timing attacks, this function
|
|
|
|
* executes the exact same sequence of (base field)
|
|
|
|
* operations for any valid m. It avoids any if-branch or
|
|
|
|
* array index depending on the value of m.
|
|
|
|
*
|
|
|
|
* \note If f_rng is not NULL, it is used to randomize intermediate
|
|
|
|
* results in order to prevent potential timing attacks
|
|
|
|
* targeting these results. It is recommended to always
|
|
|
|
* provide a non-NULL f_rng (the overhead is negligible).
|
|
|
|
*
|
2012-10-31 09:26:55 +01:00
|
|
|
* \param grp ECP group
|
|
|
|
* \param R Destination point
|
|
|
|
* \param m Integer by which to multiply
|
|
|
|
* \param P Point to multiply
|
2013-09-02 14:29:09 +02:00
|
|
|
* \param f_rng RNG function (see notes)
|
|
|
|
* \param p_rng RNG parameter
|
2012-10-31 09:26:55 +01:00
|
|
|
*
|
2012-11-05 10:06:12 +01:00
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ECP_INVALID_KEY if m is not a valid privkey
|
2013-11-21 09:28:03 +01:00
|
|
|
* or P is not a valid pubkey,
|
2015-05-28 09:33:39 +02:00
|
|
|
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
|
2012-10-31 09:26:55 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|
|
|
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
|
2013-11-20 23:06:14 +01:00
|
|
|
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
|
2012-10-31 09:26:55 +01:00
|
|
|
|
2015-05-11 18:40:45 +02:00
|
|
|
/**
|
|
|
|
* \brief Multiplication and addition of two points by integers:
|
|
|
|
* R = m * P + n * Q
|
|
|
|
* (Not thread-safe to use same group in multiple threads)
|
|
|
|
*
|
2015-05-14 13:55:51 +02:00
|
|
|
* \note In contrast to mbedtls_ecp_mul(), this function does not guarantee
|
2015-05-11 18:40:45 +02:00
|
|
|
* a constant execution flow and timing.
|
|
|
|
*
|
|
|
|
* \param grp ECP group
|
|
|
|
* \param R Destination point
|
|
|
|
* \param m Integer by which to multiply P
|
|
|
|
* \param P Point to multiply by m
|
|
|
|
* \param n Integer by which to multiply Q
|
|
|
|
* \param Q Point to be multiplied by n
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
|
|
|
* MBEDTLS_ERR_ECP_INVALID_KEY if m or n is not a valid privkey
|
|
|
|
* or P or Q is not a valid pubkey,
|
2015-05-28 09:33:39 +02:00
|
|
|
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
|
2015-05-11 18:40:45 +02:00
|
|
|
*/
|
|
|
|
int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|
|
|
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
|
|
|
|
const mbedtls_mpi *n, const mbedtls_ecp_point *Q );
|
|
|
|
|
2013-07-01 14:06:13 +02:00
|
|
|
/**
|
|
|
|
* \brief Check that a point is a valid public key on this curve
|
|
|
|
*
|
|
|
|
* \param grp Curve/group the point should belong to
|
|
|
|
* \param pt Point to check
|
|
|
|
*
|
|
|
|
* \return 0 if point is a valid public key,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ECP_INVALID_KEY otherwise.
|
2013-07-01 14:06:13 +02:00
|
|
|
*
|
|
|
|
* \note This function only checks the point is non-zero, has valid
|
|
|
|
* coordinates and lies on the curve, but not that it is
|
|
|
|
* indeed a multiple of G. This is additional check is more
|
|
|
|
* expensive, isn't required by standards, and shouldn't be
|
|
|
|
* necessary if the group used has a small cofactor. In
|
|
|
|
* particular, it is useless for the NIST groups which all
|
|
|
|
* have a cofactor of 1.
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \note Uses bare components rather than an mbedtls_ecp_keypair structure
|
2013-07-01 14:06:13 +02:00
|
|
|
* in order to ease use with other structures such as
|
2015-04-08 12:49:31 +02:00
|
|
|
* mbedtls_ecdh_context of mbedtls_ecdsa_context.
|
2013-07-01 14:06:13 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt );
|
2013-07-01 14:06:13 +02:00
|
|
|
|
|
|
|
/**
|
2015-04-08 12:49:31 +02:00
|
|
|
* \brief Check that an mbedtls_mpi is a valid private key for this curve
|
2013-07-01 14:06:13 +02:00
|
|
|
*
|
|
|
|
* \param grp Group used
|
|
|
|
* \param d Integer to check
|
|
|
|
*
|
|
|
|
* \return 0 if point is a valid private key,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ECP_INVALID_KEY otherwise.
|
2013-07-01 14:06:13 +02:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \note Uses bare components rather than an mbedtls_ecp_keypair structure
|
2013-07-01 14:06:13 +02:00
|
|
|
* in order to ease use with other structures such as
|
2015-04-08 12:49:31 +02:00
|
|
|
* mbedtls_ecdh_context of mbedtls_ecdsa_context.
|
2013-07-01 14:06:13 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d );
|
2013-07-01 14:06:13 +02:00
|
|
|
|
2013-01-26 14:42:45 +01:00
|
|
|
/**
|
|
|
|
* \brief Generate a keypair
|
|
|
|
*
|
|
|
|
* \param grp ECP group
|
|
|
|
* \param d Destination MPI (secret part)
|
|
|
|
* \param Q Destination point (public part)
|
|
|
|
* \param f_rng RNG function
|
|
|
|
* \param p_rng RNG parameter
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
|
2013-07-01 14:06:13 +02:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \note Uses bare components rather than an mbedtls_ecp_keypair structure
|
2013-07-01 14:06:13 +02:00
|
|
|
* in order to ease use with other structures such as
|
2015-04-08 12:49:31 +02:00
|
|
|
* mbedtls_ecdh_context of mbedtls_ecdsa_context.
|
2013-01-26 14:42:45 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q,
|
2013-01-26 14:42:45 +01:00
|
|
|
int (*f_rng)(void *, unsigned char *, size_t),
|
|
|
|
void *p_rng );
|
|
|
|
|
2013-11-30 14:13:16 +01:00
|
|
|
/**
|
|
|
|
* \brief Generate a keypair
|
|
|
|
*
|
|
|
|
* \param grp_id ECP group identifier
|
|
|
|
* \param key Destination keypair
|
|
|
|
* \param f_rng RNG function
|
|
|
|
* \param p_rng RNG parameter
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
|
2013-11-30 14:13:16 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
|
2013-11-30 14:13:16 +01:00
|
|
|
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
|
|
|
|
|
2014-11-06 15:25:32 +01:00
|
|
|
/**
|
|
|
|
* \brief Check a public-private key pair
|
|
|
|
*
|
|
|
|
* \param pub Keypair structure holding a public key
|
|
|
|
* \param prv Keypair structure holding a private (plus public) key
|
|
|
|
*
|
2015-04-14 15:00:09 +02:00
|
|
|
* \return 0 if successful (keys are valid and match), or
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA, or
|
|
|
|
* a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX code.
|
2014-11-06 15:25:32 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv );
|
2014-11-06 15:25:32 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_SELF_TEST)
|
2012-10-31 09:26:55 +01:00
|
|
|
/**
|
|
|
|
* \brief Checkup routine
|
|
|
|
*
|
2014-03-27 20:12:44 +01:00
|
|
|
* \return 0 if successful, or 1 if a test failed
|
2012-10-31 09:26:55 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_ecp_self_test( int verbose );
|
2014-03-27 20:12:44 +01:00
|
|
|
#endif
|
2012-10-31 09:26:55 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-01 13:03:14 +02:00
|
|
|
#endif /* ecp.h */
|