diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ec/ec.h | 319 |
1 files changed, 301 insertions, 18 deletions
diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h index 6d6a9b7127..8bc2a235b1 100644 --- a/src/lib/libcrypto/ec/ec.h +++ b/src/lib/libcrypto/ec/ec.h | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | /* crypto/ec/ec.h */ | 1 | /* crypto/ec/ec.h */ |
| 2 | /* | ||
| 3 | * Originally written by Bodo Moeller for the OpenSSL project. | ||
| 4 | */ | ||
| 2 | /* ==================================================================== | 5 | /* ==================================================================== |
| 3 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. |
| 4 | * | 7 | * |
| 5 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
| @@ -52,22 +55,48 @@ | |||
| 52 | * Hudson (tjh@cryptsoft.com). | 55 | * Hudson (tjh@cryptsoft.com). |
| 53 | * | 56 | * |
| 54 | */ | 57 | */ |
| 58 | /* ==================================================================== | ||
| 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | ||
| 60 | * | ||
| 61 | * Portions of the attached software ("Contribution") are developed by | ||
| 62 | * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. | ||
| 63 | * | ||
| 64 | * The Contribution is licensed pursuant to the OpenSSL open source | ||
| 65 | * license provided above. | ||
| 66 | * | ||
| 67 | * The elliptic curve binary polynomial software is originally written by | ||
| 68 | * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. | ||
| 69 | * | ||
| 70 | */ | ||
| 55 | 71 | ||
| 56 | #ifndef HEADER_EC_H | 72 | #ifndef HEADER_EC_H |
| 57 | #define HEADER_EC_H | 73 | #define HEADER_EC_H |
| 58 | 74 | ||
| 75 | #include <openssl/opensslconf.h> | ||
| 76 | |||
| 59 | #ifdef OPENSSL_NO_EC | 77 | #ifdef OPENSSL_NO_EC |
| 60 | #error EC is disabled. | 78 | #error EC is disabled. |
| 61 | #endif | 79 | #endif |
| 62 | 80 | ||
| 63 | #include <openssl/bn.h> | 81 | #include <openssl/asn1.h> |
| 64 | #include <openssl/symhacks.h> | 82 | #include <openssl/symhacks.h> |
| 83 | #ifndef OPENSSL_NO_DEPRECATED | ||
| 84 | #include <openssl/bn.h> | ||
| 85 | #endif | ||
| 65 | 86 | ||
| 66 | #ifdef __cplusplus | 87 | #ifdef __cplusplus |
| 67 | extern "C" { | 88 | extern "C" { |
| 89 | #elif defined(__SUNPRO_C) | ||
| 90 | # if __SUNPRO_C >= 0x520 | ||
| 91 | # pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) | ||
| 92 | # endif | ||
| 68 | #endif | 93 | #endif |
| 69 | 94 | ||
| 70 | 95 | ||
| 96 | #ifndef OPENSSL_ECC_MAX_FIELD_BITS | ||
| 97 | # define OPENSSL_ECC_MAX_FIELD_BITS 661 | ||
| 98 | #endif | ||
| 99 | |||
| 71 | typedef enum { | 100 | typedef enum { |
| 72 | /* values as defined in X9.62 (ECDSA) and elsewhere */ | 101 | /* values as defined in X9.62 (ECDSA) and elsewhere */ |
| 73 | POINT_CONVERSION_COMPRESSED = 2, | 102 | POINT_CONVERSION_COMPRESSED = 2, |
| @@ -84,7 +113,8 @@ typedef struct ec_group_st | |||
| 84 | -- field definition | 113 | -- field definition |
| 85 | -- curve coefficients | 114 | -- curve coefficients |
| 86 | -- optional generator with associated information (order, cofactor) | 115 | -- optional generator with associated information (order, cofactor) |
| 87 | -- optional extra data (TODO: precomputed table for fast computation of multiples of generator) | 116 | -- optional extra data (precomputed table for fast computation of multiples of generator) |
| 117 | -- ASN1 stuff | ||
| 88 | */ | 118 | */ |
| 89 | EC_GROUP; | 119 | EC_GROUP; |
| 90 | 120 | ||
| @@ -96,40 +126,84 @@ typedef struct ec_point_st EC_POINT; | |||
| 96 | */ | 126 | */ |
| 97 | const EC_METHOD *EC_GFp_simple_method(void); | 127 | const EC_METHOD *EC_GFp_simple_method(void); |
| 98 | const EC_METHOD *EC_GFp_mont_method(void); | 128 | const EC_METHOD *EC_GFp_mont_method(void); |
| 99 | #if 0 | 129 | const EC_METHOD *EC_GFp_nist_method(void); |
| 100 | const EC_METHOD *EC_GFp_recp_method(void); /* TODO */ | 130 | |
| 101 | const EC_METHOD *EC_GFp_nist_method(void); /* TODO */ | 131 | /* EC_METHOD for curves over GF(2^m). |
| 102 | #endif | 132 | */ |
| 133 | const EC_METHOD *EC_GF2m_simple_method(void); | ||
| 103 | 134 | ||
| 104 | 135 | ||
| 105 | EC_GROUP *EC_GROUP_new(const EC_METHOD *); | 136 | EC_GROUP *EC_GROUP_new(const EC_METHOD *); |
| 106 | void EC_GROUP_free(EC_GROUP *); | 137 | void EC_GROUP_free(EC_GROUP *); |
| 107 | void EC_GROUP_clear_free(EC_GROUP *); | 138 | void EC_GROUP_clear_free(EC_GROUP *); |
| 108 | int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); | 139 | int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); |
| 140 | EC_GROUP *EC_GROUP_dup(const EC_GROUP *); | ||
| 109 | 141 | ||
| 110 | const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); | 142 | const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); |
| 111 | 143 | int EC_METHOD_get_field_type(const EC_METHOD *); | |
| 144 | |||
| 145 | int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); | ||
| 146 | const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); | ||
| 147 | int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); | ||
| 148 | int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); | ||
| 149 | |||
| 150 | void EC_GROUP_set_curve_name(EC_GROUP *, int nid); | ||
| 151 | int EC_GROUP_get_curve_name(const EC_GROUP *); | ||
| 152 | |||
| 153 | void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); | ||
| 154 | int EC_GROUP_get_asn1_flag(const EC_GROUP *); | ||
| 155 | |||
| 156 | void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); | ||
| 157 | point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); | ||
| 158 | |||
| 159 | unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); | ||
| 160 | size_t EC_GROUP_get_seed_len(const EC_GROUP *); | ||
| 161 | size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); | ||
| 112 | 162 | ||
| 113 | /* We don't have types for field specifications and field elements in general. | ||
| 114 | * Otherwise we could declare | ||
| 115 | * int EC_GROUP_set_curve(EC_GROUP *, .....); | ||
| 116 | */ | ||
| 117 | int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | 163 | int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); |
| 118 | int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); | 164 | int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); |
| 165 | int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | ||
| 166 | int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); | ||
| 167 | |||
| 168 | /* returns the number of bits needed to represent a field element */ | ||
| 169 | int EC_GROUP_get_degree(const EC_GROUP *); | ||
| 170 | |||
| 171 | /* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ | ||
| 172 | int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); | ||
| 173 | /* EC_GROUP_check_discriminant() returns 1 if the discriminant of the | ||
| 174 | * elliptic curve is not zero, 0 otherwise */ | ||
| 175 | int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); | ||
| 119 | 176 | ||
| 120 | /* EC_GROUP_new_GFp() calls EC_GROUP_new() and EC_GROUP_set_GFp() | 177 | /* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ |
| 178 | int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); | ||
| 179 | |||
| 180 | /* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() | ||
| 121 | * after choosing an appropriate EC_METHOD */ | 181 | * after choosing an appropriate EC_METHOD */ |
| 122 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | 182 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); |
| 183 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | ||
| 123 | 184 | ||
| 124 | int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); | 185 | /* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure |
| 125 | EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); | 186 | * specified by a curve name (in form of a NID) */ |
| 126 | int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); | 187 | EC_GROUP *EC_GROUP_new_by_curve_name(int nid); |
| 127 | int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); | 188 | /* handling of internal curves */ |
| 189 | typedef struct { | ||
| 190 | int nid; | ||
| 191 | const char *comment; | ||
| 192 | } EC_builtin_curve; | ||
| 193 | /* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number | ||
| 194 | * of all available curves or zero if a error occurred. | ||
| 195 | * In case r ist not zero nitems EC_builtin_curve structures | ||
| 196 | * are filled with the data of the first nitems internal groups */ | ||
| 197 | size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); | ||
| 198 | |||
| 199 | |||
| 200 | /* EC_POINT functions */ | ||
| 128 | 201 | ||
| 129 | EC_POINT *EC_POINT_new(const EC_GROUP *); | 202 | EC_POINT *EC_POINT_new(const EC_GROUP *); |
| 130 | void EC_POINT_free(EC_POINT *); | 203 | void EC_POINT_free(EC_POINT *); |
| 131 | void EC_POINT_clear_free(EC_POINT *); | 204 | void EC_POINT_clear_free(EC_POINT *); |
| 132 | int EC_POINT_copy(EC_POINT *, const EC_POINT *); | 205 | int EC_POINT_copy(EC_POINT *, const EC_POINT *); |
| 206 | EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); | ||
| 133 | 207 | ||
| 134 | const EC_METHOD *EC_POINT_method_of(const EC_POINT *); | 208 | const EC_METHOD *EC_POINT_method_of(const EC_POINT *); |
| 135 | 209 | ||
| @@ -145,11 +219,28 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, | |||
| 145 | int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, | 219 | int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, |
| 146 | const BIGNUM *x, int y_bit, BN_CTX *); | 220 | const BIGNUM *x, int y_bit, BN_CTX *); |
| 147 | 221 | ||
| 222 | int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, | ||
| 223 | const BIGNUM *x, const BIGNUM *y, BN_CTX *); | ||
| 224 | int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, | ||
| 225 | BIGNUM *x, BIGNUM *y, BN_CTX *); | ||
| 226 | int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, | ||
| 227 | const BIGNUM *x, int y_bit, BN_CTX *); | ||
| 228 | |||
| 148 | size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, | 229 | size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, |
| 149 | unsigned char *buf, size_t len, BN_CTX *); | 230 | unsigned char *buf, size_t len, BN_CTX *); |
| 150 | int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, | 231 | int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, |
| 151 | const unsigned char *buf, size_t len, BN_CTX *); | 232 | const unsigned char *buf, size_t len, BN_CTX *); |
| 152 | 233 | ||
| 234 | /* other interfaces to point2oct/oct2point: */ | ||
| 235 | BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, | ||
| 236 | point_conversion_form_t form, BIGNUM *, BN_CTX *); | ||
| 237 | EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, | ||
| 238 | EC_POINT *, BN_CTX *); | ||
| 239 | char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, | ||
| 240 | point_conversion_form_t form, BN_CTX *); | ||
| 241 | EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, | ||
| 242 | EC_POINT *, BN_CTX *); | ||
| 243 | |||
| 153 | int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); | 244 | int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); |
| 154 | int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); | 245 | int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); |
| 155 | int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); | 246 | int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); |
| @@ -164,9 +255,112 @@ int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); | |||
| 164 | 255 | ||
| 165 | int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); | 256 | int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); |
| 166 | int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); | 257 | int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); |
| 258 | |||
| 259 | /* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ | ||
| 167 | int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); | 260 | int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); |
| 261 | /* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ | ||
| 262 | int EC_GROUP_have_precompute_mult(const EC_GROUP *); | ||
| 263 | |||
| 264 | |||
| 168 | 265 | ||
| 266 | /* ASN1 stuff */ | ||
| 169 | 267 | ||
| 268 | /* EC_GROUP_get_basis_type() returns the NID of the basis type | ||
| 269 | * used to represent the field elements */ | ||
| 270 | int EC_GROUP_get_basis_type(const EC_GROUP *); | ||
| 271 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); | ||
| 272 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, | ||
| 273 | unsigned int *k2, unsigned int *k3); | ||
| 274 | |||
| 275 | #define OPENSSL_EC_NAMED_CURVE 0x001 | ||
| 276 | |||
| 277 | typedef struct ecpk_parameters_st ECPKPARAMETERS; | ||
| 278 | |||
| 279 | EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); | ||
| 280 | int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); | ||
| 281 | |||
| 282 | #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) | ||
| 283 | #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) | ||
| 284 | #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ | ||
| 285 | (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) | ||
| 286 | #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ | ||
| 287 | (unsigned char *)(x)) | ||
| 288 | |||
| 289 | #ifndef OPENSSL_NO_BIO | ||
| 290 | int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); | ||
| 291 | #endif | ||
| 292 | #ifndef OPENSSL_NO_FP_API | ||
| 293 | int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); | ||
| 294 | #endif | ||
| 295 | |||
| 296 | /* the EC_KEY stuff */ | ||
| 297 | typedef struct ec_key_st EC_KEY; | ||
| 298 | |||
| 299 | /* some values for the encoding_flag */ | ||
| 300 | #define EC_PKEY_NO_PARAMETERS 0x001 | ||
| 301 | #define EC_PKEY_NO_PUBKEY 0x002 | ||
| 302 | |||
| 303 | EC_KEY *EC_KEY_new(void); | ||
| 304 | EC_KEY *EC_KEY_new_by_curve_name(int nid); | ||
| 305 | void EC_KEY_free(EC_KEY *); | ||
| 306 | EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); | ||
| 307 | EC_KEY *EC_KEY_dup(const EC_KEY *); | ||
| 308 | |||
| 309 | int EC_KEY_up_ref(EC_KEY *); | ||
| 310 | |||
| 311 | const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); | ||
| 312 | int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); | ||
| 313 | const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); | ||
| 314 | int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); | ||
| 315 | const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); | ||
| 316 | int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); | ||
| 317 | unsigned EC_KEY_get_enc_flags(const EC_KEY *); | ||
| 318 | void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); | ||
| 319 | point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); | ||
| 320 | void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); | ||
| 321 | /* functions to set/get method specific data */ | ||
| 322 | void *EC_KEY_get_key_method_data(EC_KEY *, | ||
| 323 | void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); | ||
| 324 | void EC_KEY_insert_key_method_data(EC_KEY *, void *data, | ||
| 325 | void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); | ||
| 326 | /* wrapper functions for the underlying EC_GROUP object */ | ||
| 327 | void EC_KEY_set_asn1_flag(EC_KEY *, int); | ||
| 328 | int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); | ||
| 329 | |||
| 330 | /* EC_KEY_generate_key() creates a ec private (public) key */ | ||
| 331 | int EC_KEY_generate_key(EC_KEY *); | ||
| 332 | /* EC_KEY_check_key() */ | ||
| 333 | int EC_KEY_check_key(const EC_KEY *); | ||
| 334 | |||
| 335 | /* de- and encoding functions for SEC1 ECPrivateKey */ | ||
| 336 | EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); | ||
| 337 | int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); | ||
| 338 | /* de- and encoding functions for EC parameters */ | ||
| 339 | EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); | ||
| 340 | int i2d_ECParameters(EC_KEY *a, unsigned char **out); | ||
| 341 | /* de- and encoding functions for EC public key | ||
| 342 | * (octet string, not DER -- hence 'o2i' and 'i2o') */ | ||
| 343 | EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); | ||
| 344 | int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); | ||
| 345 | |||
| 346 | #ifndef OPENSSL_NO_BIO | ||
| 347 | int ECParameters_print(BIO *bp, const EC_KEY *x); | ||
| 348 | int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); | ||
| 349 | #endif | ||
| 350 | #ifndef OPENSSL_NO_FP_API | ||
| 351 | int ECParameters_print_fp(FILE *fp, const EC_KEY *x); | ||
| 352 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); | ||
| 353 | #endif | ||
| 354 | |||
| 355 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) | ||
| 356 | |||
| 357 | #ifndef __cplusplus | ||
| 358 | #if defined(__SUNPRO_C) | ||
| 359 | # if __SUNPRO_C >= 0x520 | ||
| 360 | # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) | ||
| 361 | # endif | ||
| 362 | # endif | ||
| 363 | #endif | ||
| 170 | 364 | ||
| 171 | /* BEGIN ERROR CODES */ | 365 | /* BEGIN ERROR CODES */ |
| 172 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 366 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| @@ -178,51 +372,124 @@ void ERR_load_EC_strings(void); | |||
| 178 | 372 | ||
| 179 | /* Function codes. */ | 373 | /* Function codes. */ |
| 180 | #define EC_F_COMPUTE_WNAF 143 | 374 | #define EC_F_COMPUTE_WNAF 143 |
| 375 | #define EC_F_D2I_ECPARAMETERS 144 | ||
| 376 | #define EC_F_D2I_ECPKPARAMETERS 145 | ||
| 377 | #define EC_F_D2I_ECPRIVATEKEY 146 | ||
| 378 | #define EC_F_ECPARAMETERS_PRINT 147 | ||
| 379 | #define EC_F_ECPARAMETERS_PRINT_FP 148 | ||
| 380 | #define EC_F_ECPKPARAMETERS_PRINT 149 | ||
| 381 | #define EC_F_ECPKPARAMETERS_PRINT_FP 150 | ||
| 382 | #define EC_F_ECP_NIST_MOD_192 203 | ||
| 383 | #define EC_F_ECP_NIST_MOD_224 204 | ||
| 384 | #define EC_F_ECP_NIST_MOD_256 205 | ||
| 385 | #define EC_F_ECP_NIST_MOD_521 206 | ||
| 386 | #define EC_F_EC_ASN1_GROUP2CURVE 153 | ||
| 387 | #define EC_F_EC_ASN1_GROUP2FIELDID 154 | ||
| 388 | #define EC_F_EC_ASN1_GROUP2PARAMETERS 155 | ||
| 389 | #define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 | ||
| 390 | #define EC_F_EC_ASN1_PARAMETERS2GROUP 157 | ||
| 391 | #define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 | ||
| 392 | #define EC_F_EC_EX_DATA_SET_DATA 211 | ||
| 393 | #define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 | ||
| 394 | #define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 | ||
| 395 | #define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 | ||
| 396 | #define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 | ||
| 397 | #define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 | ||
| 398 | #define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 | ||
| 399 | #define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 | ||
| 400 | #define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 | ||
| 181 | #define EC_F_EC_GFP_MONT_FIELD_DECODE 133 | 401 | #define EC_F_EC_GFP_MONT_FIELD_DECODE 133 |
| 182 | #define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 | 402 | #define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 |
| 183 | #define EC_F_EC_GFP_MONT_FIELD_MUL 131 | 403 | #define EC_F_EC_GFP_MONT_FIELD_MUL 131 |
| 404 | #define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 | ||
| 184 | #define EC_F_EC_GFP_MONT_FIELD_SQR 132 | 405 | #define EC_F_EC_GFP_MONT_FIELD_SQR 132 |
| 406 | #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 | ||
| 407 | #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 | ||
| 408 | #define EC_F_EC_GFP_NIST_FIELD_MUL 200 | ||
| 409 | #define EC_F_EC_GFP_NIST_FIELD_SQR 201 | ||
| 410 | #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 | ||
| 411 | #define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 | ||
| 412 | #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 | ||
| 185 | #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 | 413 | #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 |
| 186 | #define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 | 414 | #define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 |
| 187 | #define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 | 415 | #define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 |
| 188 | #define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 | 416 | #define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 |
| 189 | #define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 | 417 | #define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 |
| 190 | #define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 | 418 | #define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 |
| 419 | #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 | ||
| 191 | #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 | 420 | #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 |
| 421 | #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 | ||
| 192 | #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 | 422 | #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 |
| 423 | #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 | ||
| 193 | #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 | 424 | #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 |
| 425 | #define EC_F_EC_GROUP_CHECK 170 | ||
| 426 | #define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 | ||
| 194 | #define EC_F_EC_GROUP_COPY 106 | 427 | #define EC_F_EC_GROUP_COPY 106 |
| 195 | #define EC_F_EC_GROUP_GET0_GENERATOR 139 | 428 | #define EC_F_EC_GROUP_GET0_GENERATOR 139 |
| 196 | #define EC_F_EC_GROUP_GET_COFACTOR 140 | 429 | #define EC_F_EC_GROUP_GET_COFACTOR 140 |
| 430 | #define EC_F_EC_GROUP_GET_CURVE_GF2M 172 | ||
| 197 | #define EC_F_EC_GROUP_GET_CURVE_GFP 130 | 431 | #define EC_F_EC_GROUP_GET_CURVE_GFP 130 |
| 432 | #define EC_F_EC_GROUP_GET_DEGREE 173 | ||
| 198 | #define EC_F_EC_GROUP_GET_ORDER 141 | 433 | #define EC_F_EC_GROUP_GET_ORDER 141 |
| 434 | #define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 | ||
| 435 | #define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 | ||
| 199 | #define EC_F_EC_GROUP_NEW 108 | 436 | #define EC_F_EC_GROUP_NEW 108 |
| 437 | #define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 | ||
| 438 | #define EC_F_EC_GROUP_NEW_FROM_DATA 175 | ||
| 200 | #define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 | 439 | #define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 |
| 440 | #define EC_F_EC_GROUP_SET_CURVE_GF2M 176 | ||
| 201 | #define EC_F_EC_GROUP_SET_CURVE_GFP 109 | 441 | #define EC_F_EC_GROUP_SET_CURVE_GFP 109 |
| 202 | #define EC_F_EC_GROUP_SET_EXTRA_DATA 110 | 442 | #define EC_F_EC_GROUP_SET_EXTRA_DATA 110 |
| 203 | #define EC_F_EC_GROUP_SET_GENERATOR 111 | 443 | #define EC_F_EC_GROUP_SET_GENERATOR 111 |
| 444 | #define EC_F_EC_KEY_CHECK_KEY 177 | ||
| 445 | #define EC_F_EC_KEY_COPY 178 | ||
| 446 | #define EC_F_EC_KEY_GENERATE_KEY 179 | ||
| 447 | #define EC_F_EC_KEY_NEW 182 | ||
| 448 | #define EC_F_EC_KEY_PRINT 180 | ||
| 449 | #define EC_F_EC_KEY_PRINT_FP 181 | ||
| 204 | #define EC_F_EC_POINTS_MAKE_AFFINE 136 | 450 | #define EC_F_EC_POINTS_MAKE_AFFINE 136 |
| 205 | #define EC_F_EC_POINTS_MUL 138 | 451 | #define EC_F_EC_POINTS_MUL 138 |
| 206 | #define EC_F_EC_POINT_ADD 112 | 452 | #define EC_F_EC_POINT_ADD 112 |
| 207 | #define EC_F_EC_POINT_CMP 113 | 453 | #define EC_F_EC_POINT_CMP 113 |
| 208 | #define EC_F_EC_POINT_COPY 114 | 454 | #define EC_F_EC_POINT_COPY 114 |
| 209 | #define EC_F_EC_POINT_DBL 115 | 455 | #define EC_F_EC_POINT_DBL 115 |
| 456 | #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 | ||
| 210 | #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 | 457 | #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 |
| 211 | #define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 | 458 | #define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 |
| 459 | #define EC_F_EC_POINT_INVERT 210 | ||
| 212 | #define EC_F_EC_POINT_IS_AT_INFINITY 118 | 460 | #define EC_F_EC_POINT_IS_AT_INFINITY 118 |
| 213 | #define EC_F_EC_POINT_IS_ON_CURVE 119 | 461 | #define EC_F_EC_POINT_IS_ON_CURVE 119 |
| 214 | #define EC_F_EC_POINT_MAKE_AFFINE 120 | 462 | #define EC_F_EC_POINT_MAKE_AFFINE 120 |
| 463 | #define EC_F_EC_POINT_MUL 184 | ||
| 215 | #define EC_F_EC_POINT_NEW 121 | 464 | #define EC_F_EC_POINT_NEW 121 |
| 216 | #define EC_F_EC_POINT_OCT2POINT 122 | 465 | #define EC_F_EC_POINT_OCT2POINT 122 |
| 217 | #define EC_F_EC_POINT_POINT2OCT 123 | 466 | #define EC_F_EC_POINT_POINT2OCT 123 |
| 467 | #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 | ||
| 218 | #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 | 468 | #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 |
| 469 | #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 | ||
| 219 | #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 | 470 | #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 |
| 220 | #define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 | 471 | #define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 |
| 221 | #define EC_F_EC_POINT_SET_TO_INFINITY 127 | 472 | #define EC_F_EC_POINT_SET_TO_INFINITY 127 |
| 222 | #define EC_F_GFP_MONT_GROUP_SET_CURVE_GFP 135 | 473 | #define EC_F_EC_PRE_COMP_DUP 207 |
| 474 | #define EC_F_EC_PRE_COMP_NEW 196 | ||
| 475 | #define EC_F_EC_WNAF_MUL 187 | ||
| 476 | #define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 | ||
| 477 | #define EC_F_I2D_ECPARAMETERS 190 | ||
| 478 | #define EC_F_I2D_ECPKPARAMETERS 191 | ||
| 479 | #define EC_F_I2D_ECPRIVATEKEY 192 | ||
| 480 | #define EC_F_I2O_ECPUBLICKEY 151 | ||
| 481 | #define EC_F_O2I_ECPUBLICKEY 152 | ||
| 223 | 482 | ||
| 224 | /* Reason codes. */ | 483 | /* Reason codes. */ |
| 484 | #define EC_R_ASN1_ERROR 115 | ||
| 485 | #define EC_R_ASN1_UNKNOWN_FIELD 116 | ||
| 225 | #define EC_R_BUFFER_TOO_SMALL 100 | 486 | #define EC_R_BUFFER_TOO_SMALL 100 |
| 487 | #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 | ||
| 488 | #define EC_R_DISCRIMINANT_IS_ZERO 118 | ||
| 489 | #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 | ||
| 490 | #define EC_R_FIELD_TOO_LARGE 138 | ||
| 491 | #define EC_R_GROUP2PKPARAMETERS_FAILURE 120 | ||
| 492 | #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 | ||
| 226 | #define EC_R_INCOMPATIBLE_OBJECTS 101 | 493 | #define EC_R_INCOMPATIBLE_OBJECTS 101 |
| 227 | #define EC_R_INVALID_ARGUMENT 112 | 494 | #define EC_R_INVALID_ARGUMENT 112 |
| 228 | #define EC_R_INVALID_COMPRESSED_POINT 110 | 495 | #define EC_R_INVALID_COMPRESSED_POINT 110 |
| @@ -230,12 +497,28 @@ void ERR_load_EC_strings(void); | |||
| 230 | #define EC_R_INVALID_ENCODING 102 | 497 | #define EC_R_INVALID_ENCODING 102 |
| 231 | #define EC_R_INVALID_FIELD 103 | 498 | #define EC_R_INVALID_FIELD 103 |
| 232 | #define EC_R_INVALID_FORM 104 | 499 | #define EC_R_INVALID_FORM 104 |
| 500 | #define EC_R_INVALID_GROUP_ORDER 122 | ||
| 501 | #define EC_R_INVALID_PENTANOMIAL_BASIS 132 | ||
| 502 | #define EC_R_INVALID_PRIVATE_KEY 123 | ||
| 503 | #define EC_R_INVALID_TRINOMIAL_BASIS 137 | ||
| 504 | #define EC_R_MISSING_PARAMETERS 124 | ||
| 505 | #define EC_R_MISSING_PRIVATE_KEY 125 | ||
| 506 | #define EC_R_NOT_A_NIST_PRIME 135 | ||
| 507 | #define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 | ||
| 508 | #define EC_R_NOT_IMPLEMENTED 126 | ||
| 233 | #define EC_R_NOT_INITIALIZED 111 | 509 | #define EC_R_NOT_INITIALIZED 111 |
| 510 | #define EC_R_NO_FIELD_MOD 133 | ||
| 511 | #define EC_R_PASSED_NULL_PARAMETER 134 | ||
| 512 | #define EC_R_PKPARAMETERS2GROUP_FAILURE 127 | ||
| 234 | #define EC_R_POINT_AT_INFINITY 106 | 513 | #define EC_R_POINT_AT_INFINITY 106 |
| 235 | #define EC_R_POINT_IS_NOT_ON_CURVE 107 | 514 | #define EC_R_POINT_IS_NOT_ON_CURVE 107 |
| 236 | #define EC_R_SLOT_FULL 108 | 515 | #define EC_R_SLOT_FULL 108 |
| 237 | #define EC_R_UNDEFINED_GENERATOR 113 | 516 | #define EC_R_UNDEFINED_GENERATOR 113 |
| 517 | #define EC_R_UNDEFINED_ORDER 128 | ||
| 518 | #define EC_R_UNKNOWN_GROUP 129 | ||
| 238 | #define EC_R_UNKNOWN_ORDER 114 | 519 | #define EC_R_UNKNOWN_ORDER 114 |
| 520 | #define EC_R_UNSUPPORTED_FIELD 131 | ||
| 521 | #define EC_R_WRONG_ORDER 130 | ||
| 239 | 522 | ||
| 240 | #ifdef __cplusplus | 523 | #ifdef __cplusplus |
| 241 | } | 524 | } |
