On Wed, Mar 23, 2011, ikuzar wrote: > Hello, > I 'd like to know how to verify that DH private and public key have been > generated ? > In my DH struct, p and g had been generated with commands line ( openssl > dhparam... ) > > struct > { > BIGNUM *p; // prime number (shared) > BIGNUM *g; // generator of Z_p (shared) > BIGNUM *priv_key; // private DH value x > BIGNUM *pub_key; // public DH value g^x > // ... > }; > DH > > > Priv_key and pub_key are generated later with DH_generate_key(dh). > > I would like verify if DH_generate_key( ) has generated the priv_key ( an > human proof, example by using DHparams_print_fp(fp, dh ); ) I used this > function but it did not print private key into file pointed by fp. >
This can be performed more easily with the EVP_PKEY API which is part of OpenSSL 1.0.0 and later. You can perform all the key operations in there such as generation and printing the output. In fact they can all be done with the pkey command line utilities. If you want to keep to using the DH structure you can get a new EVP_PKEY with EVP_PKEY_new() include the DH with it by doing EVP_PKEY_set1_DH(), print it out with EVP_PKEY_print_private() and finally free up the pkey with EVP_PKEY_free(). Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial tech support now available see: http://www.openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org