Performing Elliptic Curve Operations
280 RSA BSAFE Crypto-C Developers Guide

Step 5b: Build the public-key acceleration table

It can take a while to generate the table, so use a surrender function. See The
Surrender Context on page 118 for more information:
Step 6: Destroy
Zeroize and free all sensitive information when it is no longer needed:
Performing EC Diffie-Hellman Key Agreement
Performing elliptic curve key agreement is similar to the ordinary Diffie-Hellman key
agreement scheme, which allows two parties to obtain the same symmetric key. First,
the two parties seeking to generate a secret key need to agree on the elliptic curve
parameters. The parameters can be generated by a central authority or by the parties
themselves.
The example in this section corresponds to the file ecdh.c.
In this example, the two parties who wish to derive the same secret key are Alice and
Bob. Both parties need to be provided with the same parameters:
ITEM pubKeyAccelTableItem;
generalSurrenderContext.Surrender = GeneralSurrenderFunction;
generalSurrenderContext.handle = (POINTER)&generalFlag;
generalSurrenderContext.reserved = NULL_PTR;
generalFlag = 0;
if ((status = B_BuildTableFinal
(buildTable, pubKeyAccelTableItem.data,
&(pubKeyAccelTableItem.len), maxTableLen,
&generalSurrenderContext)) != 0)
break;
T_memset(pubKeyAccelTableItem.data, 0, pubKeyAccelTableItem.len);
T_free(pubKeyAccelTableItem.data);
B_DestroyAlgorithmObject(&buildTable);
B_ALGORITHM_OBJ ecParamsObj = (B_ALGORITHM_OBJ)NULL_PTR;