Chapter 7 Public-Key Operations 243
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:
Step 6: Destroy
When you are done with all objects, remember to destroy them:
DSA Signatures
In this se ction, we desc ribe how to writ e Crypt o-C code that co mputes or veri fies 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.
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;
B_DestroyAlgorithmObject (&randomAlgorithm);
B_DestroyAlgorithmObject (&dsaKeyGenObj);
B_DestroyKeyObject (&dsaPublicKey);
B_DestroyKeyObject (&dsaPrivateKey);