I have a client-server system, where the client is an Android app. The client and the server communicate over HTTP.
If the server/network is not available, then the client has to store the data locally in an encrypted file and needs to retry to initiate the communication later, once the server/network has recovered.
There is a business requirement that these local files have to be encrypted somehow on the client, and if the client becomes damaged, the administrator needs to be able to recover the data from the local encrypted files. The data does not need to be encrypted while sending over the network.
I would like to know is what is the best way to encrypt the data? I have a potential solution in my mind, but not sure, whether it is correct/efficient or not:
I would encrypt the files with a symmetric key and share it with the server, so it can decrypt it. In order to keep the symmetric key in secret while sending it over the network, my plan is to encrypt the symmetric key with the server's public key, so only the server will be able to recover the symmetric key.
I do not want to re-invent the wheel, so I anyone knows any better, or simpler way to store and to encrypt temp data on the client, then please, share it with me. I am also looking for the name of the design-pattern that solves such a problem if there is any.