This is somewhat a theoretical question, but I am also interested in whether this is possible in practice.
Assume, that there is a service that possesses a private RSA key, and can sign any data with that key, after the key is unlocked with a password. Something similar to the ssh agent. Once unlocked, you can talk to this service through a protocol, but don't have access to the (unlocked) private key in any way. You hand over the data to sign to the service, and it returns the signature. And you also have the corresponding public key.
Now, the question is, can this service be used for encryption and decryption? I am thinking of something like this for encryption:
- You unlock the service with a password.
- You have plaintext you want to encrypt.
- You generate a random blob of data.
- You ask the service to sign this data. You verify the signature using the public key.
- You treat the signature (or some hash of it) as a key for symmetric encryption/decryption, e.g. as an AES key.
- You encrypt the plaintext with this key, and get a secret.
- You store
- the secret, and
- the random data you used to create the signature.
When you want to decrypt a secret:
- You unlock the service with a password.
- You take the stored random data.
- You ask the service to sign it with its private key. You verify the signature using the public key.
- You treat the signature (or some hash of it) as an AES key.
- You decrypt the secret with the AES key.
I admit, that I don't know much about cryptography, but to me, this seems like a good (=secure) algorithm for solving the problem, at least in theory. Am I missing something? Is this already known/used somewhere in practice?