Performing Elliptic Curve Operations

if ((status = B_VerifyFinal (ecDSAVerify, signature, signatureLen, (B_ALGORITHM_OBJ)NULL_PTR, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 6: Destroy

Destroy all objects that are no longer needed:

T_free(signature);

B_DestroyAlgorithmObject(&ecParamsObj);

B_DestroyAlgorithmObject(&ecDSAVerify);

B_DestroyKeyObject(&publicKey);

Performing ECDSA with X9.62-Compliant BER

Like the previous section, this section shows how to use Crypto-C to perform ECDSA in compliance with the ANSI X9.62 Standard. In the previous example, the parameters were already initialized; in this example, X9.62 compliant BER encodings are used to initialize the parameters.

The example in this section corresponds to the file x962.c. on the CD-ROM.

Generating EC Parameters

In the section “Generating Elliptic Curve Parameters” on page 260, we illustrated how to generate elliptic curve parameters by using AI_ECParamGen. In this example, we will use the BER encoding of an ANSI X9.62 algorithm identifier, which specifies an elliptic curve, to set our algorithm object, ecParamsObj. These parameters will subsequently be used to generate a key pair.

Step 1: Creating an Algorithm Object

You need to create an algorithm object, ecParamsObj, to hold the generated parameter information.

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 1

Page 313
Image 313
RSA Security 5.2.2 manual Performing Ecdsa with X9.62-Compliant BER, Generating EC Parameters