Good day.
The goal is to encrypt communication between the server and the Android client.
The order of action is:
1) The client connects and starts a php session.
2) The server generates / gets a pair of keys, sends the public key to the client.
3) The client, in turn, generates another pair of keys, and sends its public key to the server.
4) Further communication is carried out via this secure channel through POSTs and GETs.
Question: how often is it worth generating new keys? The server and the client can create new keys every time the session starts, but key generation is a complicated and expensive operation, especially when the server is under heavy load. On the other hand, storing private and public keys in a database and on a client device is not too secure.
I will be glad to any answers, tips and links on the topic of competent design of secure client-server systems. I ask you to point out the mistakes and delusions in my reflections, and forgive me for stupidity and naivety.
Thank.