Performing Elliptic Curve Operations
276 RSA BSAFE Crypto-C Developer’s Guide
Step 5: Final
Step 5a: Allocate memory
You must allocate sufficient memory to hold the acceleration table. According to the
Reference Manual, you can use
B_BuildTableGetBufSize to tell how much space will
be required to store the acceleration table:
Step 5b: Build the acceleration table
Finally, build the acceleration table and store it in an ITEM structure. You store it this
way for convenience—when you actually use the acceleration table, you will have to
provide it in an
ITEM structure to B_SetAlgorithmInfo. Building an acceleration table
can take a lot of time, so use a surrender context. See “The Surrender Context” on
page 118 for more information:
ITEM accelTableItem;
unsigned int maxTableLen;
if ((status = B_BuildTableGetBufSize(buildTable, &maxTableLen)) != 0)
break;
accelTableItem.data = T_malloc(maxTableLen);
if ((status = (accelTableItem.data == NULL_PTR)) != 0)
break;
ITEM accelTableItem;
generalSurrenderContext.Surrender = GeneralSurrenderFunction;
generalSurrenderContext.handle = (POINTER)&generalFlag;
generalSurrenderContext.reserved = NULL_PTR;
generalFlag = 0;
if ((status = B_BuildTableFinal(buildTable, accelTableItem.data,
&(accelTableItem.len), maxTableLen,
&generalSurrenderContext)) != 0)
break;