We implemented Diffie-Hellman Key Exchange algorithm:
KeyAgreement aKeyAgree = KeyAgreement.getInstance("DH");
keyAgreement.init(myPrivateKey);
keyAgreement.doPhase(otherPublicKey)
Now we need to generate a secret to use for AES encryption. There is method generateSecret(String algorithm)
. I think I should call it with 'AES'
argument.
But for DH I use 512-bit length public keys so the secret should be 512-bit length too. But AES allows 256-bit length keys as maximum. The plain method generateSecret()
without parameters returns 512-bit DH secret. But what generateSecret(String)
does? How it transform 512-bit secret to 256/128-bit AES key?