Performing Elliptic Curve Operations

stockECParamsBER.data = ECParamsBER; stockECParamsBER.len = 154;

if ((status = B_SetAlgorithmInfo (*ecParamsObj, AI_ECParametersBER, (POINTER)&stockECParamsBER)) != 0)

break;

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:

B_ALGORITHM_OBJ ecDSASign = (B_ALGORITHM_OBJ)NULL_PTR;

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

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.

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 9 3

Page 315
Image 315
RSA Security 5.2.2 manual StockECParamsBER.data = ECParamsBER stockECParamsBER.len =