0

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?

  • 4
    Why not just use SSL/TLS? What is special about your situation? – John Wu Aug 4 '17 at 2:29
  • Websockets don't seem to play well with self-signed certs, and in this case, I am encrypting messages between two server on the same network, so I don't really need SSL if another way also works. – Arlen Beiler Aug 4 '17 at 11:06
  • 3
    If you think websockets don't play well with self signed certs then just wait to build this proposal! If you don't know how to setup your own CA maybe you shouldn't be jumping in at the deep end building your encryption stack. – symcbean Oct 3 '17 at 12:56
  • Why do you need to use self signed certs, rather than Lets Encrypt or similar? – jrtapsell Jan 1 '18 at 19:59
1

Do not roll your own cryptography

There have been multiple attacks on SSL/TLS which have been developed by the wider industry and been through scrutiny and testing. Don't build your own, stand on the shoulders of giants.

If this is an intranet project check to see if you have an internal CA and get an issued certificate from this. Don't use self signed certificates as well your weakening your own security by doing so. Anyone can issue them and then man-in-the-middle your traffic.

Also why is the IV unchanged? An IV should be regenerated each time its used.

0

From your question it appears that you already doing mutual authentication. that is a secure way to establish a mutual trust between a client and the server. please note that this is just a connection trusts, you still need to do application authentication, firewall rules, RBAC (role base access control) and IDM (identity management) in addition to your mutual auth.

  • The preshared key should establish that the client is at least authorized to connect, right? – Arlen Beiler Aug 7 '17 at 1:44
  • preshared keys if you have a symmetric keys . do it with asymmetric keys. Basically :you create the key pairs for each end. then the client encrypts with the server public key and decrypts with it private key . and the server encryps with the client public key and decryps with its private key. – Hugo R Aug 7 '17 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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