In working on a piece of intranet software, I needed to implement security between the client and the server. I would like to know whether this is a secure way to do this or if there are significant holes.
The client and server come up with a shared secret using ECDH (secp521r1) key exchange. A new shared secret is negotiated for every request.
The encryption key is generated using Password-Based Key Derivation Function 2 (PBKDF2). I use the shared secret as the password, a preshared key as the salt (to only allow authorized clients to connect), 100,000 iterations, and the hash function is SHA512.
After that the request data is encrypted with aes-128-gcm, using the encryption key and an IV of 12 zeros. The response is encrypted using the same key. The server then discards the key so it cannot be used twice.
Is this a good implementation? Are there other better ways to do this? Is there something I am missing?