RSA Security 5.2.2 manual Computing a Digital Signature Create, Set

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 308
Image 308

Performing Elliptic Curve Operations

B_KEY_OBJ publicKey = (B_KEY_OBJ)NULL_PTR;

B_KEY_OBJ privateKey = (B_KEY_OBJ)NULL_PTR;

if ((status = GenerateECKeys (&publicKey, &privateKey, &ecParamsObj, &randomAlgorithm) != 0)

Assume that the steps in “Generating an Elliptic Curve Key Pair” on page 268 have been completed and that publicKey and privateKey are ready to be used.

Computing a Digital Signature

Step 1: Create

Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in Chapter 4 of the Reference Manual, its address is the argument for B_CreateAlgorithmObject:

B_ALGORITHM_OBJ ecDSASign = (B_ALGORITHM_OBJ)NULL_PTR;

if ((status = B_CreateAlgorithmObject (&ecDSASign)) != 0) break;

Step 2: Set

The appropriate AI to use is AI_EC_DSAWithDigest. According to the entry in the Reference Manual, you have to provide a pointer to a B_DIGEST_SPECIFIER structure to B_SetAlgorithmInfo:

typedef struct { B_INFO_TYPE digestInfoType;

POINTER digestInfoParams;

}B_DIGEST_SPECIFIER;

Currently, the only digest algorithm supported is SHA1. This does not require any parameters, so specify NULL_PTR for digestInfoParams:

2 8 6

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 308
Image 308
RSA Security 5.2.2 manual Computing a Digital Signature Create, Set