RSA Security 5.2.2 manual Verifying a Digital Signature, Use the same AI as you did for signing

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 318
Image 318

Performing Elliptic Curve Operations

Verifying a Digital Signature

To verify the signature, you must go through a similar procedure. At the end, if the signature is valid, B_VerifyFinal returns 0. If it is not valid, B_VerifyFinal will return an error.

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 ecDSAVerify = (B_ALGORITHM_OBJ)NULL_PTR;

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

Step 2: Set

Use the same AI as you did for signing:

if ((status = B_SetAlgorithmInfo (ecDSAVerify, AI_EC_DSA, (POINTER)NULL_PTR)) != 0)

break;

Step 3: Init

Associate a key with the algorithm object and provide a chooser that contains the necessary algorithm methods. (See “Computing a Digital Signature” on page 293.)

if ((status = B_VerifyInit (ecDSAVerify, publicKey, EC_DSA_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 4: Update

Pass the original message. It will be internally digested to make a new signature that can be compared with the signature received by B_VerifyFinal.

2 9 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 318
Image 318
RSA Security 5.2.2 manual Verifying a Digital Signature, Use the same AI as you did for signing