Chapter 7 Public-Key Operations 281
Performing Elliptic Curve Operations
To initialize
ecParamsObj
with a set of parameters describing an elliptic curve, follow
the steps in the section “Generating Elliptic Curve Parameters” on page 260. Assume
that these steps have been successfully completed and
ecParamsObj
contains the
common parameters for Alice and Bob. Put the elliptic curve parameters in the
A_EC_PARAMS structure,
ecParams
. For an implementation of an application-specific
procedure,
AllocAndCopyECParamInfo
, which retrieves and stores the parameters, see
“Retrieving Elliptic Curve Parameters” on page 264:
You will walk through the steps that Alice goes through, keeping in mind that Bob,
perhaps in another application, is performing the same steps.
Note: If this key agreement operation is performed several times with the same
parameters, you may wish to use the acceleration table. See “Generating
Acceleration Tables” on page 273 for more information.
Step 1: Create
Create the algorithm object which you will use to perform the key agreement:
Step 2: Set
Set the algorithm object with the information necessary to perform the operation.
AI_EC_DHKeyAgree, when used as the second argument to B_SetAlgorithmInfo, takes
as the third argument a pointer to a
B_EC_PARAMS structure:
A_EC_PARAMS
ecParams;
A_EC_PARAMS *cryptocECParams;
if ((status = B_GetAlgorithmInfo((POINTER *)&cryptocECParams, alice,
AI_ECParameters)) != 0)
break;
if ((status = AllocAndCopyECParamInfo(&ecParams, cryptocECParams)) != 0)
break;
B_ALGORITHM_OBJ alice = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject(&alice)) != 0)
break;