Performing Elliptic Curve Operations

In the sample code, FreeECParamInfo is implemented as follows:

void FreeECParamInfo(ecParams) A_EC_PARAMS *ecParams;

{

T_free(ecParams->fieldInfo.data); T_free(ecParams->coeffA.data); T_free(ecParams->coeffB.data); T_free(ecParams->base.data); T_free(ecParams->order.data); T_free(ecParams->cofactor.data);

}

Generating an Elliptic Curve Key Pair

In this section, you will generate a key pair suitable for use with Elliptic Curve DSA (ECDSA) and the Elliptic Curve Authenticated Encryption Scheme (ECAES).

You can optionally use an acceleration table to speed up the key generation operation. This is useful if you will be doing key generation with the same elliptic curve several times. If you will be using an acceleration table with this example, assume that you have gone through the steps of generating an acceleration table and that you have the table in the ITEM structure accelTableItem.

Step 1: Create

Create the algorithm object that you will use to generate the key pair:

B_ALGORITHM_OBJ ecKeyGen = (B_ALGORITHM_OBJ)NULL_PTR;

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

Also create the key objects to hold the keys after they have been generated:

B_KEY_OBJ publicKey = (B_KEY_OBJ)NULL_PTR;

B_KEY_OBJ privateKey = (B_KEY_OBJ)NULL_PTR;

2 6 8

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 290
Image 290
RSA Security 5.2.2 manual Generating an Elliptic Curve Key Pair, Sample code, FreeECParamInfo is implemented as follows