1
$\begingroup$

I have a scenario that uses RFC-3526's Diffie-Hellman Group 14 for 2048 bit key exchanges. From the document, it specifies the P (prime) value in hexadecimal value as:

  FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
  29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
  EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
  E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED
  EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D
  C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F
  83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D
  670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B
  E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9
  DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510
  15728E5A 8AACAA68 FFFFFFFF FFFFFFFF

It also specifies G (generator) as 2 which I assume in hexadecimal as:

  0x02

Assuming Alice's private key is a and Bob's private key is b. My question is when Alice and Bob exchanges their A and B where:

A = G^a mod P
B = G^b mod P

How big should I expect A and B to be in bytes?

$\endgroup$

1 Answer 1

1
$\begingroup$

$A$ and $B$ have values between 1 and $P-1$, and can in fact take on half the values in that range. As $P$ is 256 bytes long, so will $A$ and $B$. As there are approximately $2^{2047} > 256^{255}$ potential values that they can take on, we can't express them in 255 bytes.

$\endgroup$
3
  • $\begingroup$ Is it safe to encapsulate the A and B in 256 bytes or what is the safe amount of bytes I need ? $\endgroup$
    – thotheolh
    Oct 5, 2015 at 4:36
  • $\begingroup$ I meant A or B in at least 256 bytes array each. $\endgroup$
    – thotheolh
    Oct 5, 2015 at 4:37
  • $\begingroup$ @thotheolh: the obvious way to represent A and B are in arrays of 256 bytes. $\endgroup$
    – poncho
    Oct 5, 2015 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.