The X9.31 Sample Program

Verifying the Signature

Verifying an X9.31 RSA signature is almost identical to signing, except that you pass "rsaVerifyX931" for encryptionMethodName in Ai_SignVerify.

/* ======================================================== */ printf ("Verifying the Digital Signature \n");

printf ("=============================== \n");

/* Step 1: Create an algorithm object */

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

/* Step 2: Set the algorithm object to the same AI */

/* To verify the signature created above, you need to use the same AI you used for signing. Again, you must set up the appropriate structures containing the information for the algorithm you wish to use. The x931params structure is the same as the one used for signing, but you need to use "rsaVerifyX931" for the encryptionMethodName. */

signVerifyParams.encryptionMethodName = (unsigned char *)"rsaVerifyX931"; signVerifyParams.encryptionParams = NULL_PTR; signVerifyParams.digestMethodName = (unsigned char *)"sha1"; signVerifyParams.digestParams = NULL_PTR; signVerifyParams.formatMethodName = (unsigned char *)"formatX931"; signVerifyParams.formatParams = (POINTER)&x931params;

if ((status = B_SetAlgorithmInfo (digitalVerifier, AI_SignVerify, (POINTER)&signVerifyParams)) != 0)

break;

/* Step 3: Init */

/* Again, the only change required in the Init step is to include the appropriate algorithm methods in the chooser. These are the same methods included in the X931_SAMPLE_CHOOSER above. */

if ((status = B_VerifyInit

(digitalVerifier, publicKey, X931_SAMPLE_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

C h a p t e r 9 P u t t i n g I t A l l To g e t h e r : A n X 9 . 3 1 E x a m p l e

3 2 3

Page 345
Image 345
RSA Security 5.2.2 manual Verifying the Signature, Break