I am working on an app where the goal is to upload user data, store it, do some processing on that data and present it to user when asked. We want to follow end to end encryption model where the system has no way to decrypt the data an user uploaded. I haven’t dealt with security this way before and in the presented architecture I have a few questions/concerns which I want to share with you all.
When a user registers we generate a public private key for him, private key is called master key here.
When a user adds information we encrypt it using session key. Only the data processing unit(DPU) of our system should be able to decrypt this data. Since the data size might be larger than RSA-3072 the data is first encrypted using AES-256 and then encrypted with RSA session key.
Uploaded data goes to DPU, it decrypts it, does its processing and encrypts again.
When user wants access to this information we encrypt the master key with session key and send it to DPU in order to decrypt that data.
Post decryption DPU gathers all the data requested, generates a new data key, encrypts response using this data key, encrypts data key with client’s session public key and assemble both encrypted key and response and returns it.
Client app decrypts key with client’s session private key and the response is decrypted with data key.
This model is theoretical as of now, is this do able ?
Who generates these keys(session keys, data keys), do developers(Java and Python) generate these keys and where do we store them?
Is there a library we can use to make life easy for us? Again, we don’t want our system to be able to access user data without user’s master key which is on his device. We plan on using AWS Cognito for authentication and authorization and as far as I know it doesn't provide any session keys so how can we achieve whats mentioned?
Sending private key over wire to decrypt the data, is this a good idea?
I know this is lot of information please let me know if you have more question, looking forward to suggestions/comments.