Using Cryptographic Hardware

PKCS #11 Support for DSA Key Pair Generation

This section describes how to generate a DSA key pair using a PKCS #11 device. You will need some DSA parameters, since PKCS #11 does not specify a way to generate parameters. If you do not already have them, use Crypto-C to generate some DSA parameters.

B_ALGORITHM_METHOD *DSA_PARAM_GEN_CHOOSER[] = { &AM_DSA_PARAM_GEN,

(B_ALGORITHM_METHOD *)NULL_PTR;

};

B_ALGORITHM_OBJ dsaParamGen = (B_ALGORITHM_OBJ)NULL_PTR;

B_DSA_PARAM_GEN_PARAM dsaParamGenParams;

dsaParamGenParams.primeBits = 1024;

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

if ((status = B_SetAlgorithmInfo (dsaParamGen, AI_DSAParamGen, (POINTER)&dsaParamGenParams)) != 0)

break;

if ((status = B_GenerateInit

(dsaParamGen, DSA_PARAM_GEN_CHOOSER, NULL_SURR)) != 0) break;

At this point, you will call B_GenerateParameters. The resulting parameters need to be stored somewhere. They will be stored in an algorithm object. A limitation in Crypto-C is that you cannot store them in an object from which you simply extract the parameters. You must store them in an object that will be used to generate a key pair. Then you must generate a key pair to extract the parameters.

1 4 4

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 166
Image 166
RSA Security 5.2.2 manual Pkcs #11 Support for DSA Key Pair Generation