Performing Elliptic Curve Operations

The second, ecParamsObj, is set and initialized by B_GenerateParameters; it will hold the newly-generated elliptic curve parameters.

B_ALGORITHM_OBJ paramGenObj = (B_ALGORITHM_OBJ)NULL_PTR;

B_ALGORITHM_OBJ ecParamsObj = (B_ALGORITHM_OBJ)NULL_PTR;

if ((status = B_CreateAlgorithmObject(¶mGenObj)) != 0) break;

if ((status = B_CreateAlgorithmObject(&ecParamsObj)) != 0) break;

Step 2: Setting the Algorithm Object

You need to set the algorithm object that will be used to generate the elliptic curve parameters. The only AI that can be used to generate elliptic curve parameters is AI_ECParamGen. Chapter 2 in the Reference Manual gives the following:

Format of info supplied to B_SetAlgorithmInfo:

pointer to a B_EC_PARAM_GEN_PARAMS structure.

To supply the necessary information, pass a pointer to a B_EC_PARAM_GEN_PARAMS structure as the third argument to B_SetAlgorithmInfo. The B_EC_PARAM_GEN_PARAMS structure is defined in the Chapter 2 entry in the Reference Manual for AI_ECParamGen:

typedef struct

{

 

 

unsigned int

version;

 

/* implementation version */

unsigned int

fieldType;

 

/* base field for the elliptic curve */

unsigned int

fieldElementBits;

 

/* length of field element in bits */

unsigned int

pointRepresentation;/*controls field element representation */

unsigned int

minOrderBits;

/* minimum size of group generated by base */

 

/* input of 0 defaults to fieldElementBits - 7 */

unsigned int

trialDivBound;

/* maximum size of second largest prime */

 

 

/*

subgroup of group generated by base */

 

 

 

/* input of 0 defaults to 255 */

unsigned int

tableLookup;

 

/* characteristic 2 only. Set if the */

 

 

/*

use of precomputed params is desired */

} B_EC_PARAM_GEN_PARAMS;

 

 

 

 

 

 

You must choose the field type and the length of the field element. The field type can be either: a prime field of odd characteristic, that is, Fp; or a field of even characteristic, F2m.

For this example, set the arguments as shown here. The first argument specifies the

C h a p t e r 7 P u b l i c - K e y O p e r a t i o n s

2 6 1

Page 283
Image 283
RSA Security 5.2.2 manual Format of info supplied to BSetAlgorithmInfo, Implementation version, Input of 0 defaults to