Open MaartenStaa opened 8 years ago
What environment are you in? What's the versions of all the key elements and I'll see what can be done. Patches welcome!
Hey @travisghansen, I'm on OS X 10.11.6. The output of gpg --version
is:
gpg (GnuPG) 2.0.30
libgcrypt 1.7.3
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA, RSA, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
I generated my key pair at https://pgpkeygen.com/, choosing RSA as the algorithm, with a key size of 4096 bits. The header of the PGP message I'm decrypting says Version: BCPG v1.46
.
@MaartenStaa ok, I'll have to try on a linux machine. Can you send over a minimal set of code that produces the issue for you? I can generate a key pair on my own with a passphrase and see how my setup behaves.
Thanks!
Sure, this is pretty much exactly what I'm doing:
// Read the file contents.
$privateKey = file_get_contents('privatekey.asc');
// Import the private key.
$gpg = new PhpGpg\PhpGpg(null, null, ['debug' => true]);
$importedKey = $gpg->importKey($privateKey);
if ($importedKey === false) {
throw new Exception('Failed to import the private key.');
}
// Select that key as the decryption key.
$gpg->addDecryptKey($importedKey->getFingerprint(), 'privatekeypassword');
// Read the encrypted message.
$encrypted = file_get_contents('pgpmessage.txt');
// Try to decrypt it, this will hang forever...
echo $gpg->decryptAndVerify($encrypted);
I met this problem too.When I add a key that has a passphrase,descryptAndVerify went wrong.it works with a key that has no passphrase.
Hi,
I'm trying to decrypt a PGP message using a private key that has a passphrase. It seems like the decrypt hangs forever.
From what I can tell, the process is waiting for the
EOF
character—if I execute the same command as the library executes in my Terminal application, paste in the encrypted PGP message, and then enter the passphrase, it also hangs. Once I pressCtrl+D
, the decryption occurs, and the decrypted contents are written toSTDOUT
.Do you have any indication if and when support for this could be added?