singpolyma / openpgp-php

OpenPGP.php is a pure-PHP implementation of the OpenPGP Message Format (RFC 4880).
http://singpolyma.github.io/openpgp-php/
The Unlicense
179 stars 69 forks source link

move dependency phpseclib to v3 #119

Closed allan-simon closed 1 year ago

allan-simon commented 2 years ago

ok so basically now there's only the test Decryption::testDecryptRoundtrip failing

I'm currently investigating why because this fails

  public function testDecryptRoundtrip() {
    $m = new OpenPGP_Message(array(new OpenPGP_LiteralDataPacket("hello\n")));
    $key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/helloKey.gpg'));
    $encryptedMessage = OpenPGP_Crypt_Symmetric::encrypt($key, $m);

    foreach($key as $packet) {
     if(!($packet instanceof OpenPGP_SecretKeyPacket)) continue;
      $decryptor = new OpenPGP_Crypt_RSA($packet);
      $m2 = $decryptor->decrypt($encryptedMessage);

        foreach($m2 as $p) {
        if($p instanceof OpenPGP_LiteralDataPacket) {
          $this->assertEquals($p->data, "hello\n");
          }
        }
      }
    }

While this works :

  public function testDecryptRoundtrip() {
    $m = new OpenPGP_Message(array(new OpenPGP_LiteralDataPacket("hello\n")));
    $key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/helloKey.gpg'));
    $encryptedMessage = OpenPGP_Crypt_Symmetric::encrypt($key, $m);

    $decryptor = new OpenPGP_Crypt_RSA($key);
    $m2 = $decryptor->decrypt($encryptedMessage);

      foreach($m2 as $p) {
        if($p instanceof OpenPGP_LiteralDataPacket) {
            $this->assertEquals($p->data, "hello\n");

          }
      }   

i.e it seems that instanciating one packet at a time cause it to fails (while it was working on master)

allan-simon commented 2 years ago

@singpolyma this PR is now ready for review , all tests are green and all examples works :)

singpolyma commented 2 years ago

Sorry for the long delay. This mostly looks good to me. Just a few small questions, and maybe you could rebase down into a non-WIP commit with a message describing the high-points of the changes made?

Thanks so much.

allan-simon commented 2 years ago

no worry for the delay :) I've adressed all your comments and reword the commit message

there's only your comment about the exemple code remaining, feel free to propose a suggestion on how you want me to do the code, I will add it, after all it's your library so I will rename variable as you like :)

josh-h-90 commented 2 years ago

@singpolyma Hi - if this PR is pretty much ready to go, is there any chance it could be merged? Your library is exactly what I need but I'm locked to phpseclib 3 by other dependencies, so it would really help me out 🙏

activeingredient commented 1 year ago

@singpolyma - any update on this PR? Like other users here I need to use phpseclib v3 due to dependency constraints

kro94f commented 1 year ago

@singpolyma - any update on this PR? Like other users here I need to use phpseclib v3 due to dependency constraints

Hi, I would need this update too :)

singpolyma commented 1 year ago

Merged as 8b08661a65a2a40cda056a61e6ffa67eec5a4aa6

allan-simon commented 1 year ago

thanks a lot ! is it possible get a tagged version so that we can get back "stable" version in our composer :angel:

thanks again to have found the time to review and merge it :)

wendy0402 commented 1 year ago

hi @singpolyma is it possible to release this one as tagged version? thanks a lot for your time on maintaining this library!