diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec.h')
-rw-r--r-- | src/lib/libcrypto/ec/ec.h | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h index ee7078130c..9d01325af3 100644 --- a/src/lib/libcrypto/ec/ec.h +++ b/src/lib/libcrypto/ec/ec.h | |||
@@ -151,7 +151,24 @@ const EC_METHOD *EC_GFp_mont_method(void); | |||
151 | */ | 151 | */ |
152 | const EC_METHOD *EC_GFp_nist_method(void); | 152 | const EC_METHOD *EC_GFp_nist_method(void); |
153 | 153 | ||
154 | #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 | ||
155 | /** Returns 64-bit optimized methods for nistp224 | ||
156 | * \return EC_METHOD object | ||
157 | */ | ||
158 | const EC_METHOD *EC_GFp_nistp224_method(void); | ||
159 | |||
160 | /** Returns 64-bit optimized methods for nistp256 | ||
161 | * \return EC_METHOD object | ||
162 | */ | ||
163 | const EC_METHOD *EC_GFp_nistp256_method(void); | ||
164 | |||
165 | /** Returns 64-bit optimized methods for nistp521 | ||
166 | * \return EC_METHOD object | ||
167 | */ | ||
168 | const EC_METHOD *EC_GFp_nistp521_method(void); | ||
169 | #endif | ||
154 | 170 | ||
171 | #ifndef OPENSSL_NO_EC2M | ||
155 | /********************************************************************/ | 172 | /********************************************************************/ |
156 | /* EC_METHOD for curves over GF(2^m) */ | 173 | /* EC_METHOD for curves over GF(2^m) */ |
157 | /********************************************************************/ | 174 | /********************************************************************/ |
@@ -161,6 +178,8 @@ const EC_METHOD *EC_GFp_nist_method(void); | |||
161 | */ | 178 | */ |
162 | const EC_METHOD *EC_GF2m_simple_method(void); | 179 | const EC_METHOD *EC_GF2m_simple_method(void); |
163 | 180 | ||
181 | #endif | ||
182 | |||
164 | 183 | ||
165 | /********************************************************************/ | 184 | /********************************************************************/ |
166 | /* EC_GROUP functions */ | 185 | /* EC_GROUP functions */ |
@@ -282,6 +301,7 @@ int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, co | |||
282 | */ | 301 | */ |
283 | int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | 302 | int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); |
284 | 303 | ||
304 | #ifndef OPENSSL_NO_EC2M | ||
285 | /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b | 305 | /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b |
286 | * \param group EC_GROUP object | 306 | * \param group EC_GROUP object |
287 | * \param p BIGNUM with the polynomial defining the underlying field | 307 | * \param p BIGNUM with the polynomial defining the underlying field |
@@ -301,7 +321,7 @@ int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, c | |||
301 | * \return 1 on success and 0 if an error occured | 321 | * \return 1 on success and 0 if an error occured |
302 | */ | 322 | */ |
303 | int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | 323 | int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); |
304 | 324 | #endif | |
305 | /** Returns the number of bits needed to represent a field element | 325 | /** Returns the number of bits needed to represent a field element |
306 | * \param group EC_GROUP object | 326 | * \param group EC_GROUP object |
307 | * \return number of bits needed to represent a field element | 327 | * \return number of bits needed to represent a field element |
@@ -342,7 +362,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); | |||
342 | * \return newly created EC_GROUP object with the specified parameters | 362 | * \return newly created EC_GROUP object with the specified parameters |
343 | */ | 363 | */ |
344 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | 364 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); |
345 | 365 | #ifndef OPENSSL_NO_EC2M | |
346 | /** Creates a new EC_GROUP object with the specified parameters defined | 366 | /** Creates a new EC_GROUP object with the specified parameters defined |
347 | * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) | 367 | * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) |
348 | * \param p BIGNUM with the polynomial defining the underlying field | 368 | * \param p BIGNUM with the polynomial defining the underlying field |
@@ -352,7 +372,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM | |||
352 | * \return newly created EC_GROUP object with the specified parameters | 372 | * \return newly created EC_GROUP object with the specified parameters |
353 | */ | 373 | */ |
354 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | 374 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); |
355 | 375 | #endif | |
356 | /** Creates a EC_GROUP object with a curve specified by a NID | 376 | /** Creates a EC_GROUP object with a curve specified by a NID |
357 | * \param nid NID of the OID of the curve name | 377 | * \param nid NID of the OID of the curve name |
358 | * \return newly created EC_GROUP object with specified curve or NULL | 378 | * \return newly created EC_GROUP object with specified curve or NULL |
@@ -481,7 +501,7 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, | |||
481 | */ | 501 | */ |
482 | int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, | 502 | int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, |
483 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | 503 | const BIGNUM *x, int y_bit, BN_CTX *ctx); |
484 | 504 | #ifndef OPENSSL_NO_EC2M | |
485 | /** Sets the affine coordinates of a EC_POINT over GF2m | 505 | /** Sets the affine coordinates of a EC_POINT over GF2m |
486 | * \param group underlying EC_GROUP object | 506 | * \param group underlying EC_GROUP object |
487 | * \param p EC_POINT object | 507 | * \param p EC_POINT object |
@@ -514,7 +534,7 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, | |||
514 | */ | 534 | */ |
515 | int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, | 535 | int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, |
516 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | 536 | const BIGNUM *x, int y_bit, BN_CTX *ctx); |
517 | 537 | #endif | |
518 | /** Encodes a EC_POINT object to a octet string | 538 | /** Encodes a EC_POINT object to a octet string |
519 | * \param group underlying EC_GROUP object | 539 | * \param group underlying EC_GROUP object |
520 | * \param p EC_POINT object | 540 | * \param p EC_POINT object |
@@ -653,9 +673,11 @@ int EC_GROUP_have_precompute_mult(const EC_GROUP *group); | |||
653 | /* EC_GROUP_get_basis_type() returns the NID of the basis type | 673 | /* EC_GROUP_get_basis_type() returns the NID of the basis type |
654 | * used to represent the field elements */ | 674 | * used to represent the field elements */ |
655 | int EC_GROUP_get_basis_type(const EC_GROUP *); | 675 | int EC_GROUP_get_basis_type(const EC_GROUP *); |
676 | #ifndef OPENSSL_NO_EC2M | ||
656 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); | 677 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); |
657 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, | 678 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, |
658 | unsigned int *k2, unsigned int *k3); | 679 | unsigned int *k2, unsigned int *k3); |
680 | #endif | ||
659 | 681 | ||
660 | #define OPENSSL_EC_NAMED_CURVE 0x001 | 682 | #define OPENSSL_EC_NAMED_CURVE 0x001 |
661 | 683 | ||
@@ -689,11 +711,21 @@ typedef struct ec_key_st EC_KEY; | |||
689 | #define EC_PKEY_NO_PARAMETERS 0x001 | 711 | #define EC_PKEY_NO_PARAMETERS 0x001 |
690 | #define EC_PKEY_NO_PUBKEY 0x002 | 712 | #define EC_PKEY_NO_PUBKEY 0x002 |
691 | 713 | ||
714 | /* some values for the flags field */ | ||
715 | #define EC_FLAG_NON_FIPS_ALLOW 0x1 | ||
716 | #define EC_FLAG_FIPS_CHECKED 0x2 | ||
717 | |||
692 | /** Creates a new EC_KEY object. | 718 | /** Creates a new EC_KEY object. |
693 | * \return EC_KEY object or NULL if an error occurred. | 719 | * \return EC_KEY object or NULL if an error occurred. |
694 | */ | 720 | */ |
695 | EC_KEY *EC_KEY_new(void); | 721 | EC_KEY *EC_KEY_new(void); |
696 | 722 | ||
723 | int EC_KEY_get_flags(const EC_KEY *key); | ||
724 | |||
725 | void EC_KEY_set_flags(EC_KEY *key, int flags); | ||
726 | |||
727 | void EC_KEY_clear_flags(EC_KEY *key, int flags); | ||
728 | |||
697 | /** Creates a new EC_KEY object using a named curve as underlying | 729 | /** Creates a new EC_KEY object using a named curve as underlying |
698 | * EC_GROUP object. | 730 | * EC_GROUP object. |
699 | * \param nid NID of the named curve. | 731 | * \param nid NID of the named curve. |
@@ -799,6 +831,15 @@ int EC_KEY_generate_key(EC_KEY *key); | |||
799 | */ | 831 | */ |
800 | int EC_KEY_check_key(const EC_KEY *key); | 832 | int EC_KEY_check_key(const EC_KEY *key); |
801 | 833 | ||
834 | /** Sets a public key from affine coordindates performing | ||
835 | * neccessary NIST PKV tests. | ||
836 | * \param key the EC_KEY object | ||
837 | * \param x public key x coordinate | ||
838 | * \param y public key y coordinate | ||
839 | * \return 1 on success and 0 otherwise. | ||
840 | */ | ||
841 | int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y); | ||
842 | |||
802 | 843 | ||
803 | /********************************************************************/ | 844 | /********************************************************************/ |
804 | /* de- and encoding functions for SEC1 ECPrivateKey */ | 845 | /* de- and encoding functions for SEC1 ECPrivateKey */ |
@@ -926,6 +967,7 @@ void ERR_load_EC_strings(void); | |||
926 | /* Error codes for the EC functions. */ | 967 | /* Error codes for the EC functions. */ |
927 | 968 | ||
928 | /* Function codes. */ | 969 | /* Function codes. */ |
970 | #define EC_F_BN_TO_FELEM 224 | ||
929 | #define EC_F_COMPUTE_WNAF 143 | 971 | #define EC_F_COMPUTE_WNAF 143 |
930 | #define EC_F_D2I_ECPARAMETERS 144 | 972 | #define EC_F_D2I_ECPARAMETERS 144 |
931 | #define EC_F_D2I_ECPKPARAMETERS 145 | 973 | #define EC_F_D2I_ECPKPARAMETERS 145 |
@@ -968,6 +1010,15 @@ void ERR_load_EC_strings(void); | |||
968 | #define EC_F_EC_GFP_MONT_FIELD_SQR 132 | 1010 | #define EC_F_EC_GFP_MONT_FIELD_SQR 132 |
969 | #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 | 1011 | #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 |
970 | #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 | 1012 | #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 |
1013 | #define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225 | ||
1014 | #define EC_F_EC_GFP_NISTP224_POINTS_MUL 228 | ||
1015 | #define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226 | ||
1016 | #define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230 | ||
1017 | #define EC_F_EC_GFP_NISTP256_POINTS_MUL 231 | ||
1018 | #define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232 | ||
1019 | #define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233 | ||
1020 | #define EC_F_EC_GFP_NISTP521_POINTS_MUL 234 | ||
1021 | #define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235 | ||
971 | #define EC_F_EC_GFP_NIST_FIELD_MUL 200 | 1022 | #define EC_F_EC_GFP_NIST_FIELD_MUL 200 |
972 | #define EC_F_EC_GFP_NIST_FIELD_SQR 201 | 1023 | #define EC_F_EC_GFP_NIST_FIELD_SQR 201 |
973 | #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 | 1024 | #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 |
@@ -1010,6 +1061,7 @@ void ERR_load_EC_strings(void); | |||
1010 | #define EC_F_EC_KEY_NEW 182 | 1061 | #define EC_F_EC_KEY_NEW 182 |
1011 | #define EC_F_EC_KEY_PRINT 180 | 1062 | #define EC_F_EC_KEY_PRINT 180 |
1012 | #define EC_F_EC_KEY_PRINT_FP 181 | 1063 | #define EC_F_EC_KEY_PRINT_FP 181 |
1064 | #define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229 | ||
1013 | #define EC_F_EC_POINTS_MAKE_AFFINE 136 | 1065 | #define EC_F_EC_POINTS_MAKE_AFFINE 136 |
1014 | #define EC_F_EC_POINT_ADD 112 | 1066 | #define EC_F_EC_POINT_ADD 112 |
1015 | #define EC_F_EC_POINT_CMP 113 | 1067 | #define EC_F_EC_POINT_CMP 113 |
@@ -1040,6 +1092,9 @@ void ERR_load_EC_strings(void); | |||
1040 | #define EC_F_I2D_ECPKPARAMETERS 191 | 1092 | #define EC_F_I2D_ECPKPARAMETERS 191 |
1041 | #define EC_F_I2D_ECPRIVATEKEY 192 | 1093 | #define EC_F_I2D_ECPRIVATEKEY 192 |
1042 | #define EC_F_I2O_ECPUBLICKEY 151 | 1094 | #define EC_F_I2O_ECPUBLICKEY 151 |
1095 | #define EC_F_NISTP224_PRE_COMP_NEW 227 | ||
1096 | #define EC_F_NISTP256_PRE_COMP_NEW 236 | ||
1097 | #define EC_F_NISTP521_PRE_COMP_NEW 237 | ||
1043 | #define EC_F_O2I_ECPUBLICKEY 152 | 1098 | #define EC_F_O2I_ECPUBLICKEY 152 |
1044 | #define EC_F_OLD_EC_PRIV_DECODE 222 | 1099 | #define EC_F_OLD_EC_PRIV_DECODE 222 |
1045 | #define EC_F_PKEY_EC_CTRL 197 | 1100 | #define EC_F_PKEY_EC_CTRL 197 |
@@ -1052,12 +1107,15 @@ void ERR_load_EC_strings(void); | |||
1052 | /* Reason codes. */ | 1107 | /* Reason codes. */ |
1053 | #define EC_R_ASN1_ERROR 115 | 1108 | #define EC_R_ASN1_ERROR 115 |
1054 | #define EC_R_ASN1_UNKNOWN_FIELD 116 | 1109 | #define EC_R_ASN1_UNKNOWN_FIELD 116 |
1110 | #define EC_R_BIGNUM_OUT_OF_RANGE 144 | ||
1055 | #define EC_R_BUFFER_TOO_SMALL 100 | 1111 | #define EC_R_BUFFER_TOO_SMALL 100 |
1112 | #define EC_R_COORDINATES_OUT_OF_RANGE 146 | ||
1056 | #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 | 1113 | #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 |
1057 | #define EC_R_DECODE_ERROR 142 | 1114 | #define EC_R_DECODE_ERROR 142 |
1058 | #define EC_R_DISCRIMINANT_IS_ZERO 118 | 1115 | #define EC_R_DISCRIMINANT_IS_ZERO 118 |
1059 | #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 | 1116 | #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 |
1060 | #define EC_R_FIELD_TOO_LARGE 143 | 1117 | #define EC_R_FIELD_TOO_LARGE 143 |
1118 | #define EC_R_GF2M_NOT_SUPPORTED 147 | ||
1061 | #define EC_R_GROUP2PKPARAMETERS_FAILURE 120 | 1119 | #define EC_R_GROUP2PKPARAMETERS_FAILURE 120 |
1062 | #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 | 1120 | #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 |
1063 | #define EC_R_INCOMPATIBLE_OBJECTS 101 | 1121 | #define EC_R_INCOMPATIBLE_OBJECTS 101 |
@@ -1092,6 +1150,7 @@ void ERR_load_EC_strings(void); | |||
1092 | #define EC_R_UNKNOWN_GROUP 129 | 1150 | #define EC_R_UNKNOWN_GROUP 129 |
1093 | #define EC_R_UNKNOWN_ORDER 114 | 1151 | #define EC_R_UNKNOWN_ORDER 114 |
1094 | #define EC_R_UNSUPPORTED_FIELD 131 | 1152 | #define EC_R_UNSUPPORTED_FIELD 131 |
1153 | #define EC_R_WRONG_CURVE_PARAMETERS 145 | ||
1095 | #define EC_R_WRONG_ORDER 130 | 1154 | #define EC_R_WRONG_ORDER 130 |
1096 | 1155 | ||
1097 | #ifdef __cplusplus | 1156 | #ifdef __cplusplus |