B_VerifyFinal

Performing DSA Operations

page 118:

#define MAX_SIG_LEN 48

unsigned char signature[MAX_SIG_LEN]; unsigned int signatureLen;

/* generalFlag is for the surrender function. */ generalFlag = 0;

if ((status = B_SignFinal

(dsaSigner, signature, &signatureLen, MAX_SIG_LEN, randomAlgorithm, &generalSurrenderContext)) != 0)

break;

Step 6: Destroy

When you are done with all objects, remember to destroy them:

B_DestroyAlgorithmObject (&dsaSigner);

B_DestroyKeyObject (&dsaPrivateKey);

Verifying a Digital Signature

The Crypto-C sequence B_VerifyInit, B_VerifyUpdate, and B_VerifyFinal digests the original data and checks the signature. If the signature is valid,

returns a zero; if the signature is not valid, it returns an error code.

Step 1: Creating An Algorithm Object

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

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

2 4 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 268
Image 268
RSA Security 5.2.2 manual Destroy, #define Maxsiglen