B_GetKeyInfo information:

Performing Elliptic Curve Operations

B_DestroyAlgorithmObject(&ecKeyGen);

B_DestroyAlgorithmObject(&randomAlgorithm);

B_DestroyKeyObject(&publicKey);

B_DestroyKeyObject(&privateKey);

Retrieving an Elliptic Curve Key

If you need to store or transport information about your elliptic curve keys, you need to be able to retrieve the key information from an algorithm object. This section outlines the steps needed to retrieve information for a public key. The steps for retrieving a private key are similar.

You need to call B_GetKeyInfo with the appropriate KI. The Reference Manual describes two KIs for use with elliptic curve public keys: KI_ECPublic and KI_ECPublicComponent. However, KI_ECPublicComponent does not supply the elliptic curve parameters, which must be associated with any elliptic curve key. Therefore, you can only use KI_ECPublicComponent if you only need the public component, for example, if you have already retrieved the appropriate EC parameters. Therefore, for this example, you’ll use KI_ECPublic.

KI_ECPublic gives a pointer to an A_EC_PUBLIC_KEY structure:

typedef struct {

 

ITEM

publicKey;

/* public component */

A_EC_PARAMS curveParams;

/* the underlying elliptic curve parameters */

}A_EC_PUBLIC_KEY;

After you have your public key information in the key object publicKey, make a call to

. See “Generating an Elliptic Curve Key Pair” on page 268 for more

A_EC_PUBLIC_KEY *cryptocPublicKeyInfo;

if ((status = B_GetKeyInfo((POINTER *)&cryptocPublicKeyInfo, *publicKey, KI_ECPublic)) != 0)

break;

C h a p t e r 7 P u b l i c - K e y O p e r a t i o n s

2 7 1

Page 293
Image 293
RSA Security 5.2.2 manual Retrieving an Elliptic Curve Key, KIECPublic gives a pointer to an Aecpublickey structure