>       From: [email protected] On Behalf Of ikuzar
>       Sent: Thursday, 07 April, 2011 09:02

>       I 'd like to know if it is possible to store peer pubkey in my DH
sructure. 

If 'my' structure means an OpenSSL 'DH'
(which is actually a typedef for struct dh_st)
that represents your own keypair, sort of.

A DH publickey consists of one number (y) 
*associated somehow with* parameters (p,g).
Sometimes all three are transmitted together 
as in a static cert, and sometimes only y 
is transmitted and (p,g) are implicit.
Either way, your peer's key (y2,p2,g2) 
must use the same parameters as your key 
(y1,p1,g1) i.e. p1=p2 && g1=g2.

So if you have your keypair (p,g,x1,y1) in a 
DH struct the only peer value you need is y2.
There is an 'ex(tended)_data' capability for 
most(?) OpenSSL API structs, including DH, 
that allows you to store and retrieve 
any pointer you want (as/cast to void*), 
but it's very general and a bit clumsy.
Especially to support multiple peers.

Alternatively you could create a DH struct 
to represent the peer key and populate it 
with p(2),g(2),y2 but no x2. This "key" 
can't be used for anything but storage, 
but you can have it if you want.

But why do you want to store a peer pubkey?
The only purpose of a DH exchange is to 
produce a shared secret result, and that 
is normally what you need to keep, not y2.



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [email protected]

Reply via email to