Consider the following user case:
- I have some sensitive data (eg: credit card number)
- I encrypt this data and store it in the database
Now I want to send this data to a user X, but I don't want to:
- Decrypt this data before sending
- Give user X my key used for decrypting stored data
I would like to give to user X his own private key and use one more round of encryption on the encrypted data before I send it to him.
Is there encryption algorithm which changes the decryption key with each each subsequent encryption round? Something that looks like this:
Ct = Encrypt(KeyA, Pt) # I store Ct in the database CtB = Encrypt(KeyB, Ct) # I now encrypt it with different key and # send CtB along with a private key KeyC to the user # KeyC is derived from KeyB Pt = Decrypt(KeyC, CtB) # the user can now use this KeyC to get the original data
With this, I can create different ciphertexts for each user, stopping them from sharing keys. This also means data would never be in plaintext form on the server.
Use case is only theoretical and I know there are different solutions appropriate for such situation.