RSA Security 5.2.2 Projection Television User Manual


 
Chapter 7 Public-Key Operations 251
Performing Diffie-Hellman Key Agreement
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:
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
.
A_DH_PARAM_GEN_PARAMS dhParams;
dhParams.primeBits = 512;
dhParams.exponentBits = 504;
if ((status = B_SetAlgorithmInfo
(dhParamGenerator, AI_DHParamGen,
(POINTER)&dhParams)) != 0)
break;
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;