Choosing Options in Diffie-Hellman

It may not be right to ask this question here ... anyway, I'm trying to use the gmp library to implement DH, but the problem here I got:

Once, when I was doing tests to observe the output, although large values โ€‹โ€‹of the simple and private keys were selected:

  • p there were more than 300 decimal digits
  • a, b about 100 characters long

Finally, I got a shared secret key that was extremely small, possibly less than 10 ^ 8 in decimal ...

This problem did not occur many times, in fact, during all the observations, it appeared only once ... but still it was not so good.

So, I am wondering if there are any methods that can avoid this ... Thanx a lot

+3
source share
2 answers

Diffie-Hellman Key Exchange is designed to create a secret shared key.

By using large values โ€‹โ€‹of p, a and b, you guarantee that the pool of potential public keys is very large.

However, the actual value of the shared key can be any value in this pool. As a result, it can vary from zero to (p - 1) ... because the key

G^(ab) mod p

Therefore, you did not find a problem here ... you just see instances when it G^(ab)is close in value to a multiple p, and therefore it modis a small number.

+2
source

D-H , , p. , , (, , ).

, ( ) 0 , . , - , , , , - , 0, , .

+1

Source: https://habr.com/ru/post/1735984/


All Articles