Diffie-Hellman questions

Raul Acevedo <[email protected]> Mon, 25 Feb 2019 11:20:33 -0800
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <CAO_+-bxcyMGxL-+zpzR-9m4nii1J-MSXcQAm18C7X8ZK_HP4iA@mail.gmail.com>
I want to use DH to encrypt data between two parties using BCFIPS and with
forward secrecy. The parties have X509 publicly signed certificates to
identify themselves to each other, similar to TLS.

There are a couple approaches I'm considering:

1. Generate new ephemeral EC keys every time, and use ECCDH Basic
Agreement. The public keys are exchanged by signing with their respective
long term signing keys. No key material/KDF needed.

2. Generate ephemeral keys derived from their long term certificate keys,
throw in key material + KDF, and then generate secret. Again sign the
public key exchange with x509.

My two questions are:

1. Is one approach inherently better than the other? #1 is simpler; #2 may
be more secure because the ephemeral keys are derived from the x509 certs.

2. How is the key material shared? It's required by both parties, so is it
shared publicly along with the public keys? What criteria is there for how
to generate this key material in the first place? Random bytes? Of what
length? Static string enough?

Any help greatly appreciated. Thanks,

Raul