Chapter 7 Public-Key Operations 261
Performing Elliptic Curve Operations
The second,
ecParamsObj
, is set and initialized by B_GenerateParameters; it will hold
the newly-generated elliptic curve parameters.
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:
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:
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
B_ALGORITHM_OBJ paramGenObj = (B_ALGORITHM_OBJ)NULL_PTR;
B_ALGORITHM_OBJ ecParamsObj = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject(&paramGenObj)) != 0)
break;
if ((status = B_CreateAlgorithmObject(&ecParamsObj)) != 0)
break;
Format of info supplied to B_SetAlgorithmInfo:
pointer to a B_EC_PARAM_GEN_PARAMS structure.
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;