Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file ecp.h |
| 3 | * |
| 4 | * \brief Elliptic curves over GF(p) |
| 5 | * |
Paul Bakker | cf4365f | 2013-01-16 17:00:43 +0100 | [diff] [blame] | 6 | * Copyright (C) 2006-2013, Brainspark B.V. |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 10 | * |
| 11 | * All rights reserved. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 26 | */ |
| 27 | #ifndef POLARSSL_ECP_H |
| 28 | #define POLARSSL_ECP_H |
| 29 | |
| 30 | #include "bignum.h" |
| 31 | |
| 32 | /* |
Manuel Pégourié-Gonnard | 7cfcea3 | 2012-11-05 10:06:12 +0100 | [diff] [blame] | 33 | * ECP error codes |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 34 | */ |
Paul Bakker | cf4365f | 2013-01-16 17:00:43 +0100 | [diff] [blame] | 35 | #define POLARSSL_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */ |
| 36 | #define POLARSSL_ERR_ECP_GENERIC -0x4F00 /**< Generic ECP error */ |
Manuel Pégourié-Gonnard | 883f313 | 2012-11-02 09:40:25 +0100 | [diff] [blame] | 37 | |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 38 | /** |
Manuel Pégourié-Gonnard | 1c2782c | 2012-11-19 20:16:28 +0100 | [diff] [blame] | 39 | * \brief ECP point structure (jacobian coordinates) |
Manuel Pégourié-Gonnard | ae180d0 | 2012-11-02 18:14:40 +0100 | [diff] [blame] | 40 | * |
Manuel Pégourié-Gonnard | 1c2782c | 2012-11-19 20:16:28 +0100 | [diff] [blame] | 41 | * \note All functions expect and return points satisfying |
| 42 | * the following condition: Z == 0 or Z == 1. (Other |
| 43 | * values of Z are used by internal functions only.) |
| 44 | * The point is zero, or "at infinity", if Z == 0. |
| 45 | * Otherwise, X and Y are its standard (affine) coordinates. |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 46 | */ |
| 47 | typedef struct |
| 48 | { |
Manuel Pégourié-Gonnard | 5179e46 | 2012-10-31 19:37:54 +0100 | [diff] [blame] | 49 | mpi X; /*!< the point's X coordinate */ |
| 50 | mpi Y; /*!< the point's Y coordinate */ |
Manuel Pégourié-Gonnard | 1c2782c | 2012-11-19 20:16:28 +0100 | [diff] [blame] | 51 | mpi Z; /*!< the point's Z coordinate */ |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 52 | } |
| 53 | ecp_point; |
| 54 | |
| 55 | /** |
| 56 | * \brief ECP group structure |
| 57 | * |
Manuel Pégourié-Gonnard | 773ed54 | 2012-11-18 13:19:07 +0100 | [diff] [blame] | 58 | * The curves we consider are defined by y^2 = x^3 - 3x + B mod P, |
| 59 | * and a generator for a large subgroup of order N is fixed. |
Manuel Pégourié-Gonnard | 62aad14 | 2012-11-10 00:27:12 +0100 | [diff] [blame] | 60 | * |
Manuel Pégourié-Gonnard | 773ed54 | 2012-11-18 13:19:07 +0100 | [diff] [blame] | 61 | * pbits and nbits must be the size of P and N in bits. |
Manuel Pégourié-Gonnard | 4712325 | 2012-11-10 14:44:24 +0100 | [diff] [blame] | 62 | * |
Manuel Pégourié-Gonnard | 773ed54 | 2012-11-18 13:19:07 +0100 | [diff] [blame] | 63 | * If modp is NULL, reduction modulo P is done using a generic |
| 64 | * algorithm. Otherwise, it must point to a function that takes an mpi |
| 65 | * in the range 0..2^(2*pbits) and transforms it in-place in an integer |
| 66 | * of little more than pbits, so that the integer may be efficiently |
| 67 | * brought in the 0..P range by a few additions or substractions. It |
| 68 | * must return 0 on success and a POLARSSL_ERR_ECP_XXX error on failure. |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 69 | */ |
| 70 | typedef struct |
| 71 | { |
| 72 | mpi P; /*!< prime modulus of the base field */ |
| 73 | mpi B; /*!< constant term in the equation */ |
| 74 | ecp_point G; /*!< generator of the subgroup used */ |
| 75 | mpi N; /*!< the order of G */ |
Manuel Pégourié-Gonnard | 773ed54 | 2012-11-18 13:19:07 +0100 | [diff] [blame] | 76 | size_t pbits; /*!< number of bits in P */ |
| 77 | size_t nbits; /*!< number of bits in N */ |
Manuel Pégourié-Gonnard | 62aad14 | 2012-11-10 00:27:12 +0100 | [diff] [blame] | 78 | int (*modp)(mpi *); /*!< function for fast reduction mod P */ |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 79 | } |
| 80 | ecp_group; |
| 81 | |
| 82 | /** |
| 83 | * RFC 5114 defines a number of standardized ECP groups for use with TLS. |
| 84 | * |
| 85 | * These also are the NIST-recommended ECP groups, are the random ECP groups |
| 86 | * recommended by SECG, and include the two groups used by NSA Suite B. |
Manuel Pégourié-Gonnard | d7e4570 | 2012-10-31 18:57:05 +0100 | [diff] [blame] | 87 | * There are known as secpLLLr1 with LLL = 192, 224, 256, 384, 521. |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 88 | * |
| 89 | * \warning This library does not support validation of arbitrary domain |
| 90 | * parameters. Therefore, only well-known domain parameters from trusted |
Manuel Pégourié-Gonnard | 4712325 | 2012-11-10 14:44:24 +0100 | [diff] [blame] | 91 | * sources should be used. See ecp_use_known_dp(). |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 92 | */ |
Manuel Pégourié-Gonnard | a5402fe | 2012-11-07 20:24:05 +0100 | [diff] [blame] | 93 | #define POLARSSL_ECP_DP_SECP192R1 0 |
| 94 | #define POLARSSL_ECP_DP_SECP224R1 1 |
| 95 | #define POLARSSL_ECP_DP_SECP256R1 2 |
| 96 | #define POLARSSL_ECP_DP_SECP384R1 3 |
| 97 | #define POLARSSL_ECP_DP_SECP521R1 4 |
| 98 | |
Manuel Pégourié-Gonnard | b63f9e9 | 2012-11-21 13:00:58 +0100 | [diff] [blame] | 99 | /** |
| 100 | * Maximum bit size of the groups (that is, of N) |
| 101 | */ |
| 102 | #define POLARSSL_ECP_MAX_N_BITS 521 |
| 103 | |
Manuel Pégourié-Gonnard | 8555607 | 2012-11-17 19:54:20 +0100 | [diff] [blame] | 104 | /* |
Manuel Pégourié-Gonnard | b63f9e9 | 2012-11-21 13:00:58 +0100 | [diff] [blame] | 105 | * Maximum window size (actually, NAF width) used for point multipliation. |
| 106 | * Default: 7. |
Manuel Pégourié-Gonnard | 8555607 | 2012-11-17 19:54:20 +0100 | [diff] [blame] | 107 | * Minimum value: 2. Maximum value: 8. |
| 108 | * |
Manuel Pégourié-Gonnard | b63f9e9 | 2012-11-21 13:00:58 +0100 | [diff] [blame] | 109 | * Result is an array of at most ( 1 << ( POLARSSL_ECP_WINDOW_SIZE - 1 ) ) |
Manuel Pégourié-Gonnard | 8555607 | 2012-11-17 19:54:20 +0100 | [diff] [blame] | 110 | * points used for point multiplication, so at most 64 by default. |
| 111 | * In practice, most curves will use less precomputed points. |
| 112 | * |
| 113 | * Reduction in size may reduce speed for big curves. |
| 114 | */ |
Manuel Pégourié-Gonnard | b63f9e9 | 2012-11-21 13:00:58 +0100 | [diff] [blame] | 115 | #define POLARSSL_ECP_WINDOW_SIZE 7 /**< Maximum NAF width used. */ |
Manuel Pégourié-Gonnard | 8555607 | 2012-11-17 19:54:20 +0100 | [diff] [blame] | 116 | |
Manuel Pégourié-Gonnard | 37d218a | 2012-11-24 15:19:55 +0100 | [diff] [blame] | 117 | /* |
| 118 | * Point formats |
| 119 | */ |
| 120 | #define POLARSSL_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format */ |
| 121 | #define POLARSSL_ECP_PF_COMPRESSED 1 /**< Compressed point format */ |
| 122 | |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 123 | #ifdef __cplusplus |
| 124 | extern "C" { |
| 125 | #endif |
| 126 | |
| 127 | /** |
Manuel Pégourié-Gonnard | 847395a | 2012-11-05 13:13:44 +0100 | [diff] [blame] | 128 | * \brief Initialize a point (as zero) |
Manuel Pégourié-Gonnard | ae180d0 | 2012-11-02 18:14:40 +0100 | [diff] [blame] | 129 | */ |
| 130 | void ecp_point_init( ecp_point *pt ); |
| 131 | |
| 132 | /** |
Manuel Pégourié-Gonnard | b505c27 | 2012-11-05 17:27:54 +0100 | [diff] [blame] | 133 | * \brief Initialize a group (to something meaningless) |
| 134 | */ |
| 135 | void ecp_group_init( ecp_group *grp ); |
| 136 | |
| 137 | /** |
Manuel Pégourié-Gonnard | 883f313 | 2012-11-02 09:40:25 +0100 | [diff] [blame] | 138 | * \brief Free the components of a point |
| 139 | */ |
| 140 | void ecp_point_free( ecp_point *pt ); |
| 141 | |
| 142 | /** |
| 143 | * \brief Free the components of an ECP group |
| 144 | */ |
| 145 | void ecp_group_free( ecp_group *grp ); |
| 146 | |
| 147 | /** |
Manuel Pégourié-Gonnard | ae180d0 | 2012-11-02 18:14:40 +0100 | [diff] [blame] | 148 | * \brief Set a point to zero |
Manuel Pégourié-Gonnard | 1c2782c | 2012-11-19 20:16:28 +0100 | [diff] [blame] | 149 | * |
| 150 | * \return 0 if successful, |
| 151 | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed |
Manuel Pégourié-Gonnard | ae180d0 | 2012-11-02 18:14:40 +0100 | [diff] [blame] | 152 | */ |
Manuel Pégourié-Gonnard | 1c2782c | 2012-11-19 20:16:28 +0100 | [diff] [blame] | 153 | int ecp_set_zero( ecp_point *pt ); |
Manuel Pégourié-Gonnard | ae180d0 | 2012-11-02 18:14:40 +0100 | [diff] [blame] | 154 | |
| 155 | /** |
Manuel Pégourié-Gonnard | 883f313 | 2012-11-02 09:40:25 +0100 | [diff] [blame] | 156 | * \brief Copy the contents of point Q into P |
| 157 | * |
| 158 | * \param P Destination point |
| 159 | * \param Q Source point |
| 160 | * |
Manuel Pégourié-Gonnard | 7cfcea3 | 2012-11-05 10:06:12 +0100 | [diff] [blame] | 161 | * \return 0 if successful, |
| 162 | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed |
Manuel Pégourié-Gonnard | 883f313 | 2012-11-02 09:40:25 +0100 | [diff] [blame] | 163 | */ |
| 164 | int ecp_copy( ecp_point *P, const ecp_point *Q ); |
| 165 | |
| 166 | /** |
Manuel Pégourié-Gonnard | 1c33057 | 2012-11-24 12:05:44 +0100 | [diff] [blame] | 167 | * \brief Check that a point is a valid public key on this curve |
| 168 | * |
| 169 | * \param grp Curve/group the point should belong to |
| 170 | * \param pt Point to check |
| 171 | * |
| 172 | * \return 0 if point is a valid public key, |
| 173 | * POLARSSL_ERR_ECP_GENERIC otherwise. |
| 174 | * |
| 175 | * \note This function only checks the point is non-zero, has valid |
| 176 | * coordinates and lies on the curve, but not that it is |
| 177 | * indeed a multiple of G. This is additional check is more |
| 178 | * expensive, isn't required by standards, and shouldn't be |
| 179 | * necessary if the group used has a small cofactor. In |
| 180 | * particular, it is useless for the NIST groups which all |
| 181 | * have a cofactor of 1. |
| 182 | */ |
| 183 | int ecp_check_pubkey( const ecp_group *grp, const ecp_point *pt ); |
| 184 | |
| 185 | /** |
Manuel Pégourié-Gonnard | 847395a | 2012-11-05 13:13:44 +0100 | [diff] [blame] | 186 | * \brief Import a non-zero point from two ASCII strings |
| 187 | * |
| 188 | * \param P Destination point |
| 189 | * \param radix Input numeric base |
| 190 | * \param x First affine coordinate as a null-terminated string |
| 191 | * \param y Second affine coordinate as a null-terminated string |
| 192 | * |
| 193 | * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code |
| 194 | */ |
| 195 | int ecp_point_read_string( ecp_point *P, int radix, |
| 196 | const char *x, const char *y ); |
| 197 | |
| 198 | /** |
| 199 | * \brief Import an ECP group from null-terminated ASCII strings |
| 200 | * |
| 201 | * \param grp Destination group |
Manuel Pégourié-Gonnard | b505c27 | 2012-11-05 17:27:54 +0100 | [diff] [blame] | 202 | * \param radix Input numeric base |
Manuel Pégourié-Gonnard | 847395a | 2012-11-05 13:13:44 +0100 | [diff] [blame] | 203 | * \param p Prime modulus of the base field |
| 204 | * \param b Constant term in the equation |
| 205 | * \param gx The generator's X coordinate |
| 206 | * \param gy The generator's Y coordinate |
| 207 | * \param n The generator's order |
| 208 | * |
| 209 | * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code |
Manuel Pégourié-Gonnard | 773ed54 | 2012-11-18 13:19:07 +0100 | [diff] [blame] | 210 | * |
| 211 | * \note Sets all fields except modp. |
Manuel Pégourié-Gonnard | 847395a | 2012-11-05 13:13:44 +0100 | [diff] [blame] | 212 | */ |
| 213 | int ecp_group_read_string( ecp_group *grp, int radix, |
| 214 | const char *p, const char *b, |
| 215 | const char *gx, const char *gy, const char *n); |
| 216 | |
| 217 | /** |
Manuel Pégourié-Gonnard | 37d218a | 2012-11-24 15:19:55 +0100 | [diff] [blame] | 218 | * \brief Export a point into unsigned binary data |
Manuel Pégourié-Gonnard | e19feb5 | 2012-11-24 14:10:14 +0100 | [diff] [blame] | 219 | * |
Manuel Pégourié-Gonnard | 5e402d8 | 2012-11-24 16:19:42 +0100 | [diff] [blame] | 220 | * \param grp Group to which the point should belong |
Manuel Pégourié-Gonnard | e19feb5 | 2012-11-24 14:10:14 +0100 | [diff] [blame] | 221 | * \param P Point to export |
Manuel Pégourié-Gonnard | 37d218a | 2012-11-24 15:19:55 +0100 | [diff] [blame] | 222 | * \param format Point format, should be a POLARSSL_ECP_PF_XXX macro |
Manuel Pégourié-Gonnard | e19feb5 | 2012-11-24 14:10:14 +0100 | [diff] [blame] | 223 | * \param olen Length of the actual ouput |
| 224 | * \param buf Output buffer |
| 225 | * \param buflen Length of the output buffer |
| 226 | * |
| 227 | * \return 0 if successful, or POLARSSL_ERR_ECP_GENERIC |
| 228 | */ |
Manuel Pégourié-Gonnard | 37d218a | 2012-11-24 15:19:55 +0100 | [diff] [blame] | 229 | int ecp_write_binary( const ecp_group *grp, const ecp_point *P, int format, |
Manuel Pégourié-Gonnard | e19feb5 | 2012-11-24 14:10:14 +0100 | [diff] [blame] | 230 | size_t *olen, unsigned char *buf, size_t buflen ); |
| 231 | |
| 232 | /** |
Manuel Pégourié-Gonnard | 5e402d8 | 2012-11-24 16:19:42 +0100 | [diff] [blame] | 233 | * \brief Import a point from unsigned binary data |
| 234 | * |
| 235 | * \param grp Group to which the point should belong |
| 236 | * \param P Point to import |
| 237 | * \param format Point format, must be POLARSSL_ECP_PF_UNCOMPRESSED for now |
| 238 | * \param buf Input buffer |
| 239 | * \param ilen Actual length of input |
| 240 | * |
| 241 | * \return 0 if successful, |
| 242 | * POLARSSL_ERR_ECP_GENERIC if input is invalid |
| 243 | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed |
| 244 | * |
| 245 | * \note This function does NOT check that the point actually |
| 246 | * belongs to the given group, see ecp_check_pubkey() for |
| 247 | * that. |
| 248 | */ |
| 249 | int ecp_read_binary( const ecp_group *grp, ecp_point *P, int format, |
| 250 | const unsigned char *buf, size_t ilen ); |
| 251 | /** |
Manuel Pégourié-Gonnard | a5402fe | 2012-11-07 20:24:05 +0100 | [diff] [blame] | 252 | * \brief Set a group using well-known domain parameters |
| 253 | * |
| 254 | * \param grp Destination group |
| 255 | * \param index Index in the list of well-known domain parameters |
| 256 | * |
Manuel Pégourié-Gonnard | 4712325 | 2012-11-10 14:44:24 +0100 | [diff] [blame] | 257 | * \return O if successful, |
Manuel Pégourié-Gonnard | a5402fe | 2012-11-07 20:24:05 +0100 | [diff] [blame] | 258 | * POLARSSL_ERR_MPI_XXX if initialization failed |
| 259 | * POLARSSL_ERR_ECP_GENERIC if index is out of range |
| 260 | * |
| 261 | * \note Index should be a POLARSSL_ECP_DP_XXX macro. |
| 262 | */ |
| 263 | int ecp_use_known_dp( ecp_group *grp, size_t index ); |
| 264 | |
| 265 | /** |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 266 | * \brief Addition: R = P + Q |
| 267 | * |
| 268 | * \param grp ECP group |
| 269 | * \param R Destination point |
| 270 | * \param P Left-hand point |
| 271 | * \param Q Right-hand point |
| 272 | * |
Manuel Pégourié-Gonnard | 7cfcea3 | 2012-11-05 10:06:12 +0100 | [diff] [blame] | 273 | * \return 0 if successful, |
Manuel Pégourié-Gonnard | 62aad14 | 2012-11-10 00:27:12 +0100 | [diff] [blame] | 274 | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 275 | */ |
| 276 | int ecp_add( const ecp_group *grp, ecp_point *R, |
| 277 | const ecp_point *P, const ecp_point *Q ); |
| 278 | |
| 279 | /** |
Manuel Pégourié-Gonnard | 9674fd0 | 2012-11-19 21:23:27 +0100 | [diff] [blame] | 280 | * \brief Subtraction: R = P - Q |
| 281 | * |
| 282 | * \param grp ECP group |
| 283 | * \param R Destination point |
| 284 | * \param P Left-hand point |
| 285 | * \param Q Right-hand point |
| 286 | * |
| 287 | * \return 0 if successful, |
| 288 | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed |
| 289 | */ |
| 290 | int ecp_sub( const ecp_group *grp, ecp_point *R, |
| 291 | const ecp_point *P, const ecp_point *Q ); |
| 292 | |
| 293 | /** |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 294 | * \brief Multiplication by an integer: R = m * P |
| 295 | * |
| 296 | * \param grp ECP group |
| 297 | * \param R Destination point |
| 298 | * \param m Integer by which to multiply |
| 299 | * \param P Point to multiply |
| 300 | * |
Manuel Pégourié-Gonnard | 7cfcea3 | 2012-11-05 10:06:12 +0100 | [diff] [blame] | 301 | * \return 0 if successful, |
Manuel Pégourié-Gonnard | 62aad14 | 2012-11-10 00:27:12 +0100 | [diff] [blame] | 302 | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed |
Manuel Pégourié-Gonnard | b63f9e9 | 2012-11-21 13:00:58 +0100 | [diff] [blame] | 303 | * POLARSSL_ERR_ECP_GENERIC if m < 0 of m has greater bit |
| 304 | * length than N, the number of points in the group. |
| 305 | * |
| 306 | * \note This function executes a constant number of operations |
| 307 | * for random m in the allowed range. |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 308 | */ |
Manuel Pégourié-Gonnard | 5179e46 | 2012-10-31 19:37:54 +0100 | [diff] [blame] | 309 | int ecp_mul( const ecp_group *grp, ecp_point *R, |
| 310 | const mpi *m, const ecp_point *P ); |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 311 | |
| 312 | /** |
Manuel Pégourié-Gonnard | 45a035a | 2013-01-26 14:42:45 +0100 | [diff] [blame^] | 313 | * \brief Generate a keypair |
| 314 | * |
| 315 | * \param grp ECP group |
| 316 | * \param d Destination MPI (secret part) |
| 317 | * \param Q Destination point (public part) |
| 318 | * \param f_rng RNG function |
| 319 | * \param p_rng RNG parameter |
| 320 | * |
| 321 | * \return 0 if successful, |
| 322 | * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code |
| 323 | */ |
| 324 | int ecp_gen_keypair( const ecp_group *grp, mpi *d, ecp_point *Q, |
| 325 | int (*f_rng)(void *, unsigned char *, size_t), |
| 326 | void *p_rng ); |
| 327 | |
| 328 | /** |
Manuel Pégourié-Gonnard | 39d2adb | 2012-10-31 09:26:55 +0100 | [diff] [blame] | 329 | * \brief Checkup routine |
| 330 | * |
| 331 | * \return 0 if successful, or 1 if the test failed |
| 332 | */ |
| 333 | int ecp_self_test( int verbose ); |
| 334 | |
| 335 | #ifdef __cplusplus |
| 336 | } |
| 337 | #endif |
| 338 | |
| 339 | #endif |