A SERVICE OF

logo

Performing Elliptic Curve Operations
296 RSA BSAFE Crypto-C Developers Guide
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:
Step 2: Set
Use the same AI as you did for signing:
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.)
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.
B_ALGORITHM_OBJ ecDSAVerify = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&ecDSAVerify)) != 0)
break;
if ((status = B_SetAlgorithmInfo (ecDSAVerify, AI_EC_DSA,
(POINTER)NULL_PTR)) != 0)
break;
if ((status = B_VerifyInit (ecDSAVerify, publicKey, EC_DSA_CHOOSER,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;