RSA Security 5.2.2 manual Destroy

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 274
Image 274
B_GenerateParameters

Performing Diffie-Hellman Key Agreement

The second is a result algorithm object. Crypto-C will generate some values and will need to place them somewhere. So you might as well place them into an algorithm object now. (This is similar to generating an RSA key pair, where the results were placed into key objects.) Create an algorithm object, but do not set it;

will do that.

The third argument is a random algorithm. Complete Steps 1 through 4 of

“Generating Random Numbers” on page 165. You do not need random bytes, only an algorithm that can generate them. The algorithm chooser you are using contains the AM for SHA random number generation.

The last argument is a surrender context. Generating Diffie-Hellman parameters is time-consuming; it can take up to two minutes. On slower machines, generating parameters over 800-bits can take more than an hour. Use the surrender context mentioned previously. It will print out a dot every second to let you know that Crypto-C is computing and the machine has not crashed:

B_ALGORITHM_OBJ dhParametersObj = (B_ALGORITHM_OBJ)NULL_PTR;

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

/* generalFlag is for this tutorial’s surrender function. */ generalFlag = 0;

if ((status = B_GenerateParameters (dhParamGenerator, dhParametersObj, randomAlgorithm, &generalSurrenderContext)) != 0)

break;

Step 6: Destroy

Remember to destroy your objects. Do not destroy the dhParametersObj object until you have passed it on to the parties executing the agreement. The next section discusses that point:

B_DestroyAlgorithmObject (&randomAlgorithm);

B_DestroyAlgorithmObject (&dhParamGenerator);

2 5 2

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 274
Image 274
RSA Security 5.2.2 manual Destroy