LTKCPP-- LLRP Toolkit C Plus Plus Library
|
00001 /* crypto/ec/ec.h */ 00002 /* 00003 * Originally written by Bodo Moeller for the OpenSSL project. 00004 */ 00009 /* ==================================================================== 00010 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions 00014 * are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright 00017 * notice, this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in 00021 * the documentation and/or other materials provided with the 00022 * distribution. 00023 * 00024 * 3. All advertising materials mentioning features or use of this 00025 * software must display the following acknowledgment: 00026 * "This product includes software developed by the OpenSSL Project 00027 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 00028 * 00029 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 00030 * endorse or promote products derived from this software without 00031 * prior written permission. For written permission, please contact 00032 * openssl-core@openssl.org. 00033 * 00034 * 5. Products derived from this software may not be called "OpenSSL" 00035 * nor may "OpenSSL" appear in their names without prior written 00036 * permission of the OpenSSL Project. 00037 * 00038 * 6. Redistributions of any form whatsoever must retain the following 00039 * acknowledgment: 00040 * "This product includes software developed by the OpenSSL Project 00041 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 00042 * 00043 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 00044 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00045 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00046 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 00047 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00048 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00049 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00050 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00051 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00052 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00053 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 00054 * OF THE POSSIBILITY OF SUCH DAMAGE. 00055 * ==================================================================== 00056 * 00057 * This product includes cryptographic software written by Eric Young 00058 * (eay@cryptsoft.com). This product includes software written by Tim 00059 * Hudson (tjh@cryptsoft.com). 00060 * 00061 */ 00062 /* ==================================================================== 00063 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 00064 * 00065 * Portions of the attached software ("Contribution") are developed by 00066 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. 00067 * 00068 * The Contribution is licensed pursuant to the OpenSSL open source 00069 * license provided above. 00070 * 00071 * The elliptic curve binary polynomial software is originally written by 00072 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. 00073 * 00074 */ 00075 00076 #ifndef HEADER_EC_H 00077 # define HEADER_EC_H 00078 00079 # include <openssl/opensslconf.h> 00080 00081 # ifdef OPENSSL_NO_EC 00082 # error EC is disabled. 00083 # endif 00084 00085 # include <openssl/asn1.h> 00086 # include <openssl/symhacks.h> 00087 # ifndef OPENSSL_NO_DEPRECATED 00088 # include <openssl/bn.h> 00089 # endif 00090 00091 # ifdef __cplusplus 00092 extern "C" { 00093 # elif defined(__SUNPRO_C) 00094 # if __SUNPRO_C >= 0x520 00095 # pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) 00096 # endif 00097 # endif 00098 00099 # ifndef OPENSSL_ECC_MAX_FIELD_BITS 00100 # define OPENSSL_ECC_MAX_FIELD_BITS 661 00101 # endif 00102 00105 typedef enum { 00108 POINT_CONVERSION_COMPRESSED = 2, 00110 POINT_CONVERSION_UNCOMPRESSED = 4, 00113 POINT_CONVERSION_HYBRID = 6 00114 } point_conversion_form_t; 00115 00116 typedef struct ec_method_st EC_METHOD; 00117 00118 typedef struct ec_group_st 00119 /*- 00120 EC_METHOD *meth; 00121 -- field definition 00122 -- curve coefficients 00123 -- optional generator with associated information (order, cofactor) 00124 -- optional extra data (precomputed table for fast computation of multiples of generator) 00125 -- ASN1 stuff 00126 */ 00127 EC_GROUP; 00128 00129 typedef struct ec_point_st EC_POINT; 00130 00131 /********************************************************************/ 00132 /* EC_METHODs for curves over GF(p) */ 00133 /********************************************************************/ 00134 00139 const EC_METHOD *EC_GFp_simple_method(void); 00140 00144 const EC_METHOD *EC_GFp_mont_method(void); 00145 00149 const EC_METHOD *EC_GFp_nist_method(void); 00150 00151 # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 00152 00155 const EC_METHOD *EC_GFp_nistp224_method(void); 00156 00160 const EC_METHOD *EC_GFp_nistp256_method(void); 00161 00165 const EC_METHOD *EC_GFp_nistp521_method(void); 00166 # endif 00167 00168 # ifndef OPENSSL_NO_EC2M 00169 /********************************************************************/ 00170 /* EC_METHOD for curves over GF(2^m) */ 00171 /********************************************************************/ 00172 00176 const EC_METHOD *EC_GF2m_simple_method(void); 00177 00178 # endif 00179 00180 /********************************************************************/ 00181 /* EC_GROUP functions */ 00182 /********************************************************************/ 00183 00188 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); 00189 00193 void EC_GROUP_free(EC_GROUP *group); 00194 00198 void EC_GROUP_clear_free(EC_GROUP *group); 00199 00205 int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); 00206 00212 EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); 00213 00218 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); 00219 00224 int EC_METHOD_get_field_type(const EC_METHOD *meth); 00225 00234 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, 00235 const BIGNUM *order, const BIGNUM *cofactor); 00236 00241 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); 00242 00247 BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); 00248 00255 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); 00256 00263 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, 00264 BN_CTX *ctx); 00265 00270 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); 00271 00276 int EC_GROUP_get_curve_name(const EC_GROUP *group); 00277 00278 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); 00279 int EC_GROUP_get_asn1_flag(const EC_GROUP *group); 00280 00281 void EC_GROUP_set_point_conversion_form(EC_GROUP *group, 00282 point_conversion_form_t form); 00283 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); 00284 00285 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); 00286 size_t EC_GROUP_get_seed_len(const EC_GROUP *); 00287 size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); 00288 00297 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, 00298 const BIGNUM *b, BN_CTX *ctx); 00299 00308 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, 00309 BIGNUM *b, BN_CTX *ctx); 00310 00311 # ifndef OPENSSL_NO_EC2M 00312 00320 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, 00321 const BIGNUM *b, BN_CTX *ctx); 00322 00331 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, 00332 BIGNUM *b, BN_CTX *ctx); 00333 # endif 00334 00338 int EC_GROUP_get_degree(const EC_GROUP *group); 00339 00345 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); 00346 00352 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); 00353 00360 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); 00361 00362 /* 00363 * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after 00364 * choosing an appropriate EC_METHOD 00365 */ 00366 00375 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, 00376 const BIGNUM *b, BN_CTX *ctx); 00377 # ifndef OPENSSL_NO_EC2M 00378 00386 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, 00387 const BIGNUM *b, BN_CTX *ctx); 00388 # endif 00389 00394 EC_GROUP *EC_GROUP_new_by_curve_name(int nid); 00395 00396 /********************************************************************/ 00397 /* handling of internal curves */ 00398 /********************************************************************/ 00399 00400 typedef struct { 00401 int nid; 00402 const char *comment; 00403 } EC_builtin_curve; 00404 00405 /* 00406 * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all 00407 * available curves or zero if a error occurred. In case r ist not zero 00408 * nitems EC_builtin_curve structures are filled with the data of the first 00409 * nitems internal groups 00410 */ 00411 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); 00412 00413 const char *EC_curve_nid2nist(int nid); 00414 int EC_curve_nist2nid(const char *name); 00415 00416 /********************************************************************/ 00417 /* EC_POINT functions */ 00418 /********************************************************************/ 00419 00424 EC_POINT *EC_POINT_new(const EC_GROUP *group); 00425 00429 void EC_POINT_free(EC_POINT *point); 00430 00434 void EC_POINT_clear_free(EC_POINT *point); 00435 00441 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); 00442 00449 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); 00450 00455 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); 00456 00462 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); 00463 00473 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, 00474 EC_POINT *p, const BIGNUM *x, 00475 const BIGNUM *y, const BIGNUM *z, 00476 BN_CTX *ctx); 00477 00487 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, 00488 const EC_POINT *p, BIGNUM *x, 00489 BIGNUM *y, BIGNUM *z, 00490 BN_CTX *ctx); 00491 00500 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, 00501 const BIGNUM *x, const BIGNUM *y, 00502 BN_CTX *ctx); 00503 00512 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, 00513 const EC_POINT *p, BIGNUM *x, 00514 BIGNUM *y, BN_CTX *ctx); 00515 00524 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, 00525 EC_POINT *p, const BIGNUM *x, 00526 int y_bit, BN_CTX *ctx); 00527 # ifndef OPENSSL_NO_EC2M 00528 00536 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, 00537 const BIGNUM *x, const BIGNUM *y, 00538 BN_CTX *ctx); 00539 00548 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, 00549 const EC_POINT *p, BIGNUM *x, 00550 BIGNUM *y, BN_CTX *ctx); 00551 00560 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, 00561 EC_POINT *p, const BIGNUM *x, 00562 int y_bit, BN_CTX *ctx); 00563 # endif 00564 00574 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, 00575 point_conversion_form_t form, 00576 unsigned char *buf, size_t len, BN_CTX *ctx); 00577 00586 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, 00587 const unsigned char *buf, size_t len, BN_CTX *ctx); 00588 00589 /* other interfaces to point2oct/oct2point: */ 00590 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, 00591 point_conversion_form_t form, BIGNUM *, BN_CTX *); 00592 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, 00593 EC_POINT *, BN_CTX *); 00594 char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, 00595 point_conversion_form_t form, BN_CTX *); 00596 EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, 00597 EC_POINT *, BN_CTX *); 00598 00599 /********************************************************************/ 00600 /* functions for doing EC_POINT arithmetic */ 00601 /********************************************************************/ 00602 00611 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, 00612 const EC_POINT *b, BN_CTX *ctx); 00613 00621 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, 00622 BN_CTX *ctx); 00623 00630 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); 00631 00637 int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); 00638 00645 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, 00646 BN_CTX *ctx); 00647 00655 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, 00656 BN_CTX *ctx); 00657 00658 int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); 00659 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, 00660 EC_POINT *points[], BN_CTX *ctx); 00661 00672 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, 00673 size_t num, const EC_POINT *p[], const BIGNUM *m[], 00674 BN_CTX *ctx); 00675 00685 int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, 00686 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); 00687 00693 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); 00694 00699 int EC_GROUP_have_precompute_mult(const EC_GROUP *group); 00700 00701 /********************************************************************/ 00702 /* ASN1 stuff */ 00703 /********************************************************************/ 00704 00705 /* 00706 * EC_GROUP_get_basis_type() returns the NID of the basis type used to 00707 * represent the field elements 00708 */ 00709 int EC_GROUP_get_basis_type(const EC_GROUP *); 00710 # ifndef OPENSSL_NO_EC2M 00711 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); 00712 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 00713 unsigned int *k2, unsigned int *k3); 00714 # endif 00715 00716 # define OPENSSL_EC_NAMED_CURVE 0x001 00717 00718 typedef struct ecpk_parameters_st ECPKPARAMETERS; 00719 00720 EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); 00721 int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); 00722 00723 # define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) 00724 # define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) 00725 # define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ 00726 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) 00727 # define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ 00728 (unsigned char *)(x)) 00729 00730 # ifndef OPENSSL_NO_BIO 00731 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); 00732 # endif 00733 # ifndef OPENSSL_NO_FP_API 00734 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); 00735 # endif 00736 00737 /********************************************************************/ 00738 /* EC_KEY functions */ 00739 /********************************************************************/ 00740 00741 typedef struct ec_key_st EC_KEY; 00742 00743 /* some values for the encoding_flag */ 00744 # define EC_PKEY_NO_PARAMETERS 0x001 00745 # define EC_PKEY_NO_PUBKEY 0x002 00746 00747 /* some values for the flags field */ 00748 # define EC_FLAG_NON_FIPS_ALLOW 0x1 00749 # define EC_FLAG_FIPS_CHECKED 0x2 00750 00754 EC_KEY *EC_KEY_new(void); 00755 00756 int EC_KEY_get_flags(const EC_KEY *key); 00757 00758 void EC_KEY_set_flags(EC_KEY *key, int flags); 00759 00760 void EC_KEY_clear_flags(EC_KEY *key, int flags); 00761 00767 EC_KEY *EC_KEY_new_by_curve_name(int nid); 00768 00772 void EC_KEY_free(EC_KEY *key); 00773 00779 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); 00780 00785 EC_KEY *EC_KEY_dup(const EC_KEY *src); 00786 00791 int EC_KEY_up_ref(EC_KEY *key); 00792 00797 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); 00798 00805 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); 00806 00811 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); 00812 00819 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); 00820 00825 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); 00826 00833 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); 00834 00835 unsigned EC_KEY_get_enc_flags(const EC_KEY *key); 00836 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); 00837 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); 00838 void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); 00839 /* functions to set/get method specific data */ 00840 void *EC_KEY_get_key_method_data(EC_KEY *key, 00841 void *(*dup_func) (void *), 00842 void (*free_func) (void *), 00843 void (*clear_free_func) (void *)); 00852 void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data, 00853 void *(*dup_func) (void *), 00854 void (*free_func) (void *), 00855 void (*clear_free_func) (void *)); 00856 /* wrapper functions for the underlying EC_GROUP object */ 00857 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); 00858 00865 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); 00866 00871 int EC_KEY_generate_key(EC_KEY *key); 00872 00877 int EC_KEY_check_key(const EC_KEY *key); 00878 00886 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, 00887 BIGNUM *y); 00888 00889 /********************************************************************/ 00890 /* de- and encoding functions for SEC1 ECPrivateKey */ 00891 /********************************************************************/ 00892 00899 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); 00900 00907 int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); 00908 00909 /********************************************************************/ 00910 /* de- and encoding functions for EC parameters */ 00911 /********************************************************************/ 00912 00920 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); 00921 00928 int i2d_ECParameters(EC_KEY *key, unsigned char **out); 00929 00930 /********************************************************************/ 00931 /* de- and encoding functions for EC public key */ 00932 /* (octet string, not DER -- hence 'o2i' and 'i2o') */ 00933 /********************************************************************/ 00934 00942 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); 00943 00950 int i2o_ECPublicKey(EC_KEY *key, unsigned char **out); 00951 00952 # ifndef OPENSSL_NO_BIO 00953 00958 int ECParameters_print(BIO *bp, const EC_KEY *key); 00959 00966 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); 00967 00968 # endif 00969 # ifndef OPENSSL_NO_FP_API 00970 00975 int ECParameters_print_fp(FILE *fp, const EC_KEY *key); 00976 00983 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); 00984 00985 # endif 00986 00987 # define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) 00988 00989 # ifndef __cplusplus 00990 # if defined(__SUNPRO_C) 00991 # if __SUNPRO_C >= 0x520 00992 # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) 00993 # endif 00994 # endif 00995 # endif 00996 00997 # define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ 00998 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 00999 EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ 01000 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) 01001 01002 # define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \ 01003 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01004 EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ 01005 EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL) 01006 01007 # define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \ 01008 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01009 EVP_PKEY_OP_DERIVE, \ 01010 EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL) 01011 01012 # define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \ 01013 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01014 EVP_PKEY_OP_DERIVE, \ 01015 EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL) 01016 01017 # define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \ 01018 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01019 EVP_PKEY_OP_DERIVE, \ 01020 EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL) 01021 01022 # define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \ 01023 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01024 EVP_PKEY_OP_DERIVE, \ 01025 EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL) 01026 01027 # define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \ 01028 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01029 EVP_PKEY_OP_DERIVE, \ 01030 EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md) 01031 01032 # define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \ 01033 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01034 EVP_PKEY_OP_DERIVE, \ 01035 EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd) 01036 01037 # define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \ 01038 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01039 EVP_PKEY_OP_DERIVE, \ 01040 EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL) 01041 01042 # define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \ 01043 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01044 EVP_PKEY_OP_DERIVE, \ 01045 EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen) 01046 01047 # define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \ 01048 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01049 EVP_PKEY_OP_DERIVE, \ 01050 EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p) 01051 01052 # define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \ 01053 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 01054 EVP_PKEY_OP_DERIVE, \ 01055 EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p) 01056 01057 # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) 01058 # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) 01059 # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) 01060 # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) 01061 # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) 01062 # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) 01063 # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) 01064 # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) 01065 # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) 01066 # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) 01067 /* KDF types */ 01068 # define EVP_PKEY_ECDH_KDF_NONE 1 01069 # define EVP_PKEY_ECDH_KDF_X9_62 2 01070 01071 /* BEGIN ERROR CODES */ 01072 /* 01073 * The following lines are auto generated by the script mkerr.pl. Any changes 01074 * made after this point may be overwritten when the script is next run. 01075 */ 01076 void ERR_load_EC_strings(void); 01077 01078 /* Error codes for the EC functions. */ 01079 01080 /* Function codes. */ 01081 # define EC_F_BN_TO_FELEM 224 01082 # define EC_F_COMPUTE_WNAF 143 01083 # define EC_F_D2I_ECPARAMETERS 144 01084 # define EC_F_D2I_ECPKPARAMETERS 145 01085 # define EC_F_D2I_ECPRIVATEKEY 146 01086 # define EC_F_DO_EC_KEY_PRINT 221 01087 # define EC_F_ECDH_CMS_DECRYPT 238 01088 # define EC_F_ECDH_CMS_SET_SHARED_INFO 239 01089 # define EC_F_ECKEY_PARAM2TYPE 223 01090 # define EC_F_ECKEY_PARAM_DECODE 212 01091 # define EC_F_ECKEY_PRIV_DECODE 213 01092 # define EC_F_ECKEY_PRIV_ENCODE 214 01093 # define EC_F_ECKEY_PUB_DECODE 215 01094 # define EC_F_ECKEY_PUB_ENCODE 216 01095 # define EC_F_ECKEY_TYPE2PARAM 220 01096 # define EC_F_ECPARAMETERS_PRINT 147 01097 # define EC_F_ECPARAMETERS_PRINT_FP 148 01098 # define EC_F_ECPKPARAMETERS_PRINT 149 01099 # define EC_F_ECPKPARAMETERS_PRINT_FP 150 01100 # define EC_F_ECP_NISTZ256_GET_AFFINE 240 01101 # define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243 01102 # define EC_F_ECP_NISTZ256_POINTS_MUL 241 01103 # define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244 01104 # define EC_F_ECP_NISTZ256_SET_WORDS 245 01105 # define EC_F_ECP_NISTZ256_WINDOWED_MUL 242 01106 # define EC_F_ECP_NIST_MOD_192 203 01107 # define EC_F_ECP_NIST_MOD_224 204 01108 # define EC_F_ECP_NIST_MOD_256 205 01109 # define EC_F_ECP_NIST_MOD_521 206 01110 # define EC_F_EC_ASN1_GROUP2CURVE 153 01111 # define EC_F_EC_ASN1_GROUP2FIELDID 154 01112 # define EC_F_EC_ASN1_GROUP2PARAMETERS 155 01113 # define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 01114 # define EC_F_EC_ASN1_PARAMETERS2GROUP 157 01115 # define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 01116 # define EC_F_EC_EX_DATA_SET_DATA 211 01117 # define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 01118 # define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 01119 # define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 01120 # define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 01121 # define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 01122 # define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 01123 # define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 01124 # define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 01125 # define EC_F_EC_GFP_MONT_FIELD_DECODE 133 01126 # define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 01127 # define EC_F_EC_GFP_MONT_FIELD_MUL 131 01128 # define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 01129 # define EC_F_EC_GFP_MONT_FIELD_SQR 132 01130 # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 01131 # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 01132 # define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225 01133 # define EC_F_EC_GFP_NISTP224_POINTS_MUL 228 01134 # define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226 01135 # define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230 01136 # define EC_F_EC_GFP_NISTP256_POINTS_MUL 231 01137 # define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232 01138 # define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233 01139 # define EC_F_EC_GFP_NISTP521_POINTS_MUL 234 01140 # define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235 01141 # define EC_F_EC_GFP_NIST_FIELD_MUL 200 01142 # define EC_F_EC_GFP_NIST_FIELD_SQR 201 01143 # define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 01144 # define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 01145 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 01146 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 01147 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 01148 # define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 01149 # define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 01150 # define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 01151 # define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 01152 # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 01153 # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 01154 # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 01155 # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 01156 # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 01157 # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 01158 # define EC_F_EC_GROUP_CHECK 170 01159 # define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 01160 # define EC_F_EC_GROUP_COPY 106 01161 # define EC_F_EC_GROUP_GET0_GENERATOR 139 01162 # define EC_F_EC_GROUP_GET_COFACTOR 140 01163 # define EC_F_EC_GROUP_GET_CURVE_GF2M 172 01164 # define EC_F_EC_GROUP_GET_CURVE_GFP 130 01165 # define EC_F_EC_GROUP_GET_DEGREE 173 01166 # define EC_F_EC_GROUP_GET_ORDER 141 01167 # define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 01168 # define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 01169 # define EC_F_EC_GROUP_NEW 108 01170 # define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 01171 # define EC_F_EC_GROUP_NEW_FROM_DATA 175 01172 # define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 01173 # define EC_F_EC_GROUP_SET_CURVE_GF2M 176 01174 # define EC_F_EC_GROUP_SET_CURVE_GFP 109 01175 # define EC_F_EC_GROUP_SET_EXTRA_DATA 110 01176 # define EC_F_EC_GROUP_SET_GENERATOR 111 01177 # define EC_F_EC_KEY_CHECK_KEY 177 01178 # define EC_F_EC_KEY_COPY 178 01179 # define EC_F_EC_KEY_GENERATE_KEY 179 01180 # define EC_F_EC_KEY_NEW 182 01181 # define EC_F_EC_KEY_PRINT 180 01182 # define EC_F_EC_KEY_PRINT_FP 181 01183 # define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229 01184 # define EC_F_EC_POINTS_MAKE_AFFINE 136 01185 # define EC_F_EC_POINT_ADD 112 01186 # define EC_F_EC_POINT_CMP 113 01187 # define EC_F_EC_POINT_COPY 114 01188 # define EC_F_EC_POINT_DBL 115 01189 # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 01190 # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 01191 # define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 01192 # define EC_F_EC_POINT_INVERT 210 01193 # define EC_F_EC_POINT_IS_AT_INFINITY 118 01194 # define EC_F_EC_POINT_IS_ON_CURVE 119 01195 # define EC_F_EC_POINT_MAKE_AFFINE 120 01196 # define EC_F_EC_POINT_MUL 184 01197 # define EC_F_EC_POINT_NEW 121 01198 # define EC_F_EC_POINT_OCT2POINT 122 01199 # define EC_F_EC_POINT_POINT2OCT 123 01200 # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 01201 # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 01202 # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 01203 # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 01204 # define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 01205 # define EC_F_EC_POINT_SET_TO_INFINITY 127 01206 # define EC_F_EC_PRE_COMP_DUP 207 01207 # define EC_F_EC_PRE_COMP_NEW 196 01208 # define EC_F_EC_WNAF_MUL 187 01209 # define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 01210 # define EC_F_I2D_ECPARAMETERS 190 01211 # define EC_F_I2D_ECPKPARAMETERS 191 01212 # define EC_F_I2D_ECPRIVATEKEY 192 01213 # define EC_F_I2O_ECPUBLICKEY 151 01214 # define EC_F_NISTP224_PRE_COMP_NEW 227 01215 # define EC_F_NISTP256_PRE_COMP_NEW 236 01216 # define EC_F_NISTP521_PRE_COMP_NEW 237 01217 # define EC_F_O2I_ECPUBLICKEY 152 01218 # define EC_F_OLD_EC_PRIV_DECODE 222 01219 # define EC_F_PKEY_EC_CTRL 197 01220 # define EC_F_PKEY_EC_CTRL_STR 198 01221 # define EC_F_PKEY_EC_DERIVE 217 01222 # define EC_F_PKEY_EC_KEYGEN 199 01223 # define EC_F_PKEY_EC_PARAMGEN 219 01224 # define EC_F_PKEY_EC_SIGN 218 01225 01226 /* Reason codes. */ 01227 # define EC_R_ASN1_ERROR 115 01228 # define EC_R_ASN1_UNKNOWN_FIELD 116 01229 # define EC_R_BIGNUM_OUT_OF_RANGE 144 01230 # define EC_R_BUFFER_TOO_SMALL 100 01231 # define EC_R_COORDINATES_OUT_OF_RANGE 146 01232 # define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 01233 # define EC_R_DECODE_ERROR 142 01234 # define EC_R_DISCRIMINANT_IS_ZERO 118 01235 # define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 01236 # define EC_R_FIELD_TOO_LARGE 143 01237 # define EC_R_GF2M_NOT_SUPPORTED 147 01238 # define EC_R_GROUP2PKPARAMETERS_FAILURE 120 01239 # define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 01240 # define EC_R_INCOMPATIBLE_OBJECTS 101 01241 # define EC_R_INVALID_ARGUMENT 112 01242 # define EC_R_INVALID_COMPRESSED_POINT 110 01243 # define EC_R_INVALID_COMPRESSION_BIT 109 01244 # define EC_R_INVALID_CURVE 141 01245 # define EC_R_INVALID_DIGEST 151 01246 # define EC_R_INVALID_DIGEST_TYPE 138 01247 # define EC_R_INVALID_ENCODING 102 01248 # define EC_R_INVALID_FIELD 103 01249 # define EC_R_INVALID_FORM 104 01250 # define EC_R_INVALID_GROUP_ORDER 122 01251 # define EC_R_INVALID_PENTANOMIAL_BASIS 132 01252 # define EC_R_INVALID_PRIVATE_KEY 123 01253 # define EC_R_INVALID_TRINOMIAL_BASIS 137 01254 # define EC_R_KDF_PARAMETER_ERROR 148 01255 # define EC_R_KEYS_NOT_SET 140 01256 # define EC_R_MISSING_PARAMETERS 124 01257 # define EC_R_MISSING_PRIVATE_KEY 125 01258 # define EC_R_NOT_A_NIST_PRIME 135 01259 # define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 01260 # define EC_R_NOT_IMPLEMENTED 126 01261 # define EC_R_NOT_INITIALIZED 111 01262 # define EC_R_NO_FIELD_MOD 133 01263 # define EC_R_NO_PARAMETERS_SET 139 01264 # define EC_R_PASSED_NULL_PARAMETER 134 01265 # define EC_R_PEER_KEY_ERROR 149 01266 # define EC_R_PKPARAMETERS2GROUP_FAILURE 127 01267 # define EC_R_POINT_AT_INFINITY 106 01268 # define EC_R_POINT_IS_NOT_ON_CURVE 107 01269 # define EC_R_SHARED_INFO_ERROR 150 01270 # define EC_R_SLOT_FULL 108 01271 # define EC_R_UNDEFINED_GENERATOR 113 01272 # define EC_R_UNDEFINED_ORDER 128 01273 # define EC_R_UNKNOWN_GROUP 129 01274 # define EC_R_UNKNOWN_ORDER 114 01275 # define EC_R_UNSUPPORTED_FIELD 131 01276 # define EC_R_WRONG_CURVE_PARAMETERS 145 01277 # define EC_R_WRONG_ORDER 130 01278 01279 #ifdef __cplusplus 01280 } 01281 #endif 01282 #endif