Performing Elliptic Curve Operations
268 RSA BSAFE Crypto-C Developers Guide
In the sample code,
FreeECParamInfo
is implemented as follows:
Generating an Elliptic Curve Key Pair
In this section, you will generate a key pair suitable for use with Elliptic Curve DSA
(ECDSA) and the Elliptic Curve Authenticated Encryption Scheme (ECAES).
You can optionally use an acceleration table to speed up the key generation operation.
This is useful if you will be doing key generation with the same elliptic curve several
times. If you will be using an acceleration table with this example, assume that you
have gone through the steps of generating an acceleration table and that you have the
table in the ITEM structure
accelTableItem
.
Step 1: Create
Create the algorithm object that you will use to generate the key pair:
Also create the key objects to hold the keys after they have been generated:
void FreeECParamInfo(ecParams)
A_EC_PARAMS *ecParams;
{
T_free(ecParams->fieldInfo.data);
T_free(ecParams->coeffA.data);
T_free(ecParams->coeffB.data);
T_free(ecParams->base.data);
T_free(ecParams->order.data);
T_free(ecParams->cofactor.data);
}
B_ALGORITHM_OBJ ecKeyGen = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&ecKeyGen)) != 0)
break;
B_KEY_OBJ publicKey = (B_KEY_OBJ)NULL_PTR;
B_KEY_OBJ privateKey = (B_KEY_OBJ)NULL_PTR;