Performing Elliptic Curve Operations
298 RSA BSAFE Crypto-C Developers Guide
Using Elliptic Curve Parameters
See the section Generating Elliptic Curve Parameters on page 260 for the steps you
must complete to generate a new curve. You need a properly initialized pseudo-
random number generator. Assume that the function
InitializeRandomAlgorithm
goes
through Steps 1 through 4 in the section Generating Random Numbers on page 165.
Also assume that the function
InitializeECParamsObj
generates new parameters and
places them in
ecParamsObj
, following the steps in Using Elliptic Curve Parameters
on page298:
You now have a properly initialized random algorithm object,
randomAlgorithm
, and
an algorithm object,
ecParamsObj
, containing the parameters that describe the elliptic
curve that you will use.
Using an EC Key Pair
Before you can encrypt, you need to generate a public/private key pair. As described
in Using an EC Key Pair on page 298, key generation requires a properly initialized
random algorithm and the parameters describing an elliptic curve, both of which you
have created in the previous step:
Assume that the steps in Using an EC Key Pair have been completed and that
publicKey
and
privateKey
are ready to be used.
ECAES Public-Key Encryption
Once you have gone through the preliminary steps of generating your elliptic curve
parameters and creating your public/private key pair, you are ready to encrypt your
message.
B_ALGORITHM_OBJ randomAlgorithm = (B_ALGORITHM_OBJ)NULL_PTR;
B_ALGORITHM_OBJ ecParamsObj = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = InitializeRandomAlgorithm (&randomAlgorithm)) != 0)
break;
if ((status = InitializeECParamsObj (&ecParamsObj,
&randomAlgorithm)) != 0)
break;
B_KEY_OBJ publicKey = (B_KEY_OBJ)NULL_PTR;
B_KEY_OBJ privateKey = (B_KEY_OBJ)NULL_PTR;