Performing Elliptic Curve Operations
278 RSA BSAFE Crypto-C Developers Guide
Of course, you can write your own versions of these procedures to satisfy the needs of
your application:
When the information is no longer needed, dont forget to free the allocated memory:
Step 2b: Put the information retrieved in the proper format
To build the public-key acceleration table, use AI_ECBuildPubKeyAccelTable. The
Reference Chapter 2 entry for AI_ECBuildPubKeyAccelTable states that you must
supply a pointer to a B_EC_PARAMS structure. The procedure you use to fill this
structure in is the same as the one you used to build the generic acceleration table.
However, because you are building an acceleration table based on the public key, you
must also pass in information about the public key.
You have an A_EC_PUBLIC_KEY struct containing the public key information, so the
appropriate B_INFO_TYPE to use is AI_ECPubKey. According to the Reference Manual
entry on AI_ECPubKey, you should pass B_SetAlgorithmInfo a pointer to
A_EC_PUBLIC_KEY structure. Set the
parameterInfoType
to AI_ECPubKey and give
parameterInfoValue
the pointer to your A_EC_PUBLIC_KEY structure
publicKeyInfo
.
A_EC_PUBLIC_KEY *cryptocPublicKeyInfo;
A_EC_PUBLIC_KEY publicKeyInfo;
if ((status = B_GetKeyInfo((POINTER *)&cryptocPublicKeyInfo,
*publicKey, KI_ECPublic)) != 0)
break;
if ((status = AllocAndCopyECPubKeyInfo(&publicKeyInfo,
cryptocPublicKeyInfo)) != 0)
break;
FreeECPubKeyInfo(&publicKeyInfo);
B_EC_PARAMS paramInfo;
paramInfo.parameterInfoType = AI_ECPubKey;
paramInfo.parameterInfoValue = (POINTER)&publicKeyInfo;
if ((status = B_SetAlgorithmInfo(buildTable, AI_ECBuildPubKeyAccelTable,
(POINTER)&paramInfo)) != 0)
break;