Performing Elliptic Curve Operations

To sign an arbitrarily long message with the elliptic curve version of DSA, you can use AI_EC_DSAWithDigest. First, you need to generate parameters for an elliptic curve and a key pair from that curve. Then, you will specify a digest algorithm for use with ECDSA in signing the message. Currently, the only digest algorithm supported for this operation is SHA1.

The example in this section corresponds to the file ecdsadig.c.

Generating EC Parameters

See the section “Generating Elliptic Curve Parameters” on page 260 for the steps you must complete to generate a new curve. You will need a properly initialized pseudo- random number generator. Assume that the function InitializeRandomAlgorithm goes through Steps 1-4 in “Generating Random Numbers” on page 165. Also, assume that the function InitializeECParamsObj goes through the steps in “Generating Elliptic Curve Parameters” on page 260 to generate new parameters and place them in ecParamsObj:

B_ALGORITHM_OBJ randomAlgorithm = (B_ALGORITHM_OBJ)NULL_PTR;

B_ALGORITHM_OBJ ecParamsObj = (B_ALGORITHM_OBJ)NULL_PTR;

if ((status = InitializeRandomAlgorithm (&randomAlgorithm)) != 0) break;

if ((status = InitializeECParamsObj (&ecParamsObj, &randomAlgorithm)) != 0)

break;

Now you have a properly initialized random algorithm object, randomAlgorithm, and an algorithm object, ecParamsObj, containing the parameters that describe the elliptic curve that you are going to use.

Generating an EC Key Pair

You also need to generate a public and private key. 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, and optionally the acceleration table corresponding to that curve:

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 8 5

Page 307
Image 307
RSA Security 5.2.2 manual Generating EC Parameters, Generating an EC Key Pair