Things are getting clearer as I dig deeper. The book "Network Security with
OpenSSL" by John Viega et al has some explanation of how the DH key exchange
takes place.
With that knowledge, I went through the source code and found that
DH_Compute_Key() is being called in s3_clnt.c and s3_srvr.c. So there is no
need to call it in client applications.
BRs
Ramg
On Thu, Aug 27, 2009 at 12:23 PM, Ram G <mydev...@gmail.com> wrote:
> Hello,
>
> Going through various posts, I have come across references to Bodo
> Moeller's example code showing SSL communication without certificates and
> using anonymous DH key exchange. If anybody has that sample, can you please
> forward it ?
>
> I have written a client and server taking help from the sample programs.
> I'm generating the DH params in the server and setting it in the SSL
> context. I'm setting the cipher as ADH-AES256-SHA in both server and client.
> The client and server are communicating.
>
> To generate the DH parameters P & G, I have done this:
>
> 1) Calling DH_generate_parameters() in the server will generate the Prime P
> 2) Calling DH_generate_key() performs the first step of a Diffie-Hellman
> key exchange by generating private and public DH values.
>
> Documentation also talks about this call to generate the shared key:
>
> 3) Calling DH_compute_key(), these are combined with the client's public
> value to compute the shared key. (My program is working even without the
> DH_compute_key() call in the server - which is strange I think)
>
> What I'm not sure is :
>
> What is the call I need to make in the client to pass the client's public
> key ( G (power X) mod P ) to the server ?
>
> I'm working on a prototype and beginning to get my hands dirty with
> OpenSSL. Your help is greatly appreciated.
>
> -Ramg
>
--0016e6464fd0c8a848047224b892
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Things are getting clearer as I dig deeper. The book "Network Sec=
urity with OpenSSL" by John Viega et al has some explanation of how th=
e DH key exchange takes place.</div>
<div>=A0</div>
<div>With that knowledge, I went through the source code and found that DH_=
Compute_Key() is being called in s3_clnt.c and s3_srvr.c. So there is no ne=
ed to call it in client applications.</div>
<div>=A0</div>
<div>BRs</div>
<div>=A0</div>
<div>Ramg<br></div>
<div class=3D"gmail_quote">On Thu, Aug 27, 2009 at 12:23 PM, Ram G <span di=
r=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com">mydev...@gmail.co=
m</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Hello,</div>
<div>=A0</div>
<div>Going through various posts, I have come across references to Bodo Moe=
ller's example code showing SSL communication without certificates and =
using anonymous DH key exchange. If anybody has that sample, can you please=
forward it ?</div>
<div>=A0</div>
<div>I have written a client and server taking help from the sample program=
s. I'm generating the DH params in the server and setting it in the SSL=
context. I'm setting the cipher as ADH-AES256-SHA in both server and c=
lient. The client and server are communicating.</div>
<div>=A0</div>
<div>To generate the DH parameters P & G,=A0I have done=A0this:</div>
<div>=A0</div>
<div>1) Calling DH_generate_parameters() in the server will generate the Pr=
ime P<br>2) Calling DH_generate_key() performs the first step of a Diffie-H=
ellman key exchange by generating private and public DH values. </div>
<div>=A0</div>
<div>Documentation also talks about this call to generate the shared key:</=
div>
<div>=A0</div>
<div>3) Calling DH_compute_key(), these are combined with the client's =
public value to compute the shared key. (My program is working even without=
the DH_compute_key() call in the server - which is strange I think)</div>
<div>=A0</div>
<div>What I'm not sure is :</div>
<div>=A0</div>
<div>What is the call I need to make in the client to pass the client's=
public key ( G (power X) mod P )=A0to the server ? </div>
<div>=A0</div>
<div>I'm working on a prototype and beginning to get my hands dirty wit=
h OpenSSL. Your help is greatly appreciated. </div>
<div>=A0</div>
<div>-Ramg</div></blockquote></div><br>
--0016e6464fd0c8a848047224b892--
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org
I'm also interested in such sample program. Anyone?
--000e0cd755247e29240472322fe0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I'm also interested in such sample program. Anyone?<br><br><div><br><di=
v class=3D"gmail_quote">On Thu, Aug 27, 2009 at 4:39 PM, Ram G <span dir=3D=
"ltr"><<a href=3D"mailto:mydev...@gmail.com">mydev...@gmail.com</a=
>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;"><div>Things are getting clearer as I dig de=
eper. The book "Network Security with OpenSSL" by John Viega et a=
l has some explanation of how the DH key exchange takes place.</div>
<div>=A0</div>
<div>With that knowledge, I went through the source code and found that DH_=
Compute_Key() is being called in s3_clnt.c and s3_srvr.c. So there is no ne=
ed to call it in client applications.</div>
<div>=A0</div>
<div>BRs</div>
<div>=A0</div>
<div>Ramg<br></div>
<div class=3D"gmail_quote">On Thu, Aug 27, 2009 at 12:23 PM, Ram G <span di=
r=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com" target=3D"_blank">my=
devf...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"padding-left:1ex;margin:0px 0px =
0px 0.8ex;border-left:#ccc 1px solid">
</blockquote></div><br></div>
--000e0cd755247e29240472322fe0--
Here is the sample program I have so far to test the concept of anonymous
DH:
1) Start with the samples included in the source. For e.g :
demos/ssl/serv.cpp and cli.cpp
2) Server & Client: Remove all the calls related to certificates -
SSL_CTX_use_certificate_file(ctx, CERTF, SSL_FILETYPE_PEM)
SSL_CTX_use_PrivateKey_file(ctx, KEYF, SSL_FILETYPE_PEM)
SSL_CTX_check_private_key(ctx))
SSL_get_peer_certificate()
etc.
3) Write a function to either load the DH params from a file or generate it:
void load_dh_params(ctx)
SSL_CTX *ctx;
{
DH *dh=NULL;
RAND_seed(rnd_seed, sizeof rnd_seed);
if(((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, 128, 5,
NULL))
printf("Couldn't generate DH \n");
//Make calls to DH_check() to make sure generated params are ok
....
if (!DH_generate_key(dh))
printf("Couldn't generate DH key\n");
//If you want to read from a file, use following, comment out generation
calls above
////////BIO *out;
////////out=BIO_new(BIO_s_file());
////////BIO_set_fp(out,stdout,BIO_NOCLOSE);
////////dh = PEM_read_bio_DHparams(bio,NULL,NULL,NULL);
////////BIO_free(bio);
if(SSL_CTX_set_tmp_dh(ctx,dh)<0)
printf("Couldn't set DH parameters\n");
}
4) Server : Call the DH generation function
....
ctx = SSL_CTX_new (meth);
load_dh_params(ctx);
5) Server & client: Set the cipher
SSL_CTX_set_cipher_list(ctx,"ADH-AES256-SHA");
This should be enough for a very basic anonymous DH client/server program
Regards
Ramg
--0016e644cd96f5942b0472335212
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Here is the sample program I have so far to test the concept of anonym=
ous DH:</div>
<div>=A0</div>
<div>1) Start with the samples included in the source. For e.g : demos/ssl/=
serv.cpp and cli.cpp</div>
<div>=A0</div>
<div>2) Server & Client: Remove all the calls related to certificates -=
</div>
<div>=A0</div>
<div>SSL_CTX_use_certificate_file(ctx, CERTF, SSL_FILETYPE_PEM)</div>
<div>SSL_CTX_use_PrivateKey_file(ctx, KEYF, SSL_FILETYPE_PEM)</div>
<div>SSL_CTX_check_private_key(ctx))</div>
<div>SSL_get_peer_certificate() </div>
<div>=A0</div>
<div>etc.</div>
<div>=A0</div>
<div>3) Write a function to either load the DH params from a file or genera=
te it:</div>
<div>=A0</div>
<div>void load_dh_params(ctx)<br>SSL_CTX *ctx;<br>{</div>
<div>=A0DH *dh=3DNULL;</div>
<div>=A0RAND_seed(rnd_seed, sizeof rnd_seed);=A0</div>
<div>=A0if(((dh =3D DH_new()) =3D=3D NULL) || !DH_generate_parameters_ex(dh=
, 128, 5, NULL))<br>=A0=A0printf("Couldn't generate DH \n");<=
/div>
<div>=A0//Make calls to DH_check() to make sure generated params are ok<br>=
=A0....<br>=A0<br>=A0if (!DH_generate_key(dh)) <br>=A0=A0printf("Could=
n't generate DH key\n");</div>
<div>=A0//If you want to read from a file, use following, comment out gener=
ation calls above<br>=A0////////BIO *out;<br>=A0////////out=3DBIO_new(BIO_s=
_file());<br>=A0////////BIO_set_fp(out,stdout,BIO_NOCLOSE);<br>=A0////////d=
h =3D PEM_read_bio_DHparams(bio,NULL,NULL,NULL);<br>
=A0////////BIO_free(bio);</div>
<div>=A0if(SSL_CTX_set_tmp_dh(ctx,dh)<0)<br>=A0=A0printf("Couldn=
9;t set DH parameters\n");</div>
<div>}</div>
<div>=A0</div>
<div>4) Server : Call the DH generation function</div>
<div>=A0</div>
<div>=A0 ....</div>
<div>=A0 ctx =3D SSL_CTX_new (meth);<br>=A0 load_dh_params(ctx);</div>
<div>=A0</div>
<div>5) Server & client: Set the cipher</div>
<div>=A0</div>
<div>SSL_CTX_set_cipher_list(ctx,"ADH-AES256-SHA");</div>
<div>=A0</div>
<div>This should be enough for a very basic anonymous DH client/server prog=
ram</div>
<div>=A0</div>
<div>Regards</div>
<div>=A0</div>
<div>Ramg</div>
<div>=A0</div>
<div><br>=A0</div>
<div class=3D"gmail_quote">On Fri, Aug 28, 2009 at 7:42 AM, Josue Andrade G=
omes <span dir=3D"ltr"><<a href=3D"mailto:josue.gome...@gmail.com=
">josue.gome...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I'm also interested in such =
sample program. Anyone?=20
<div>
<div></div>
<div class=3D"h5"><br><br>
<div><br>
<div class=3D"gmail_quote">On Thu, Aug 27, 2009 at 4:39 PM, Ram G <span dir=
=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com" target=3D"_blank">myd=
evfo...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Things are getting clearer as I dig deeper. The book "Network Sec=
urity with OpenSSL" by John Viega et al has some explanation of how th=
e DH key exchange takes place.</div>
<div>=A0</div>
<div>With that knowledge, I went through the source code and found that DH_=
Compute_Key() is being called in s3_clnt.c and s3_srvr.c. So there is no ne=
ed to call it in client applications.</div>
<div>=A0</div>
<div>BRs</div>
<div>=A0</div>
<div>Ramg<br></div>
<div class=3D"gmail_quote">On Thu, Aug 27, 2009 at 12:23 PM, Ram G <span di=
r=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com" target=3D"_blank">my=
devf...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>-Ramg</div></blockquote></div><br></blockquote></div><br></div></div><=
/div></blockquote></div><br>
--0016e644cd96f5942b0472335212--
Also include the following call to read the DH files (samples included in
source like dh1024.pem) in function load_dh_params().
////////if ((bio=BIO_new_file(file,"r")) == NULL)
////////printf("Couldn't open DH file\n");
--00151774046ea30c4204723363b5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Also include the following call to read the DH files (samples included=
in source like dh1024.pem) in function load_dh_params().</div>
<div>=A0</div>
<div>////////if ((bio=3DBIO_new_file(file,"r")) =3D=3D NULL)<br>=
=A0=A0=A0=A0=A0 ////////printf("Couldn't open DH file\n");<br=
><br>=A0</div>
<div class=3D"gmail_quote">On Fri, Aug 28, 2009 at 9:04 AM, Ram G <span dir=
=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com">mydev...@gmail.com=
</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div></div>
<div class=3D"h5">
<div>=A0</div>
<div><br>=A0</div>
<div class=3D"gmail_quote">On Fri, Aug 28, 2009 at 7:42 AM, Josue Andrade G=
omes <span dir=3D"ltr"><<a href=3D"mailto:josue.gome...@gmail.com=
" target=3D"_blank">josue.gome...@gmail.com</a>></span> wrote:<br=
>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I'm also interested in such =
sample program. Anyone?=20
<div>
<div></div>
<div><br><br>
/div></blockquote></div><br></div></div></blockquote></div><br>
--00151774046ea30c4204723363b5--
Thanks a lot.
For those interested I've published here my sample:
http://www.josuegomes.com/dhsample.php<http://www.josuegomes.com/dhsample.php>
--000e0cd330805823b6047236ba5c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Thanks a lot.</div><br clear=3D"all">For those interested I've pub=
lished here my sample:=A0<a href=3D"http://www.josuegomes.com/dhsample.php"=
>http://www.josuegomes.com/dhsample.php</a><div><a href=3D"http://www.josue=
gomes.com/dhsample.php"></a><br>
<div><br><br><div class=3D"gmail_quote">On Fri, Aug 28, 2009 at 10:09 AM, R=
am G <span dir=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com">mydevfo=
ru...@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>Also include the following call to read the DH files (samples included=
in source like dh1024.pem) in function load_dh_params().</div>
<div>=A0</div>
<div>////////if ((bio=3DBIO_new_file(file,"r")) =3D=3D NULL)<br>=
=A0=A0=A0=A0=A0 ////////printf("Couldn't open DH file\n");<br=
><br>=A0</div><div><div></div><div class=3D"h5">
<div class=3D"gmail_quote">On Fri, Aug 28, 2009 at 9:04 AM, Ram G <span dir=
=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com" target=3D"_blank">myd=
evfo...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"padding-left:1ex;margin:0px 0px =
0px 0.8ex;border-left:#ccc 1px solid">
<div>=A0</div>
<div><br>=A0</div>
<div class=3D"gmail_quote">On Fri, Aug 28, 2009 at 7:42 AM, Josue Andrade G=
omes <span dir=3D"ltr"><<a href=3D"mailto:josue.gome...@gmail.com=
" target=3D"_blank">josue.gome...@gmail.com</a>></span> wrote:<br=
>
<blockquote class=3D"gmail_quote" style=3D"padding-left:1ex;margin:0px 0px =
0px 0.8ex;border-left:#ccc 1px solid">I'm also interested in such sampl=
e program. Anyone?=20
<div>
<div></div>
<div><br><br>
<div><br>
<div class=3D"gmail_quote">On Thu, Aug 27, 2009 at 4:39 PM, Ram G <span dir=
=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com" target=3D"_blank">myd=
evfo...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"padding-left:1ex;margin:0px 0px =
0px 0.8ex;border-left:#ccc 1px solid">
<div>Things are getting clearer as I dig deeper. The book "Network Sec=
urity with OpenSSL" by John Viega et al has some explanation of how th=
e DH key exchange takes place.</div>
<div>=A0</div>
<div>With that knowledge, I went through the source code and found that DH_=
Compute_Key() is being called in s3_clnt.c and s3_srvr.c. So there is no ne=
ed to call it in client applications.</div>
<div>=A0</div>
<div>BRs</div>
<div>=A0</div>
<div>Ramg<br></div>
<div class=3D"gmail_quote">On Thu, Aug 27, 2009 at 12:23 PM, Ram G <span di=
r=3D"ltr"><<a href=3D"mailto:mydev...@gmail.com" target=3D"_blank">my=
devf...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"padding-left:1ex;margin:0px 0px =
0px 0.8ex;border-left:#ccc 1px solid">
</div></div></blockquote></div><br></div></div>
--000e0cd330805823b6047236ba5c--