Performing Elliptic Curve Operations

Of course, you can write your own versions of these procedures to satisfy the needs of your application:

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;

When the information is no longer needed, don’t forget to free the allocated memory:

FreeECPubKeyInfo(&publicKeyInfo);

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.

B_EC_PARAMS paramInfo;

paramInfo.parameterInfoType = AI_ECPubKey; paramInfo.parameterInfoValue = (POINTER)&publicKeyInfo;

if ((status = B_SetAlgorithmInfo(buildTable, AI_ECBuildPubKeyAccelTable, (POINTER)¶mInfo)) != 0)

break;

2 7 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 300
Image 300
RSA Security 5.2.2 manual Put the information retrieved in the proper format, FreeECPubKeyInfo&publicKeyInfo