Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot decrypt messages encoded with GPG #133

Open
bouboot82 opened this issue Apr 23, 2023 · 0 comments
Open

Cannot decrypt messages encoded with GPG #133

bouboot82 opened this issue Apr 23, 2023 · 0 comments

Comments

@bouboot82
Copy link

bouboot82 commented Apr 23, 2023

Hi,

Every time I try to run the decryption algorithm on messages encoded with gpg (the key pairs have been generated in gpg as well), I get the following errors :

Severity: Warning

Message: Undefined array key "e"

Filename: lib/openpgp_crypt_rsa.php

Line Number: 250

Backtrace:

File: /OpenPGP-PHP/lib/openpgp_crypt_rsa.php
Line: 250
Function: _error_handler

...

And

A PHP Error was encountered
Severity: Warning

Message: Undefined array key "d"

Filename: lib/openpgp_crypt_rsa.php

Line Number: 251

Backtrace:

File: OpenPGP-PHP/lib/openpgp_crypt_rsa.php
Line: 251
Function: _error_handler

The first and the second errors are triggered when using the armored version of the key and the message.
The second one only is triggered when using the unarmored versions.

The code used for the ASCII version is :

        $keyEncrypted = OpenPGP_Message::parse(OpenPGP::unarmor(file_get_contents(dirname(__FILE__) . '/test.key'), 'PGP PRIVATE KEY BLOCK'));
        foreach($keyEncrypted as $p) {
	        if(!($p instanceof OpenPGP_SecretKeyPacket)) continue;

	        $key = OpenPGP_Crypt_Symmetric::decryptSecretKey('Passphrase', $p);

	        $msg = OpenPGP_Message::parse(OpenPGP::unarmor(file_get_contents(dirname(__FILE__) . '/testArmored.txt'), 'PGP MESSAGE'));

	        $decryptor = new OpenPGP_Crypt_RSA($key);
	        $decrypted = $decryptor->decrypt($msg);
        }

For the unarmored version

        $key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/test.gpg'));
        $decryptor = new OpenPGP_Crypt_RSA($key);
        $decrypted = $decryptor->decrypt(file_get_contents(dirname(__FILE__) . '/test.asc'));  

The files used for the test are attached.

Thanks in advance
Archive.zip

@bouboot82 bouboot82 changed the title Connot decrypt messages encoded with GPG Cannot decrypt messages encoded with GPG Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant