Hi,

I have a doubt here regarding the length in bits for shared secret key
generated using Diffie-Hellman, hope someone could kindly clear my doubt
:)

In "DH *DH_generate_parameters(int prime_len, int generator, void
*callback, char *cb_arg)", the first argument is the length in bits for
the prime number to be generated in order for subsequent calculation of
the shared secret key.  I have a doubt here.  Let say I want to generate
a 128 bits (16 bytes) shared secret key, so I pass the value 128 to the
first argument which is prime_len.  Then after the "numofbyte =
DH_compute_key(a_shared_secret_key, b->pub_key, a)" function is called,
the return value, numofbyte in this case holds the number of bytes for
the shared secret key generated.  I noticed that numofbyte is sometimes
15 bytes and sometimes 16 bytes.  Does this mean that prime_len is not
the place to specify the number of bits for the shared secret key
required?  Then where to specify?  How about if I want a shared secret
key of 126 bits?  If you specify prime_len = 126, most probably
numofbyte returned from DH_compute_key equals 16, but not all the bits
constitute the bits for the shared secret key right?  I mean only 126
bits out of the 128 bits (16 bytes).  Or is it that the length of the
shared secret key in bits must be in multiple of 8 (prime_len must be
set to mutiple of 8 in the very first place)?

Thank you in advance!

Regards,
Wayne
[EMAIL PROTECTED]

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

Reply via email to