maybe it's not so proper to ask this question here... anyway, I'm trying to use the gmp library for the implementation of DH, but the problem here I got is:
Once, when I was doing the tests to observe the output, although big values of prime and the private keys were selected:
finally I got a shared secret key which was extremely small, perhaps smaller than 10^8 in decimal...
This problem didn't show up many times, in fact, during all the observation, it appeared just once...but still, this was not so good at all.
So I wonder if there are some methods which can avoid this... Thanx a lot
The Diffie-Hellman key exchange is designed to generate a secret shared key.
By using large values of p, a and b, you ensure that the pool of potential shared keys is a very large one.
However, the actual value of the shared key can be any value within that pool. As a result, it could range from zero to (p - 1)... that's because, the Key is
G^(ab) mod p
Hence, you haven't discovered a problem here... your just seeing the instances when G^(ab)
is close in value to a multiple of p
, and hence the mod
is a low number.