I have a need for the following encryption properties: $f(g(v_\text{plaintext}) = v_\text{ciphertext}$ needs to be decryptable by $f^{-1}(g^{-1}(v_\text{ciphertext}))$ and $f$ and $g$ need to be different. The idea goes like this.
A user is going to encrypt some plaintext (DB credentials) with a private key they control. $g(v_\text{plaintext})$
A server is going to encrypt $g(v_\text{plaintext})$ with a private key that it controls. $f(g(v_\text{plaintext})) = v_\text{ciphertext}$.
Sometime in the future the server will ask the user to decrypt using their private key and send the result back to the server. $g^{-1}(v_\text{ciphertext})$.
Server will take the result from the previous step and decrypt the ciphertext: $f^{-1}(g^{-1}(v_\text{ciphertext})) = v_\text{plaintext}$.
The reason that I find this procedure desirable is that:
- the DB credentials ($v_\text{plaintext}$) are never sent over the wire unencrypted
- the owner of the DB credentials is able to encrypt on their side (client-side using $g$).
Anyone know of a set of cryptographic primatives that would get me there?