Performing Diffie-Hellman Key Agreement

A_DH_PARAM_GEN_PARAMS dhParams;

dhParams.primeBits = 512; dhParams.exponentBits = 504;

if ((status = B_SetAlgorithmInfo (dhParamGenerator, AI_DHParamGen, (POINTER)&dhParams)) != 0)

break;

Step 3: Init

Initialize the generation process with B_GenerateInit. Build an algorithm chooser. Because this function is quick, it is reasonable to pass NULL_PTR as the surrender context. Generating the parameters in Step 5 is time-consuming, though, so you will use a surrender context there:

B_ALGORITHM_METHOD *DH_SAMPLE_CHOOSER[] = { &AM_SHA_RANDOM,

&AM_DH_PARAM_GEN,

(B_ALGORITHM_METHOD *)NULL_PTR

};

if ((status = B_GenerateInit (dhParamGenerator, DH_SAMPLE_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 4: Update

There is no Step 4 in generating Diffie-Hellman parameters.

Step 5: Generate

To generate Diffie-Hellman parameters, call the Crypto-C function

B_GenerateParameters. The Reference Manual Chapter 4 entry for this call indicates there are four arguments.

The first is the algorithm object that generates the parameters; in this example, that is dhParamGenerator.

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 5 1

Page 273
Image 273
RSA Security 5.2.2 manual There is no in generating Diffie-Hellman parameters, Adhparamgenparams dhParams