Is it possible to have encryption with multiple private keys (PHP)?
That's how it done in OpenPGP (and, other systems):- you are generating secret symmetric key, which is used to encrypt the data itself;- then, this symmetric key is encrypted with Tom's key;- also, symmetric key can be encrypted with Jim's and Bob's public key, allowing them to decrypt the key and after that to decrypt the data
PHP provides a function for this - openssl_seal()
. This function takes an array of public keys, and encrypts the data so that any one of the corresponding private keys can be used to decrypt it (using openssl_open()
).
I don't know libraries in PHP. But in general the procedure is as follows:
- Data is encrypted using a symmetric key
- For each recipient, key is encrypted using the public key of recipient
- All this is saved in a PKCS#7 file structure
There should be some results when looking up "PHP and PKCS7"...