Thank you for your reply!!! I have another question about this topic. I need to generate a shared secret which size 16 byte, using a DH_compute_key() function. How can i manage that size???? Should I use a 16 byte dh->p????
Thank you for your help, Hector Agustin Cozzetti Subject: RE: Doubt about the use and initialization of DH structDate: Fri, 14 Dec 2007 08:09:29 -0700From: [EMAIL PROTECTED]: openssl-users@openssl.org First, if you pasted your original code into the email, then you have several typos. Second, two of the lines generate warnings on compilation about incompatible pointer types – these are significant. The lines are: num_byte = BN_dec2bn(dh_struct->p,str_p); num_byte = BN_dec2bn(dh_struct->g,str_g); //Note this was a line with a typo Try it with these lines as follows: num_byte = BN_dec2bn(&(dh_struct->p),str_p); num_byte = BN_dec2bn(&(dh_struct->g),str_g); When I did (plus fixing the other typo) and printed the results, I got: Num Bytes for p=5 Num Bytes for g=1 Return code from generate key=1 Bill From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Agustin CozzettiSent: December 14, 2007 5:30 AMTo: [EMAIL PROTECTED]: Doubt about the use and initialization of DH struct From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Doubt about the use and initialization of DH structDate: Fri, 14 Dec 2007 10:23:19 +0000Hello,I have a problem with DH struct in my source code C. Here a small list of my code: #include <stdio.h> #include <stdlib.h> #include <openssl/dh.h> #include <openssl/engine.h> #include <openssl/bn.h> DH *dh_struct; int main() { unsigned char str_p[] = "57503";unsigned char str_g[] = "5"; unsigned char *string; int num_byte,size,i; dh_struct = DH_new(); dh_struct->p = BN_new(); dh_struct->g = BN_new(); dh_struct->priv_key = BN_new(); dh_struct->pub_key = BN_new(); num_byte = BN_dec2bn(dh_struct->p,str_p); // Here it seems that not execute anything about structure "dh_struct->p"....why??? num_byte = BN_dec2bn(dh_struct->p,str_g); size = BN_num_bytes(dh_struct->p); // Here,the result is zero...why??? string = BN_bn2dec(dh_struct->p); // TEST,but string is NULL...why??? i=DH_generate_ket(dh_struct); // return 0,operation failed..... } I can not understand where I mistake in the code! Thank you for your help, Hector Agustin Cozzetti Per questo Natale fai i tuoi auguri con Messenger! Windows Live Messenger _________________________________________________________________ Scarica GRATIS la versione personalizzata MSN di Internet Explorer 7! http://optimizedie7.msn.com/default.aspx?mkt=it-it