DH_generate_key generates wrong public key size?

2005-04-01 Thread Bob Bradley
I'm seeing DH_generate_key generate a public key that is 1 byte less than expected (127 instead of 128 bytes for a 1024-bit key), but only sporadically (about every 200-300 tries). I've written the following test case that always fails for me in less than 300 iterations. I've only included error ch

Re: DH_generate_key generates wrong public key size?

2005-04-01 Thread Nils Larsch
Bob Bradley wrote: I'm seeing DH_generate_key generate a public key that is 1 byte less than expected (127 instead of 128 bytes for a 1024-bit key), but only sporadically (about every 200-300 tries). I've written the following test case that always fails for me in less than 300 iterations. I've onl

Re: DH_generate_key generates wrong public key size?

2005-04-01 Thread Bob Bradley
On 4/1/05 1:57 AM, "Nils Larsch" <[EMAIL PROTECTED]> wrote: > the dh public key is the result of g**k mod p (k is the private key) > operation and hence may have less than BN_num_bytes(p) bytes (approx. > every 256 key should have <= 127 bytes). I didn't realize that. Thanks for the explanation.

Re: DH_generate_key generates wrong public key size?

2005-04-01 Thread Nils Larsch
Bob Bradley wrote: On 4/1/05 1:57 AM, "Nils Larsch" <[EMAIL PROTECTED]> wrote: the dh public key is the result of g**k mod p (k is the private key) operation and hence may have less than BN_num_bytes(p) bytes (approx. every 256 key should have <= 127 bytes). I didn't realize that. Thanks for the

Re: DH_generate_key generates wrong public key size?

2005-04-01 Thread Bob Bradley
On 4/1/05 8:20 AM, "Nils Larsch" <[EMAIL PROTECTED]> wrote: > this of course reduces the key space for the private key, but if you > really need a fixed size public key you need to do it. Would it reduce security or be unsafe to simply prepend zero bytes after calling BN_bn2bin to make it fill 12

Re: DH_generate_key generates wrong public key size?

2005-04-02 Thread Nils Larsch
Bob Bradley wrote: On 4/1/05 8:20 AM, "Nils Larsch" <[EMAIL PROTECTED]> wrote: this of course reduces the key space for the private key, but if you really need a fixed size public key you need to do it. Would it reduce security or be unsafe to simply prepend zero bytes after calling BN_bn2bin to

Re: DH_generate_key generates wrong public key size?

2005-04-02 Thread Bob Bradley
On 4/2/05 12:51 AM, "Nils Larsch" <[EMAIL PROTECTED]> wrote: > ... BN_bin2bn should correctly handle leading zeros in binary input Okay, great. Thanks for all the help. __ OpenSSL Project http://