wolfSSL 3.11.1 for TLS1.3 beta

Fork of wolfSSL by wolf SSL

Committer:
wolfSSL
Date:
Tue May 30 06:16:19 2017 +0000
Revision:
13:80fb167dafdf
wolfSSL 3.11.1: TLS1.3 Beta

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 13:80fb167dafdf 1 /* ecc.h
wolfSSL 13:80fb167dafdf 2 *
wolfSSL 13:80fb167dafdf 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 13:80fb167dafdf 4 *
wolfSSL 13:80fb167dafdf 5 * This file is part of wolfSSL.
wolfSSL 13:80fb167dafdf 6 *
wolfSSL 13:80fb167dafdf 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 13:80fb167dafdf 8 * it under the terms of the GNU General Public License as published by
wolfSSL 13:80fb167dafdf 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 13:80fb167dafdf 10 * (at your option) any later version.
wolfSSL 13:80fb167dafdf 11 *
wolfSSL 13:80fb167dafdf 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 13:80fb167dafdf 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 13:80fb167dafdf 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 13:80fb167dafdf 15 * GNU General Public License for more details.
wolfSSL 13:80fb167dafdf 16 *
wolfSSL 13:80fb167dafdf 17 * You should have received a copy of the GNU General Public License
wolfSSL 13:80fb167dafdf 18 * along with this program; if not, write to the Free Software
wolfSSL 13:80fb167dafdf 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 13:80fb167dafdf 20 */
wolfSSL 13:80fb167dafdf 21
wolfSSL 13:80fb167dafdf 22
wolfSSL 13:80fb167dafdf 23 #ifndef WOLF_CRYPT_ECC_H
wolfSSL 13:80fb167dafdf 24 #define WOLF_CRYPT_ECC_H
wolfSSL 13:80fb167dafdf 25
wolfSSL 13:80fb167dafdf 26 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 13:80fb167dafdf 27
wolfSSL 13:80fb167dafdf 28 #ifdef HAVE_ECC
wolfSSL 13:80fb167dafdf 29
wolfSSL 13:80fb167dafdf 30 #include <wolfssl/wolfcrypt/integer.h>
wolfSSL 13:80fb167dafdf 31 #include <wolfssl/wolfcrypt/random.h>
wolfSSL 13:80fb167dafdf 32
wolfSSL 13:80fb167dafdf 33 #ifdef HAVE_X963_KDF
wolfSSL 13:80fb167dafdf 34 #include <wolfssl/wolfcrypt/hash.h>
wolfSSL 13:80fb167dafdf 35 #endif
wolfSSL 13:80fb167dafdf 36
wolfSSL 13:80fb167dafdf 37 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 13:80fb167dafdf 38 #include <wolfssl/wolfcrypt/async.h>
wolfSSL 13:80fb167dafdf 39 #ifdef WOLFSSL_CERT_GEN
wolfSSL 13:80fb167dafdf 40 #include <wolfssl/wolfcrypt/asn.h>
wolfSSL 13:80fb167dafdf 41 #endif
wolfSSL 13:80fb167dafdf 42 #endif
wolfSSL 13:80fb167dafdf 43
wolfSSL 13:80fb167dafdf 44 #ifdef WOLFSSL_ATECC508A
wolfSSL 13:80fb167dafdf 45 #include <wolfssl/wolfcrypt/port/atmel/atmel.h>
wolfSSL 13:80fb167dafdf 46 #endif /* WOLFSSL_ATECC508A */
wolfSSL 13:80fb167dafdf 47
wolfSSL 13:80fb167dafdf 48
wolfSSL 13:80fb167dafdf 49 #ifdef __cplusplus
wolfSSL 13:80fb167dafdf 50 extern "C" {
wolfSSL 13:80fb167dafdf 51 #endif
wolfSSL 13:80fb167dafdf 52
wolfSSL 13:80fb167dafdf 53
wolfSSL 13:80fb167dafdf 54 /* Enable curve B parameter if needed */
wolfSSL 13:80fb167dafdf 55 #if defined(HAVE_COMP_KEY) || defined(ECC_CACHE_CURVE)
wolfSSL 13:80fb167dafdf 56 #ifndef USE_ECC_B_PARAM /* Allow someone to force enable */
wolfSSL 13:80fb167dafdf 57 #define USE_ECC_B_PARAM
wolfSSL 13:80fb167dafdf 58 #endif
wolfSSL 13:80fb167dafdf 59 #endif
wolfSSL 13:80fb167dafdf 60
wolfSSL 13:80fb167dafdf 61
wolfSSL 13:80fb167dafdf 62 /* Use this as the key->idx if a custom ecc_set is used for key->dp */
wolfSSL 13:80fb167dafdf 63 #define ECC_CUSTOM_IDX (-1)
wolfSSL 13:80fb167dafdf 64
wolfSSL 13:80fb167dafdf 65
wolfSSL 13:80fb167dafdf 66 /* Determine max ECC bits based on enabled curves */
wolfSSL 13:80fb167dafdf 67 #if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
wolfSSL 13:80fb167dafdf 68 #define MAX_ECC_BITS 521
wolfSSL 13:80fb167dafdf 69 #elif defined(HAVE_ECC512)
wolfSSL 13:80fb167dafdf 70 #define MAX_ECC_BITS 512
wolfSSL 13:80fb167dafdf 71 #elif defined(HAVE_ECC384)
wolfSSL 13:80fb167dafdf 72 #define MAX_ECC_BITS 384
wolfSSL 13:80fb167dafdf 73 #elif defined(HAVE_ECC320)
wolfSSL 13:80fb167dafdf 74 #define MAX_ECC_BITS 320
wolfSSL 13:80fb167dafdf 75 #elif defined(HAVE_ECC239)
wolfSSL 13:80fb167dafdf 76 #define MAX_ECC_BITS 239
wolfSSL 13:80fb167dafdf 77 #elif defined(HAVE_ECC224)
wolfSSL 13:80fb167dafdf 78 #define MAX_ECC_BITS 224
wolfSSL 13:80fb167dafdf 79 #elif !defined(NO_ECC256)
wolfSSL 13:80fb167dafdf 80 #define MAX_ECC_BITS 256
wolfSSL 13:80fb167dafdf 81 #elif defined(HAVE_ECC192)
wolfSSL 13:80fb167dafdf 82 #define MAX_ECC_BITS 192
wolfSSL 13:80fb167dafdf 83 #elif defined(HAVE_ECC160)
wolfSSL 13:80fb167dafdf 84 #define MAX_ECC_BITS 160
wolfSSL 13:80fb167dafdf 85 #elif defined(HAVE_ECC128)
wolfSSL 13:80fb167dafdf 86 #define MAX_ECC_BITS 128
wolfSSL 13:80fb167dafdf 87 #elif defined(HAVE_ECC112)
wolfSSL 13:80fb167dafdf 88 #define MAX_ECC_BITS 112
wolfSSL 13:80fb167dafdf 89 #endif
wolfSSL 13:80fb167dafdf 90
wolfSSL 13:80fb167dafdf 91 /* calculate max ECC bytes */
wolfSSL 13:80fb167dafdf 92 #if ((MAX_ECC_BITS * 2) % 8) == 0
wolfSSL 13:80fb167dafdf 93 #define MAX_ECC_BYTES (MAX_ECC_BITS / 8)
wolfSSL 13:80fb167dafdf 94 #else
wolfSSL 13:80fb167dafdf 95 /* add byte if not aligned */
wolfSSL 13:80fb167dafdf 96 #define MAX_ECC_BYTES ((MAX_ECC_BITS / 8) + 1)
wolfSSL 13:80fb167dafdf 97 #endif
wolfSSL 13:80fb167dafdf 98
wolfSSL 13:80fb167dafdf 99
wolfSSL 13:80fb167dafdf 100 enum {
wolfSSL 13:80fb167dafdf 101 ECC_PUBLICKEY = 1,
wolfSSL 13:80fb167dafdf 102 ECC_PRIVATEKEY = 2,
wolfSSL 13:80fb167dafdf 103 ECC_MAXNAME = 16, /* MAX CURVE NAME LENGTH */
wolfSSL 13:80fb167dafdf 104 SIG_HEADER_SZ = 6, /* ECC signature header size */
wolfSSL 13:80fb167dafdf 105 ECC_BUFSIZE = 256, /* for exported keys temp buffer */
wolfSSL 13:80fb167dafdf 106 ECC_MINSIZE = 20, /* MIN Private Key size */
wolfSSL 13:80fb167dafdf 107 ECC_MAXSIZE = 66, /* MAX Private Key size */
wolfSSL 13:80fb167dafdf 108 ECC_MAXSIZE_GEN = 74, /* MAX Buffer size required when generating ECC keys*/
wolfSSL 13:80fb167dafdf 109 ECC_MAX_PAD_SZ = 4, /* ECC maximum padding size */
wolfSSL 13:80fb167dafdf 110 ECC_MAX_OID_LEN = 16,
wolfSSL 13:80fb167dafdf 111 ECC_MAX_SIG_SIZE= ((MAX_ECC_BYTES * 2) + ECC_MAX_PAD_SZ + SIG_HEADER_SZ)
wolfSSL 13:80fb167dafdf 112 };
wolfSSL 13:80fb167dafdf 113
wolfSSL 13:80fb167dafdf 114 /* Curve Types */
wolfSSL 13:80fb167dafdf 115 typedef enum ecc_curve_id {
wolfSSL 13:80fb167dafdf 116 ECC_CURVE_INVALID = -1,
wolfSSL 13:80fb167dafdf 117 ECC_CURVE_DEF = 0, /* NIST or SECP */
wolfSSL 13:80fb167dafdf 118
wolfSSL 13:80fb167dafdf 119 /* NIST Prime Curves */
wolfSSL 13:80fb167dafdf 120 ECC_SECP192R1,
wolfSSL 13:80fb167dafdf 121 ECC_PRIME192V2,
wolfSSL 13:80fb167dafdf 122 ECC_PRIME192V3,
wolfSSL 13:80fb167dafdf 123 ECC_PRIME239V1,
wolfSSL 13:80fb167dafdf 124 ECC_PRIME239V2,
wolfSSL 13:80fb167dafdf 125 ECC_PRIME239V3,
wolfSSL 13:80fb167dafdf 126 ECC_SECP256R1,
wolfSSL 13:80fb167dafdf 127
wolfSSL 13:80fb167dafdf 128 /* SECP Curves */
wolfSSL 13:80fb167dafdf 129 ECC_SECP112R1,
wolfSSL 13:80fb167dafdf 130 ECC_SECP112R2,
wolfSSL 13:80fb167dafdf 131 ECC_SECP128R1,
wolfSSL 13:80fb167dafdf 132 ECC_SECP128R2,
wolfSSL 13:80fb167dafdf 133 ECC_SECP160R1,
wolfSSL 13:80fb167dafdf 134 ECC_SECP160R2,
wolfSSL 13:80fb167dafdf 135 ECC_SECP224R1,
wolfSSL 13:80fb167dafdf 136 ECC_SECP384R1,
wolfSSL 13:80fb167dafdf 137 ECC_SECP521R1,
wolfSSL 13:80fb167dafdf 138
wolfSSL 13:80fb167dafdf 139 /* Koblitz */
wolfSSL 13:80fb167dafdf 140 ECC_SECP160K1,
wolfSSL 13:80fb167dafdf 141 ECC_SECP192K1,
wolfSSL 13:80fb167dafdf 142 ECC_SECP224K1,
wolfSSL 13:80fb167dafdf 143 ECC_SECP256K1,
wolfSSL 13:80fb167dafdf 144
wolfSSL 13:80fb167dafdf 145 /* Brainpool Curves */
wolfSSL 13:80fb167dafdf 146 ECC_BRAINPOOLP160R1,
wolfSSL 13:80fb167dafdf 147 ECC_BRAINPOOLP192R1,
wolfSSL 13:80fb167dafdf 148 ECC_BRAINPOOLP224R1,
wolfSSL 13:80fb167dafdf 149 ECC_BRAINPOOLP256R1,
wolfSSL 13:80fb167dafdf 150 ECC_BRAINPOOLP320R1,
wolfSSL 13:80fb167dafdf 151 ECC_BRAINPOOLP384R1,
wolfSSL 13:80fb167dafdf 152 ECC_BRAINPOOLP512R1,
wolfSSL 13:80fb167dafdf 153
wolfSSL 13:80fb167dafdf 154 /* Twisted Edwards Curves */
wolfSSL 13:80fb167dafdf 155 #ifdef HAVE_CURVE25519
wolfSSL 13:80fb167dafdf 156 ECC_X25519,
wolfSSL 13:80fb167dafdf 157 #endif
wolfSSL 13:80fb167dafdf 158 #ifdef HAVE_X448
wolfSSL 13:80fb167dafdf 159 ECC_X448,
wolfSSL 13:80fb167dafdf 160 #endif
wolfSSL 13:80fb167dafdf 161 } ecc_curve_id;
wolfSSL 13:80fb167dafdf 162
wolfSSL 13:80fb167dafdf 163 #ifdef HAVE_OID_ENCODING
wolfSSL 13:80fb167dafdf 164 typedef word16 ecc_oid_t;
wolfSSL 13:80fb167dafdf 165 #else
wolfSSL 13:80fb167dafdf 166 typedef byte ecc_oid_t;
wolfSSL 13:80fb167dafdf 167 /* OID encoded with ASN scheme:
wolfSSL 13:80fb167dafdf 168 first element = (oid[0] * 40) + oid[1]
wolfSSL 13:80fb167dafdf 169 if any element > 127 then MSB 0x80 indicates additional byte */
wolfSSL 13:80fb167dafdf 170 #endif
wolfSSL 13:80fb167dafdf 171
wolfSSL 13:80fb167dafdf 172 /* ECC set type defined a GF(p) curve */
wolfSSL 13:80fb167dafdf 173 typedef struct ecc_set_type {
wolfSSL 13:80fb167dafdf 174 int size; /* The size of the curve in octets */
wolfSSL 13:80fb167dafdf 175 int id; /* id of this curve */
wolfSSL 13:80fb167dafdf 176 const char* name; /* name of this curve */
wolfSSL 13:80fb167dafdf 177 const char* prime; /* prime that defines the field, curve is in (hex) */
wolfSSL 13:80fb167dafdf 178 const char* Af; /* fields A param (hex) */
wolfSSL 13:80fb167dafdf 179 const char* Bf; /* fields B param (hex) */
wolfSSL 13:80fb167dafdf 180 const char* order; /* order of the curve (hex) */
wolfSSL 13:80fb167dafdf 181 const char* Gx; /* x coordinate of the base point on curve (hex) */
wolfSSL 13:80fb167dafdf 182 const char* Gy; /* y coordinate of the base point on curve (hex) */
wolfSSL 13:80fb167dafdf 183 const ecc_oid_t* oid;
wolfSSL 13:80fb167dafdf 184 word32 oidSz;
wolfSSL 13:80fb167dafdf 185 word32 oidSum; /* sum of encoded OID bytes */
wolfSSL 13:80fb167dafdf 186 int cofactor;
wolfSSL 13:80fb167dafdf 187 } ecc_set_type;
wolfSSL 13:80fb167dafdf 188
wolfSSL 13:80fb167dafdf 189
wolfSSL 13:80fb167dafdf 190 #ifdef ALT_ECC_SIZE
wolfSSL 13:80fb167dafdf 191
wolfSSL 13:80fb167dafdf 192 /* Note on ALT_ECC_SIZE:
wolfSSL 13:80fb167dafdf 193 * The fast math code uses an array of a fixed size to store the big integers.
wolfSSL 13:80fb167dafdf 194 * By default, the array is big enough for RSA keys. There is a size,
wolfSSL 13:80fb167dafdf 195 * FP_MAX_BITS which can be used to make the array smaller when one wants ECC
wolfSSL 13:80fb167dafdf 196 * but not RSA. Some people want fast math sized for both RSA and ECC, where
wolfSSL 13:80fb167dafdf 197 * ECC won't use as much as RSA. The flag ALT_ECC_SIZE switches in an alternate
wolfSSL 13:80fb167dafdf 198 * ecc_point structure that uses an alternate fp_int that has a shorter array
wolfSSL 13:80fb167dafdf 199 * of fp_digits.
wolfSSL 13:80fb167dafdf 200 *
wolfSSL 13:80fb167dafdf 201 * Now, without ALT_ECC_SIZE, the ecc_point has three single item arrays of
wolfSSL 13:80fb167dafdf 202 * mp_ints for the components of the point. With ALT_ECC_SIZE, the components
wolfSSL 13:80fb167dafdf 203 * of the point are pointers that are set to each of a three item array of
wolfSSL 13:80fb167dafdf 204 * alt_fp_ints. While an mp_int will have 4096 bits of digit inside the
wolfSSL 13:80fb167dafdf 205 * structure, the alt_fp_int will only have 528 bits. A size value was added
wolfSSL 13:80fb167dafdf 206 * in the ALT case, as well, and is set by mp_init() and alt_fp_init(). The
wolfSSL 13:80fb167dafdf 207 * functions fp_zero() and fp_copy() use the size parameter. An int needs to
wolfSSL 13:80fb167dafdf 208 * be initialized before using it instead of just fp_zeroing it, the init will
wolfSSL 13:80fb167dafdf 209 * call zero. FP_MAX_BITS_ECC defaults to 528, but can be set to change the
wolfSSL 13:80fb167dafdf 210 * number of bits used in the alternate FP_INT.
wolfSSL 13:80fb167dafdf 211 *
wolfSSL 13:80fb167dafdf 212 * Do not enable ALT_ECC_SIZE and disable fast math in the configuration.
wolfSSL 13:80fb167dafdf 213 */
wolfSSL 13:80fb167dafdf 214
wolfSSL 13:80fb167dafdf 215 #ifndef USE_FAST_MATH
wolfSSL 13:80fb167dafdf 216 #error USE_FAST_MATH must be defined to use ALT_ECC_SIZE
wolfSSL 13:80fb167dafdf 217 #endif
wolfSSL 13:80fb167dafdf 218
wolfSSL 13:80fb167dafdf 219 /* determine max bits required for ECC math */
wolfSSL 13:80fb167dafdf 220 #ifndef FP_MAX_BITS_ECC
wolfSSL 13:80fb167dafdf 221 /* check alignment */
wolfSSL 13:80fb167dafdf 222 #if ((MAX_ECC_BITS * 2) % DIGIT_BIT) == 0
wolfSSL 13:80fb167dafdf 223 /* max bits is double */
wolfSSL 13:80fb167dafdf 224 #define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2)
wolfSSL 13:80fb167dafdf 225 #else
wolfSSL 13:80fb167dafdf 226 /* max bits is doubled, plus one digit of fudge */
wolfSSL 13:80fb167dafdf 227 #define FP_MAX_BITS_ECC ((MAX_ECC_BITS * 2) + DIGIT_BIT)
wolfSSL 13:80fb167dafdf 228 #endif
wolfSSL 13:80fb167dafdf 229 #else
wolfSSL 13:80fb167dafdf 230 /* verify alignment */
wolfSSL 13:80fb167dafdf 231 #if FP_MAX_BITS_ECC % CHAR_BIT
wolfSSL 13:80fb167dafdf 232 #error FP_MAX_BITS_ECC must be a multiple of CHAR_BIT
wolfSSL 13:80fb167dafdf 233 #endif
wolfSSL 13:80fb167dafdf 234 #endif
wolfSSL 13:80fb167dafdf 235
wolfSSL 13:80fb167dafdf 236 /* determine buffer size */
wolfSSL 13:80fb167dafdf 237 #define FP_SIZE_ECC (FP_MAX_BITS_ECC/DIGIT_BIT)
wolfSSL 13:80fb167dafdf 238
wolfSSL 13:80fb167dafdf 239
wolfSSL 13:80fb167dafdf 240 /* This needs to match the size of the fp_int struct, except the
wolfSSL 13:80fb167dafdf 241 * fp_digit array will be shorter. */
wolfSSL 13:80fb167dafdf 242 typedef struct alt_fp_int {
wolfSSL 13:80fb167dafdf 243 int used, sign, size;
wolfSSL 13:80fb167dafdf 244 fp_digit dp[FP_SIZE_ECC];
wolfSSL 13:80fb167dafdf 245 } alt_fp_int;
wolfSSL 13:80fb167dafdf 246 #endif /* ALT_ECC_SIZE */
wolfSSL 13:80fb167dafdf 247
wolfSSL 13:80fb167dafdf 248
wolfSSL 13:80fb167dafdf 249 /* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) =>
wolfSSL 13:80fb167dafdf 250 (x/z^2, y/z^3, 1) when interpreted as affine */
wolfSSL 13:80fb167dafdf 251 typedef struct {
wolfSSL 13:80fb167dafdf 252 #ifndef ALT_ECC_SIZE
wolfSSL 13:80fb167dafdf 253 mp_int x[1]; /* The x coordinate */
wolfSSL 13:80fb167dafdf 254 mp_int y[1]; /* The y coordinate */
wolfSSL 13:80fb167dafdf 255 mp_int z[1]; /* The z coordinate */
wolfSSL 13:80fb167dafdf 256 #else
wolfSSL 13:80fb167dafdf 257 mp_int* x; /* The x coordinate */
wolfSSL 13:80fb167dafdf 258 mp_int* y; /* The y coordinate */
wolfSSL 13:80fb167dafdf 259 mp_int* z; /* The z coordinate */
wolfSSL 13:80fb167dafdf 260 alt_fp_int xyz[3];
wolfSSL 13:80fb167dafdf 261 #endif
wolfSSL 13:80fb167dafdf 262 } ecc_point;
wolfSSL 13:80fb167dafdf 263
wolfSSL 13:80fb167dafdf 264 /* ECC Flags */
wolfSSL 13:80fb167dafdf 265 enum {
wolfSSL 13:80fb167dafdf 266 WC_ECC_FLAG_NONE = 0x00,
wolfSSL 13:80fb167dafdf 267 #ifdef HAVE_ECC_CDH
wolfSSL 13:80fb167dafdf 268 WC_ECC_FLAG_COFACTOR = 0x01,
wolfSSL 13:80fb167dafdf 269 #endif
wolfSSL 13:80fb167dafdf 270 };
wolfSSL 13:80fb167dafdf 271
wolfSSL 13:80fb167dafdf 272 /* An ECC Key */
wolfSSL 13:80fb167dafdf 273 struct ecc_key {
wolfSSL 13:80fb167dafdf 274 int type; /* Public or Private */
wolfSSL 13:80fb167dafdf 275 int idx; /* Index into the ecc_sets[] for the parameters of
wolfSSL 13:80fb167dafdf 276 this curve if -1, this key is using user supplied
wolfSSL 13:80fb167dafdf 277 curve in dp */
wolfSSL 13:80fb167dafdf 278 int state;
wolfSSL 13:80fb167dafdf 279 word32 flags;
wolfSSL 13:80fb167dafdf 280 const ecc_set_type* dp; /* domain parameters, either points to NIST
wolfSSL 13:80fb167dafdf 281 curves (idx >= 0) or user supplied */
wolfSSL 13:80fb167dafdf 282 void* heap; /* heap hint */
wolfSSL 13:80fb167dafdf 283 #ifdef WOLFSSL_ATECC508A
wolfSSL 13:80fb167dafdf 284 int slot; /* Key Slot Number (-1 unknown) */
wolfSSL 13:80fb167dafdf 285 byte pubkey[PUB_KEY_SIZE];
wolfSSL 13:80fb167dafdf 286 #else
wolfSSL 13:80fb167dafdf 287 ecc_point pubkey; /* public key */
wolfSSL 13:80fb167dafdf 288 mp_int k; /* private key */
wolfSSL 13:80fb167dafdf 289 #endif
wolfSSL 13:80fb167dafdf 290 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 13:80fb167dafdf 291 mp_int* r; /* sign/verify temps */
wolfSSL 13:80fb167dafdf 292 mp_int* s;
wolfSSL 13:80fb167dafdf 293 WC_ASYNC_DEV asyncDev;
wolfSSL 13:80fb167dafdf 294 #ifdef WOLFSSL_CERT_GEN
wolfSSL 13:80fb167dafdf 295 CertSignCtx certSignCtx; /* context info for cert sign (MakeSignature) */
wolfSSL 13:80fb167dafdf 296 #endif
wolfSSL 13:80fb167dafdf 297 #endif /* WOLFSSL_ASYNC_CRYPT */
wolfSSL 13:80fb167dafdf 298 };
wolfSSL 13:80fb167dafdf 299
wolfSSL 13:80fb167dafdf 300 #ifndef WC_ECCKEY_TYPE_DEFINED
wolfSSL 13:80fb167dafdf 301 typedef struct ecc_key ecc_key;
wolfSSL 13:80fb167dafdf 302 #define WC_ECCKEY_TYPE_DEFINED
wolfSSL 13:80fb167dafdf 303 #endif
wolfSSL 13:80fb167dafdf 304
wolfSSL 13:80fb167dafdf 305
wolfSSL 13:80fb167dafdf 306 /* ECC predefined curve sets */
wolfSSL 13:80fb167dafdf 307 extern const ecc_set_type ecc_sets[];
wolfSSL 13:80fb167dafdf 308
wolfSSL 13:80fb167dafdf 309 WOLFSSL_API
wolfSSL 13:80fb167dafdf 310 const char* wc_ecc_get_name(int curve_id);
wolfSSL 13:80fb167dafdf 311
wolfSSL 13:80fb167dafdf 312 #ifndef WOLFSSL_ATECC508A
wolfSSL 13:80fb167dafdf 313
wolfSSL 13:80fb167dafdf 314 #ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL
wolfSSL 13:80fb167dafdf 315 #define ECC_API WOLFSSL_API
wolfSSL 13:80fb167dafdf 316 #else
wolfSSL 13:80fb167dafdf 317 #define ECC_API WOLFSSL_LOCAL
wolfSSL 13:80fb167dafdf 318 #endif
wolfSSL 13:80fb167dafdf 319
wolfSSL 13:80fb167dafdf 320 ECC_API int ecc_map(ecc_point*, mp_int*, mp_digit);
wolfSSL 13:80fb167dafdf 321 ECC_API int ecc_projective_add_point(ecc_point* P, ecc_point* Q, ecc_point* R,
wolfSSL 13:80fb167dafdf 322 mp_int* a, mp_int* modulus, mp_digit mp);
wolfSSL 13:80fb167dafdf 323 ECC_API int ecc_projective_dbl_point(ecc_point* P, ecc_point* R, mp_int* a,
wolfSSL 13:80fb167dafdf 324 mp_int* modulus, mp_digit mp);
wolfSSL 13:80fb167dafdf 325
wolfSSL 13:80fb167dafdf 326 #endif
wolfSSL 13:80fb167dafdf 327
wolfSSL 13:80fb167dafdf 328 WOLFSSL_API
wolfSSL 13:80fb167dafdf 329 int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);
wolfSSL 13:80fb167dafdf 330 WOLFSSL_API
wolfSSL 13:80fb167dafdf 331 int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key,
wolfSSL 13:80fb167dafdf 332 int curve_id);
wolfSSL 13:80fb167dafdf 333 WOLFSSL_API
wolfSSL 13:80fb167dafdf 334 int wc_ecc_check_key(ecc_key* key);
wolfSSL 13:80fb167dafdf 335 WOLFSSL_API
wolfSSL 13:80fb167dafdf 336 int wc_ecc_is_point(ecc_point* ecp, mp_int* a, mp_int* b, mp_int* prime);
wolfSSL 13:80fb167dafdf 337
wolfSSL 13:80fb167dafdf 338 #ifdef HAVE_ECC_DHE
wolfSSL 13:80fb167dafdf 339 WOLFSSL_API
wolfSSL 13:80fb167dafdf 340 int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
wolfSSL 13:80fb167dafdf 341 word32* outlen);
wolfSSL 13:80fb167dafdf 342 WOLFSSL_LOCAL
wolfSSL 13:80fb167dafdf 343 int wc_ecc_shared_secret_gen(ecc_key* private_key, ecc_point* point,
wolfSSL 13:80fb167dafdf 344 byte* out, word32 *outlen);
wolfSSL 13:80fb167dafdf 345 WOLFSSL_API
wolfSSL 13:80fb167dafdf 346 int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
wolfSSL 13:80fb167dafdf 347 byte* out, word32 *outlen);
wolfSSL 13:80fb167dafdf 348 #define wc_ecc_shared_secret_ssh wc_ecc_shared_secret_ex /* For backwards compat */
wolfSSL 13:80fb167dafdf 349 #endif /* HAVE_ECC_DHE */
wolfSSL 13:80fb167dafdf 350
wolfSSL 13:80fb167dafdf 351 #ifdef HAVE_ECC_SIGN
wolfSSL 13:80fb167dafdf 352 WOLFSSL_API
wolfSSL 13:80fb167dafdf 353 int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
wolfSSL 13:80fb167dafdf 354 WC_RNG* rng, ecc_key* key);
wolfSSL 13:80fb167dafdf 355 WOLFSSL_API
wolfSSL 13:80fb167dafdf 356 int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
wolfSSL 13:80fb167dafdf 357 ecc_key* key, mp_int *r, mp_int *s);
wolfSSL 13:80fb167dafdf 358 #endif /* HAVE_ECC_SIGN */
wolfSSL 13:80fb167dafdf 359
wolfSSL 13:80fb167dafdf 360 #ifdef HAVE_ECC_VERIFY
wolfSSL 13:80fb167dafdf 361 WOLFSSL_API
wolfSSL 13:80fb167dafdf 362 int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
wolfSSL 13:80fb167dafdf 363 word32 hashlen, int* stat, ecc_key* key);
wolfSSL 13:80fb167dafdf 364 WOLFSSL_API
wolfSSL 13:80fb167dafdf 365 int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
wolfSSL 13:80fb167dafdf 366 word32 hashlen, int* stat, ecc_key* key);
wolfSSL 13:80fb167dafdf 367 #endif /* HAVE_ECC_VERIFY */
wolfSSL 13:80fb167dafdf 368
wolfSSL 13:80fb167dafdf 369 WOLFSSL_API
wolfSSL 13:80fb167dafdf 370 int wc_ecc_init(ecc_key* key);
wolfSSL 13:80fb167dafdf 371 WOLFSSL_API
wolfSSL 13:80fb167dafdf 372 int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);
wolfSSL 13:80fb167dafdf 373 WOLFSSL_API
wolfSSL 13:80fb167dafdf 374 void wc_ecc_free(ecc_key* key);
wolfSSL 13:80fb167dafdf 375 WOLFSSL_API
wolfSSL 13:80fb167dafdf 376 int wc_ecc_set_flags(ecc_key* key, word32 flags);
wolfSSL 13:80fb167dafdf 377 WOLFSSL_API
wolfSSL 13:80fb167dafdf 378 void wc_ecc_fp_free(void);
wolfSSL 13:80fb167dafdf 379
wolfSSL 13:80fb167dafdf 380 WOLFSSL_API
wolfSSL 13:80fb167dafdf 381 int wc_ecc_set_curve(ecc_key* key, int keysize, int curve_id);
wolfSSL 13:80fb167dafdf 382
wolfSSL 13:80fb167dafdf 383 WOLFSSL_API
wolfSSL 13:80fb167dafdf 384 int wc_ecc_is_valid_idx(int n);
wolfSSL 13:80fb167dafdf 385 WOLFSSL_API
wolfSSL 13:80fb167dafdf 386 int wc_ecc_get_curve_idx(int curve_id);
wolfSSL 13:80fb167dafdf 387 WOLFSSL_API
wolfSSL 13:80fb167dafdf 388 int wc_ecc_get_curve_id(int curve_idx);
wolfSSL 13:80fb167dafdf 389 #define wc_ecc_get_curve_name_from_id wc_ecc_get_name
wolfSSL 13:80fb167dafdf 390 WOLFSSL_API
wolfSSL 13:80fb167dafdf 391 int wc_ecc_get_curve_size_from_id(int curve_id);
wolfSSL 13:80fb167dafdf 392
wolfSSL 13:80fb167dafdf 393 WOLFSSL_API
wolfSSL 13:80fb167dafdf 394 int wc_ecc_get_curve_idx_from_name(const char* curveName);
wolfSSL 13:80fb167dafdf 395 WOLFSSL_API
wolfSSL 13:80fb167dafdf 396 int wc_ecc_get_curve_size_from_name(const char* curveName);
wolfSSL 13:80fb167dafdf 397 WOLFSSL_API
wolfSSL 13:80fb167dafdf 398 int wc_ecc_get_curve_id_from_name(const char* curveName);
wolfSSL 13:80fb167dafdf 399 WOLFSSL_API
wolfSSL 13:80fb167dafdf 400 int wc_ecc_get_curve_id_from_params(int fieldSize,
wolfSSL 13:80fb167dafdf 401 const byte* prime, word32 primeSz, const byte* Af, word32 AfSz,
wolfSSL 13:80fb167dafdf 402 const byte* Bf, word32 BfSz, const byte* order, word32 orderSz,
wolfSSL 13:80fb167dafdf 403 const byte* Gx, word32 GxSz, const byte* Gy, word32 GySz, int cofactor);
wolfSSL 13:80fb167dafdf 404
wolfSSL 13:80fb167dafdf 405 #ifndef WOLFSSL_ATECC508A
wolfSSL 13:80fb167dafdf 406
wolfSSL 13:80fb167dafdf 407 WOLFSSL_API
wolfSSL 13:80fb167dafdf 408 ecc_point* wc_ecc_new_point(void);
wolfSSL 13:80fb167dafdf 409 WOLFSSL_API
wolfSSL 13:80fb167dafdf 410 ecc_point* wc_ecc_new_point_h(void* h);
wolfSSL 13:80fb167dafdf 411 WOLFSSL_API
wolfSSL 13:80fb167dafdf 412 void wc_ecc_del_point(ecc_point* p);
wolfSSL 13:80fb167dafdf 413 WOLFSSL_API
wolfSSL 13:80fb167dafdf 414 void wc_ecc_del_point_h(ecc_point* p, void* h);
wolfSSL 13:80fb167dafdf 415 WOLFSSL_API
wolfSSL 13:80fb167dafdf 416 int wc_ecc_copy_point(ecc_point* p, ecc_point *r);
wolfSSL 13:80fb167dafdf 417 WOLFSSL_API
wolfSSL 13:80fb167dafdf 418 int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);
wolfSSL 13:80fb167dafdf 419 WOLFSSL_API
wolfSSL 13:80fb167dafdf 420 int wc_ecc_point_is_at_infinity(ecc_point *p);
wolfSSL 13:80fb167dafdf 421 WOLFSSL_API
wolfSSL 13:80fb167dafdf 422 int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
wolfSSL 13:80fb167dafdf 423 mp_int* a, mp_int* modulus, int map);
wolfSSL 13:80fb167dafdf 424 WOLFSSL_LOCAL
wolfSSL 13:80fb167dafdf 425 int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
wolfSSL 13:80fb167dafdf 426 mp_int* a, mp_int* modulus, int map, void* heap);
wolfSSL 13:80fb167dafdf 427 #endif /* !WOLFSSL_ATECC508A */
wolfSSL 13:80fb167dafdf 428
wolfSSL 13:80fb167dafdf 429
wolfSSL 13:80fb167dafdf 430 #ifdef HAVE_ECC_KEY_EXPORT
wolfSSL 13:80fb167dafdf 431 /* ASN key helpers */
wolfSSL 13:80fb167dafdf 432 WOLFSSL_API
wolfSSL 13:80fb167dafdf 433 int wc_ecc_export_x963(ecc_key*, byte* out, word32* outLen);
wolfSSL 13:80fb167dafdf 434 WOLFSSL_API
wolfSSL 13:80fb167dafdf 435 int wc_ecc_export_x963_ex(ecc_key*, byte* out, word32* outLen, int compressed);
wolfSSL 13:80fb167dafdf 436 /* extended functionality with compressed option */
wolfSSL 13:80fb167dafdf 437 #endif /* HAVE_ECC_KEY_EXPORT */
wolfSSL 13:80fb167dafdf 438
wolfSSL 13:80fb167dafdf 439 #ifdef HAVE_ECC_KEY_IMPORT
wolfSSL 13:80fb167dafdf 440 WOLFSSL_API
wolfSSL 13:80fb167dafdf 441 int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);
wolfSSL 13:80fb167dafdf 442 WOLFSSL_API
wolfSSL 13:80fb167dafdf 443 int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
wolfSSL 13:80fb167dafdf 444 int curve_id);
wolfSSL 13:80fb167dafdf 445 WOLFSSL_API
wolfSSL 13:80fb167dafdf 446 int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
wolfSSL 13:80fb167dafdf 447 word32 pubSz, ecc_key* key);
wolfSSL 13:80fb167dafdf 448 WOLFSSL_API
wolfSSL 13:80fb167dafdf 449 int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
wolfSSL 13:80fb167dafdf 450 const byte* pub, word32 pubSz, ecc_key* key, int curve_id);
wolfSSL 13:80fb167dafdf 451 WOLFSSL_API
wolfSSL 13:80fb167dafdf 452 int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);
wolfSSL 13:80fb167dafdf 453 WOLFSSL_API
wolfSSL 13:80fb167dafdf 454 int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen,
wolfSSL 13:80fb167dafdf 455 byte* s, word32* sLen);
wolfSSL 13:80fb167dafdf 456 WOLFSSL_API
wolfSSL 13:80fb167dafdf 457 int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
wolfSSL 13:80fb167dafdf 458 const char* d, const char* curveName);
wolfSSL 13:80fb167dafdf 459 WOLFSSL_API
wolfSSL 13:80fb167dafdf 460 int wc_ecc_import_raw_ex(ecc_key* key, const char* qx, const char* qy,
wolfSSL 13:80fb167dafdf 461 const char* d, int curve_id);
wolfSSL 13:80fb167dafdf 462 #endif /* HAVE_ECC_KEY_IMPORT */
wolfSSL 13:80fb167dafdf 463
wolfSSL 13:80fb167dafdf 464 #ifdef HAVE_ECC_KEY_EXPORT
wolfSSL 13:80fb167dafdf 465 WOLFSSL_API
wolfSSL 13:80fb167dafdf 466 int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
wolfSSL 13:80fb167dafdf 467 WOLFSSL_API
wolfSSL 13:80fb167dafdf 468 int wc_ecc_export_public_raw(ecc_key* key, byte* qx, word32* qxLen,
wolfSSL 13:80fb167dafdf 469 byte* qy, word32* qyLen);
wolfSSL 13:80fb167dafdf 470 WOLFSSL_API
wolfSSL 13:80fb167dafdf 471 int wc_ecc_export_private_raw(ecc_key* key, byte* qx, word32* qxLen,
wolfSSL 13:80fb167dafdf 472 byte* qy, word32* qyLen, byte* d, word32* dLen);
wolfSSL 13:80fb167dafdf 473 #endif /* HAVE_ECC_KEY_EXPORT */
wolfSSL 13:80fb167dafdf 474
wolfSSL 13:80fb167dafdf 475 #ifdef HAVE_ECC_KEY_EXPORT
wolfSSL 13:80fb167dafdf 476
wolfSSL 13:80fb167dafdf 477 WOLFSSL_API
wolfSSL 13:80fb167dafdf 478 int wc_ecc_export_point_der(const int curve_idx, ecc_point* point,
wolfSSL 13:80fb167dafdf 479 byte* out, word32* outLen);
wolfSSL 13:80fb167dafdf 480 #endif /* HAVE_ECC_KEY_EXPORT */
wolfSSL 13:80fb167dafdf 481
wolfSSL 13:80fb167dafdf 482
wolfSSL 13:80fb167dafdf 483 #ifdef HAVE_ECC_KEY_IMPORT
wolfSSL 13:80fb167dafdf 484 WOLFSSL_API
wolfSSL 13:80fb167dafdf 485 int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx,
wolfSSL 13:80fb167dafdf 486 ecc_point* point);
wolfSSL 13:80fb167dafdf 487 #endif /* HAVE_ECC_KEY_IMPORT */
wolfSSL 13:80fb167dafdf 488
wolfSSL 13:80fb167dafdf 489 /* size helper */
wolfSSL 13:80fb167dafdf 490 WOLFSSL_API
wolfSSL 13:80fb167dafdf 491 int wc_ecc_size(ecc_key* key);
wolfSSL 13:80fb167dafdf 492 WOLFSSL_API
wolfSSL 13:80fb167dafdf 493 int wc_ecc_sig_size(ecc_key* key);
wolfSSL 13:80fb167dafdf 494
wolfSSL 13:80fb167dafdf 495 WOLFSSL_API
wolfSSL 13:80fb167dafdf 496 int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz);
wolfSSL 13:80fb167dafdf 497
wolfSSL 13:80fb167dafdf 498 #ifdef WOLFSSL_CUSTOM_CURVES
wolfSSL 13:80fb167dafdf 499 WOLFSSL_API
wolfSSL 13:80fb167dafdf 500 int wc_ecc_set_custom_curve(ecc_key* key, const ecc_set_type* dp);
wolfSSL 13:80fb167dafdf 501 #endif
wolfSSL 13:80fb167dafdf 502
wolfSSL 13:80fb167dafdf 503 #ifdef HAVE_ECC_ENCRYPT
wolfSSL 13:80fb167dafdf 504 /* ecc encrypt */
wolfSSL 13:80fb167dafdf 505
wolfSSL 13:80fb167dafdf 506 enum ecEncAlgo {
wolfSSL 13:80fb167dafdf 507 ecAES_128_CBC = 1, /* default */
wolfSSL 13:80fb167dafdf 508 ecAES_256_CBC = 2
wolfSSL 13:80fb167dafdf 509 };
wolfSSL 13:80fb167dafdf 510
wolfSSL 13:80fb167dafdf 511 enum ecKdfAlgo {
wolfSSL 13:80fb167dafdf 512 ecHKDF_SHA256 = 1, /* default */
wolfSSL 13:80fb167dafdf 513 ecHKDF_SHA1 = 2
wolfSSL 13:80fb167dafdf 514 };
wolfSSL 13:80fb167dafdf 515
wolfSSL 13:80fb167dafdf 516 enum ecMacAlgo {
wolfSSL 13:80fb167dafdf 517 ecHMAC_SHA256 = 1, /* default */
wolfSSL 13:80fb167dafdf 518 ecHMAC_SHA1 = 2
wolfSSL 13:80fb167dafdf 519 };
wolfSSL 13:80fb167dafdf 520
wolfSSL 13:80fb167dafdf 521 enum {
wolfSSL 13:80fb167dafdf 522 KEY_SIZE_128 = 16,
wolfSSL 13:80fb167dafdf 523 KEY_SIZE_256 = 32,
wolfSSL 13:80fb167dafdf 524 IV_SIZE_64 = 8,
wolfSSL 13:80fb167dafdf 525 IV_SIZE_128 = 16,
wolfSSL 13:80fb167dafdf 526 EXCHANGE_SALT_SZ = 16,
wolfSSL 13:80fb167dafdf 527 EXCHANGE_INFO_SZ = 23
wolfSSL 13:80fb167dafdf 528 };
wolfSSL 13:80fb167dafdf 529
wolfSSL 13:80fb167dafdf 530 enum ecFlags {
wolfSSL 13:80fb167dafdf 531 REQ_RESP_CLIENT = 1,
wolfSSL 13:80fb167dafdf 532 REQ_RESP_SERVER = 2
wolfSSL 13:80fb167dafdf 533 };
wolfSSL 13:80fb167dafdf 534
wolfSSL 13:80fb167dafdf 535
wolfSSL 13:80fb167dafdf 536 typedef struct ecEncCtx ecEncCtx;
wolfSSL 13:80fb167dafdf 537
wolfSSL 13:80fb167dafdf 538 WOLFSSL_API
wolfSSL 13:80fb167dafdf 539 ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng);
wolfSSL 13:80fb167dafdf 540 WOLFSSL_API
wolfSSL 13:80fb167dafdf 541 ecEncCtx* wc_ecc_ctx_new_ex(int flags, WC_RNG* rng, void* heap);
wolfSSL 13:80fb167dafdf 542 WOLFSSL_API
wolfSSL 13:80fb167dafdf 543 void wc_ecc_ctx_free(ecEncCtx*);
wolfSSL 13:80fb167dafdf 544 WOLFSSL_API
wolfSSL 13:80fb167dafdf 545 int wc_ecc_ctx_reset(ecEncCtx*, WC_RNG*); /* reset for use again w/o alloc/free */
wolfSSL 13:80fb167dafdf 546
wolfSSL 13:80fb167dafdf 547 WOLFSSL_API
wolfSSL 13:80fb167dafdf 548 const byte* wc_ecc_ctx_get_own_salt(ecEncCtx*);
wolfSSL 13:80fb167dafdf 549 WOLFSSL_API
wolfSSL 13:80fb167dafdf 550 int wc_ecc_ctx_set_peer_salt(ecEncCtx*, const byte* salt);
wolfSSL 13:80fb167dafdf 551 WOLFSSL_API
wolfSSL 13:80fb167dafdf 552 int wc_ecc_ctx_set_info(ecEncCtx*, const byte* info, int sz);
wolfSSL 13:80fb167dafdf 553
wolfSSL 13:80fb167dafdf 554 WOLFSSL_API
wolfSSL 13:80fb167dafdf 555 int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
wolfSSL 13:80fb167dafdf 556 word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
wolfSSL 13:80fb167dafdf 557 WOLFSSL_API
wolfSSL 13:80fb167dafdf 558 int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
wolfSSL 13:80fb167dafdf 559 word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
wolfSSL 13:80fb167dafdf 560
wolfSSL 13:80fb167dafdf 561 #endif /* HAVE_ECC_ENCRYPT */
wolfSSL 13:80fb167dafdf 562
wolfSSL 13:80fb167dafdf 563 #ifdef HAVE_X963_KDF
wolfSSL 13:80fb167dafdf 564 WOLFSSL_API int wc_X963_KDF(enum wc_HashType type, const byte* secret,
wolfSSL 13:80fb167dafdf 565 word32 secretSz, const byte* sinfo, word32 sinfoSz,
wolfSSL 13:80fb167dafdf 566 byte* out, word32 outSz);
wolfSSL 13:80fb167dafdf 567 #endif
wolfSSL 13:80fb167dafdf 568
wolfSSL 13:80fb167dafdf 569 #ifdef ECC_CACHE_CURVE
wolfSSL 13:80fb167dafdf 570 WOLFSSL_API int wc_ecc_curve_cache_init(void);
wolfSSL 13:80fb167dafdf 571 WOLFSSL_API void wc_ecc_curve_cache_free(void);
wolfSSL 13:80fb167dafdf 572 #endif
wolfSSL 13:80fb167dafdf 573
wolfSSL 13:80fb167dafdf 574
wolfSSL 13:80fb167dafdf 575 #ifdef __cplusplus
wolfSSL 13:80fb167dafdf 576 } /* extern "C" */
wolfSSL 13:80fb167dafdf 577 #endif
wolfSSL 13:80fb167dafdf 578
wolfSSL 13:80fb167dafdf 579 #endif /* HAVE_ECC */
wolfSSL 13:80fb167dafdf 580 #endif /* WOLF_CRYPT_ECC_H */
wolfSSL 13:80fb167dafdf 581