Chapter 7 Public-Key Operations 293
Performing Elliptic Curve Operations
Generating an EC Key Pair
See Generating an Elliptic Curve Key Pair on page 268 for the required steps. To
complete those steps, you will need a properly initialized random algorithm, the
parameters describing an elliptic curve (see the x962.c sample to use BER-encoded
EC parameters), and optionally the acceleration table corresponding to that curve.
Assume that the steps in Generating an Elliptic Curve Key Pair on page 268 have
been completed and that publicKey and privateKey are ready to be used.
Computing a Digital Signature
Step 1: Create
Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in
Chapter 4 of the Reference Manual, its address is the argument for
B_CreateAlgorithmObject:
Step 2: Set
You can set the algorithm to AI_EC_DSA or to AI_EC_DSAWithDigest. We are
demonstrating raw DSA signature generation and verification; thus, we will use
AI_EC_DSA. According to the entry in the Reference Manual, you must supply a
NULL_PTR to B_SetAlgorithmInfo.
stockECParamsBER.data = ECParamsBER;
stockECParamsBER.len = 154;
if ((status = B_SetAlgorithmInfo (*ecParamsObj, AI_ECParametersBER,
(POINTER)&stockECParamsBER)) != 0)
break;
B_ALGORITHM_OBJ ecDSASign = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&ecDSASign)) != 0)
break;