I designed a custom handshake between 2 entities $\rm C$ (client) and $\rm S$ (server) which should meet the following requirements:
Requirements:
The handshake should make:
- $\rm S$ know who is $\rm C$,
- $\rm C$ make sure that he is talking to $\rm S$,
... without letting anyone who is listening the communication line know:
- what is $\rm S$'s public key,
- what is $\rm C$'s public key,
- whether or not a specific $\rm C$ with a well known public key is in the contact list of a specific $\rm S$ with a well known public key.
My handshake:
$\rm C$ opens a connection to $\rm S$.
$\rm C$ sends a random cipher's symmetric key $K_1$ to $\rm S$, encrypted using $\rm S$'s public key. Then $\rm C$ uses $K_1$ in a symmetric cipher to encrypt all the following data:
- timestamp,
- 2 first bytes of $\rm C$'s public key.
$\rm C$'s signature, where the hash is computed from:
- $K_1$,
- timestamp,
- $\rm S$'s public key.
$\rm S$ receives it and decodes it using his private key. If the timestamp is too far from now or If the signature cannot be verified then close the connection. Otherwise the message is considered valid, then $\rm S$ sends back the following concatenated message to $\rm C$, encrypted using $\rm C$'s public key:
- a random cipher's symmetric key $K_2$.
- a hash of $\rm C$'s signature from the previously received message.
$\rm C$ takes $K_2$ and verifies that the hash is from the signature that he previously sent. If it doesn't match he closes the connection.
Both $\rm C$ and $\rm S$ compute $K$ by combining $K_1$ and $K_2$ together. They now have a shared secret that they will use to encrypt and decrypt any further message via a symmetric encryption algorithm.
Notes:
- $\rm C$ and $\rm S$ know each other's public key.
- the handshake description is also available on this page.
Question: I would like to know if my handshake meets its requirements.
EDIT:
- The asymmetric encryption algorithm used is RSA with 4096 bits keys.
- The symmetric encryption algorithm used is AES-256.
- The shared secret algorithm used to combine $K_1$ and $K_2$ is Diffie-Hellman.