Performing DSA Operations

contains the AM for SHA1 random number generation. The last argument is the surrender context. This function call is quick; the lengthy portion was generating the parameters:

B_KEY_OBJ dsaPublicKey = (B_KEY_OBJ)NULL_PTR;

B_KEY_OBJ dsaPrivateKey = (B_KEY_OBJ)NULL_PTR;

if ((status = B_CreateKeyObject (&dsaPublicKey)) != 0) break;

if ((status = B_CreateKeyObject (&dsaPrivateKey)) != 0) break;

if ((status = B_GenerateKeypair (dsaKeyGenObj, dsaPublicKey, dsaPrivateKey, randomAlgorithm, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 6: Destroy

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

B_DestroyAlgorithmObject (&randomAlgorithm);

B_DestroyAlgorithmObject (&dsaKeyGenObj);

B_DestroyKeyObject (&dsaPublicKey);

B_DestroyKeyObject (&dsaPrivateKey);

DSA Signatures

In this section, we describe how to write Crypto-C code that computes or verifies DSA digital signatures. See “Authentication and Digital Signatures” on page 57 for information on what a digital signature is. For signing, Crypto-C offers B_SignInit, B_SignUpdate, and B_SignFinal, which will digest the data and create a signature using DSA with a private key. For verification, Crypto-C offers B_VerifyInit, B_VerifyUpdate, and B_VerifyFinal to digest the data again and check the signature using its DSA public key.

C h a p t e r 7 P u b l i c - K e y O p e r a t i o n s

2 4 3

Page 265
Image 265
RSA Security 5.2.2 manual DSA Signatures, When you are done with all objects, remember to destroy them