Performing Elliptic Curve Operations

Step 6: Destroy

You must free all allocated memory and destroy all objects when they are no longer needed so that all sensitive information is zeroized and freed:

T_memset(accelTableItem.data, 0, accelTableItem.len);

T_free(accelTableItem.data);

B_DestroyAlgorithmObject(&buildTable);

Generating a Public-Key Acceleration Table

This special-purpose acceleration table can be used to speed up ECDSA verification. Again, the cost in time to generate the table and space to store it must be weighed against the speedup in verification that it will provide. This table is most useful if ECDSA verification will be performed repeatedly with the same public key. The function BuildPubKeyAccelTable, used in the sample code and defined in the file ecparam.c, demonstrates the steps in creating the public-key acceleration table.

Step 1: Create

Create the algorithm object that will be used in building the public-key acceleration table. 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 buildTable = (B_ALGORITHM_OBJ)NULL_PTR;

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

Step 2: Set

Retrieve the public-key information and place it in the algorithm object used to build the acceleration table for that public key.

Step 2a: Retrieve the public key information

Because B_GetKeyInfo returns a pointer to memory that belongs to Crypto-C, you must make a copy of this information. See “Retrieving an Elliptic Curve Key” on page 271 for the definitions of AllocAndCopyECPubKeyInfo and FreeECPubKeyInfo.

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

Page 299
Image 299
RSA Security 5.2.2 manual Generating a Public-Key Acceleration Table, Retrieve the public key information