I have to find a solution to this problem: I have a network composed by 1 server and some client. The server has a couple of keys (public and private) and it shares a secret key with each client. My goal is to exchange a session key between the server and the clients.
I've evaluated some solutions, but I am unsure if my reasoning is correct.
I started thinking about DH, looking for a solution making it secure. And then I realised that maybe the client could randomly generate the session key and then it could send the key to the server in a secure way. In particular, my “secure way” consists in calculating the MAC of the session key using the shared secret key between client and server, and then encrypting $(MAC || session key)$ with the server's public key. In my opinion this “protocol” provides confidentiality, integrity and a sort of authentication using the secret shared key.
To conclude the protocol the server should send an ACK if the exchange has worked.
To recap:
Client:
- generate $k$ // random session key
- $t \leftarrow M(k,s)$ // calculate MAC using s(shared secret key)
- $c \leftarrow E(es , k||t)$ // Encrypt $k||t$ using server's public key
- Send $c$
Server:
- $k||t \leftarrow D(ds , c)$ // Decrypt c using server's private key
- $t´ \leftarrow M(k,s)$
- $(t == t´)$ ? OK : ERR
I'd like to know if my reasoning is correct.