Replacing GPG with OpenSSL for public key file encryption
| From: | Emil Guy | Date: | Thu, 02 Oct 2014 14:53:43 +0000 |
| Subject: | Replacing GPG with OpenSSL for public key file encryption | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-323881@lists.php.net to get a copy of this message | ||
Hello!
I'm trying to get rid of using GPG for encrypting some files since GPG
requires exec for the pear crypt library and a GPG install. I've made a
test implementation that uses OpenSSL public private keys generated like
this:
openssl genrsa -des3 -out priv.pem 2048
openssl rsa -in priv.pem -out pub.pem -outform PEM -pubout
And then I encrypt the data by looping through it like this (where chunk is
the length of the key used):
while($data) {
$chunk = substr(data, [...]);
[...]
openssl_public_encrypt($chunk, $encryptedBlock, $publicKey);
$output .= $encryptedBlock;
}
How is this implementation security-wise compared to gpg for encrypting
files? I don't need to keep out the NSA, but I want the files to be hard to
decrypt for an intruder. Any help is highly appreciated. Thanks!
Regards,
Emil