* Configure, crypto/ec/ec.h, crypto/ec/ecp_nistp224.c, util/mkdef.pl:
[openssl.git] / crypto / ec / ec.h
index ee7078130c5c3ae1c73d8b76e9f73a2fee40632a..69d78642ccbc8b657a8a82d5f65efdc93bb25a04 100644 (file)
@@ -151,7 +151,16 @@ const EC_METHOD *EC_GFp_mont_method(void);
  */
 const EC_METHOD *EC_GFp_nist_method(void);
 
+#ifndef OPENSSL_NO_EC_NISTP224_64_GCC_128
+/** Returns 64-bit optimized methods for nistp224
+ *  \return  EC_METHOD object
+ */
+#ifndef OPENSSL_SYS_WIN32
+const EC_METHOD *EC_GFp_nistp224_method(void);
+#endif
+#endif
 
+#ifndef OPENSSL_NO_EC2M
 /********************************************************************/ 
 /*           EC_METHOD for curves over GF(2^m)                      */
 /********************************************************************/
@@ -161,6 +170,8 @@ const EC_METHOD *EC_GFp_nist_method(void);
  */
 const EC_METHOD *EC_GF2m_simple_method(void);
 
+#endif
+
 
 /********************************************************************/
 /*                   EC_GROUP functions                             */
@@ -282,6 +293,7 @@ int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, co
  */
 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
 
+#ifndef OPENSSL_NO_EC2M
 /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  *  \param  group  EC_GROUP object
  *  \param  p      BIGNUM with the polynomial defining the underlying field
@@ -301,7 +313,7 @@ int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, c
  *  \return 1 on success and 0 if an error occured
  */
 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
-
+#endif
 /** Returns the number of bits needed to represent a field element 
  *  \param  group  EC_GROUP object
  *  \return number of bits needed to represent a field element
@@ -342,7 +354,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
  *  \return newly created EC_GROUP object with the specified parameters
  */
 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
-
+#ifndef OPENSSL_NO_EC2M
 /** Creates a new EC_GROUP object with the specified parameters defined
  *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
  *  \param  p    BIGNUM with the polynomial defining the underlying field
@@ -352,7 +364,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM
  *  \return newly created EC_GROUP object with the specified parameters
  */
 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
-
+#endif
 /** Creates a EC_GROUP object with a curve specified by a NID
  *  \param  nid  NID of the OID of the curve name
  *  \return newly created EC_GROUP object with specified curve or NULL
@@ -481,7 +493,7 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
  */
 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
        const BIGNUM *x, int y_bit, BN_CTX *ctx);
-
+#ifndef OPENSSL_NO_EC2M
 /** Sets the affine coordinates of a EC_POINT over GF2m
  *  \param  group  underlying EC_GROUP object
  *  \param  p      EC_POINT object
@@ -514,7 +526,7 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
  */
 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
        const BIGNUM *x, int y_bit, BN_CTX *ctx);
-
+#endif
 /** Encodes a EC_POINT object to a octet string
  *  \param  group  underlying EC_GROUP object
  *  \param  p      EC_POINT object
@@ -653,9 +665,11 @@ int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
 /* EC_GROUP_get_basis_type() returns the NID of the basis type
  * used to represent the field elements */
 int EC_GROUP_get_basis_type(const EC_GROUP *);
+#ifndef OPENSSL_NO_EC2M
 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 
        unsigned int *k2, unsigned int *k3);
+#endif
 
 #define OPENSSL_EC_NAMED_CURVE 0x001
 
@@ -799,6 +813,15 @@ int EC_KEY_generate_key(EC_KEY *key);
  */
 int EC_KEY_check_key(const EC_KEY *key);
 
+/** Sets a public key from affine coordindates performing
+ *  neccessary NIST PKV tests.
+ *  \param  key  the EC_KEY object
+ *  \param  x    public key x coordinate
+ *  \param  y    public key y coordinate
+ *  \return 1 on success and 0 otherwise.
+ */
+int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
+
 
 /********************************************************************/
 /*        de- and encoding functions for SEC1 ECPrivateKey          */
@@ -926,6 +949,7 @@ void ERR_load_EC_strings(void);
 /* Error codes for the EC functions. */
 
 /* Function codes. */
+#define EC_F_BN_TO_FELEM                                224
 #define EC_F_COMPUTE_WNAF                               143
 #define EC_F_D2I_ECPARAMETERS                           144
 #define EC_F_D2I_ECPKPARAMETERS                                 145
@@ -968,6 +992,9 @@ void ERR_load_EC_strings(void);
 #define EC_F_EC_GFP_MONT_FIELD_SQR                      132
 #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE                189
 #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP            135
+#define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE            225
+#define EC_F_EC_GFP_NISTP224_POINTS_MUL                         228
+#define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
 #define EC_F_EC_GFP_NIST_FIELD_MUL                      200
 #define EC_F_EC_GFP_NIST_FIELD_SQR                      201
 #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE                202
@@ -1010,6 +1037,7 @@ void ERR_load_EC_strings(void);
 #define EC_F_EC_KEY_NEW                                         182
 #define EC_F_EC_KEY_PRINT                               180
 #define EC_F_EC_KEY_PRINT_FP                            181
+#define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES   229
 #define EC_F_EC_POINTS_MAKE_AFFINE                      136
 #define EC_F_EC_POINT_ADD                               112
 #define EC_F_EC_POINT_CMP                               113
@@ -1040,6 +1068,7 @@ void ERR_load_EC_strings(void);
 #define EC_F_I2D_ECPKPARAMETERS                                 191
 #define EC_F_I2D_ECPRIVATEKEY                           192
 #define EC_F_I2O_ECPUBLICKEY                            151
+#define EC_F_NISTP224_PRE_COMP_NEW                      227
 #define EC_F_O2I_ECPUBLICKEY                            152
 #define EC_F_OLD_EC_PRIV_DECODE                                 222
 #define EC_F_PKEY_EC_CTRL                               197
@@ -1052,12 +1081,15 @@ void ERR_load_EC_strings(void);
 /* Reason codes. */
 #define EC_R_ASN1_ERROR                                         115
 #define EC_R_ASN1_UNKNOWN_FIELD                                 116
+#define EC_R_BIGNUM_OUT_OF_RANGE                        144
 #define EC_R_BUFFER_TOO_SMALL                           100
+#define EC_R_COORDINATES_OUT_OF_RANGE                   146
 #define EC_R_D2I_ECPKPARAMETERS_FAILURE                         117
 #define EC_R_DECODE_ERROR                               142
 #define EC_R_DISCRIMINANT_IS_ZERO                       118
 #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE               119
 #define EC_R_FIELD_TOO_LARGE                            143
+#define EC_R_GF2M_NOT_SUPPORTED                                 147
 #define EC_R_GROUP2PKPARAMETERS_FAILURE                         120
 #define EC_R_I2D_ECPKPARAMETERS_FAILURE                         121
 #define EC_R_INCOMPATIBLE_OBJECTS                       101
@@ -1092,6 +1124,7 @@ void ERR_load_EC_strings(void);
 #define EC_R_UNKNOWN_GROUP                              129
 #define EC_R_UNKNOWN_ORDER                              114
 #define EC_R_UNSUPPORTED_FIELD                          131
+#define EC_R_WRONG_CURVE_PARAMETERS                     145
 #define EC_R_WRONG_ORDER                                130
 
 #ifdef  __cplusplus