Performing Diffie-Hellman Key Agreement

Distributing Diffie-Hellman Parameters

The central authority, after computing the parameters, must send this information to the parties seeking agreement on a secret key. This can be done using Crypto-C format or BER-encoded format.

Note: It is not necessary to generate parameters each time two parties wish to agree on a secret key. Any number of key agreements can use the same parameters. Of course, for greater security, it is a good idea to generate new parameters every so often.

Crypto-C Format

To send the information in Crypto-C format, you can send a copy of the algorithm object to the participants. Actually, you do not send the object itself, but rather the “info supplied to B_SetAlgorithmInfo.”

Recall that you did not set the algorithm object dhParametersObj; the Crypto-C function B_GenerateParameters did. It is set to the AI AI_DHKeyAgree. In the Reference Manual Chapter 2 entry on AI_DHKeyAgree, the topic “Format of info returned by B_GetAlgorithmInfo” states that it returns a pointer to an A_DH_KEY_AGREE_PARAMS structure:

typedef struct

{

 

 

ITEM

prime;

/* prime

modulus */

ITEM

base;

/* base generator */

unsigned int

exponentBits;

/* size of random exponent

in bits */

} A_DH_KEY_AGREE_PARAMS;

where ITEM is:

typedef struct { unsigned char *data; unsigned int len;

}ITEM;

Declare a variable to be a pointer to such a structure and pass its address as the argument.

Using the Reference Manual Chapter 4 prototype for B_GetAlgorithmInfo as a guide, you can write the following:

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 3

Page 275
Image 275
RSA Security 5.2.2 manual Distributing Diffie-Hellman Parameters, Base generator