Search code examples
javasecuritykeytheorydiffie-hellman

continued encryption with diffie-hellman shared key


I'm currently working on a protocol, which uses Diffie-Hellman for an key exchange. I receive a packet, which consists of an aes-128 encrypted part and a 128 Bit DH Public Key.

In a very last step in the protocol, the aes key is sent to another peer in the network. This aes-key should be encrypted with a cipher using a 128 bit strong secretkey.

I plan to use Blowfish (can also be another cipher, doesn't really matter for the problem)

Now to encrypt the aes-key, with lets say blowfish, I have to build a secretkey for the encryption with a class called SecretKeySpec (I'm using javax.crypto stuff), which takes an byteArray in the constructor to build the secretKey.

The sharedkey from DH is a 128 Bit BigInteger. Well, now I can interpret my shared-key as a byteArray (wich gives me still 128 Bit in 16Bytes [where the numbers are interpreted as frames of 8 Bit data])

So my question is, how strong is my key really?

Is there any impact because I only use numbers as input for the byteArray (so does this limit the keyspace in any way?)

I think this is not the case, but I'm not 100% sure. Maybe someone can do the math and proof me right or wrong.

If I'm wrong what keysize for the shared key give me piece of mind to finally get to the 128Bit SecretKey for the encryption?


Solution

  • The Crypto++ website suggests using a minimum p of 3072 bits (or 256 bits for an ECC implementation) to transport a 128 bit AES key.

    You might wish to study the references provided at http://www.keylength.com/en/compare/ for further information about comparing key lengths among different algorithms.