Commit b3310161 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

New option to disable characteristic two fields in EC code.

parent afb41913
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@

 Changes between 1.0.1 and 1.1.0  [xx XXX xxxx]

  *) New build option no-ec2m to disable characteristic 2 code.
     [Steve Henson]

  *) New build option "fipscanisteronly". This only builds fipscanister.o
     and (currently) associated fips utilities. Uses the file Makefile.fips
     instead of Makefile.org as the prototype.
+3 −0
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@
#include "cryptlib.h"
#include "bn_lcl.h"

#ifndef OPENSSL_NO_EC2M

/* Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should fail. */
#define MAX_ITERATIONS 50

@@ -1032,3 +1034,4 @@ int BN_GF2m_arr2poly(const int p[], BIGNUM *a)
	return 1;
	}

#endif
+4 −4
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
	message(out,"BN_mod_sqrt");
	if (!test_sqrt(out,ctx)) goto err;
	(void)BIO_flush(out);

#ifndef OPENSSL_NO_EC2M
	message(out,"BN_GF2m_add");
	if (!test_gf2m_add(out)) goto err;
	(void)BIO_flush(out);
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
	message(out,"BN_GF2m_mod_solve_quad");
	if (!test_gf2m_mod_solve_quad(out,ctx)) goto err;
	(void)BIO_flush(out);

#endif
	BN_CTX_free(ctx);
	BIO_free(out);

@@ -1061,7 +1061,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
	BN_free(one);
	return(1);
	}

#ifndef OPENSSL_NO_EC2M
int test_gf2m_add(BIO *bp)
	{
	BIGNUM a,b,c;
@@ -1636,7 +1636,7 @@ int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx)
	BN_free(e);
	return ret;
	}

#endif
static int genprime_cb(int p, int n, BN_GENCB *arg)
	{
	char c='*';
+10 −6
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ const EC_METHOD *EC_GFp_nistp224_method(void);
#endif
#endif


#ifndef OPENSSL_NO_EC2M
/********************************************************************/ 
/*           EC_METHOD for curves over GF(2^m)                      */
/********************************************************************/
@@ -170,6 +170,8 @@ const EC_METHOD *EC_GFp_nistp224_method(void);
 */
const EC_METHOD *EC_GF2m_simple_method(void);

#endif


/********************************************************************/
/*                   EC_GROUP functions                             */
@@ -291,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
@@ -310,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
@@ -351,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
@@ -361,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
@@ -490,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
@@ -523,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
@@ -1084,6 +1087,7 @@ void ERR_load_EC_strings(void);
#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
+4 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@

#include "ec_lcl.h"

#ifndef OPENSSL_NO_EC2M


/* Compute the x-coordinate x/z for the point 2*(x/z) in Montgomery projective 
 * coordinates.
@@ -384,3 +386,5 @@ int ec_GF2m_have_precompute_mult(const EC_GROUP *group)
	{
	return ec_wNAF_have_precompute_mult(group);
 	}

#endif
Loading