> From: [email protected] On Behalf Of Marius Peschke > Sent: Thursday, 23 February, 2012 10:09
> I want to change from a self-programmed dh-implementation for > ike on a embedded device to openssl/dh. > As far as I understood, DH_generate_parameters() creates a > dh_st object. It creates a struct dh_st aka DH object *with new parameters* namely a newly-generated prime and the specified generator. > I can choose between different prime-lengths i want it to > search for a prime p for the g^x mod p. Where as g is the > base of the formula. > > With DH_generate_key i can then use the dh_st to calculate > the result of "g^x mod p". > Yes. And DH_compute_key with the peer's y to finish agreement. > But how can i use specific the DH groups 1,2,5,14-18 stated > in http://tools.ietf.org/html/rfc3526 and > http://tools.ietf.org/html/rfc2412 > Create a DH object with the standardized prime and generator (always 2) values, and optionally secret-length (although I believe there's no real harm in making your secret (x) larger than needed, it just slows down your g^x some). Use that for key agreement. You can do this on the fly with DH_new and some BN routines. Since the standards provide the primes in hex, BN_hex2bn is easy, or you could decode the hex first and do BN_mpi2bin. g is small so you only need BN_new and BN_set_word. You could encode and save these and read them back with i2d/d2i_DHparams or PEM_read/write[_bio]_DHparams, but that's likely overkill unless you want to (be able to) select between the standard groups and other groups that might be conveniently kept in files e.g. custom. ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [email protected] Automated List Manager [email protected]
