mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2026-01-13 11:49:34 +00:00
When the message is encrypted with multiple keys and the decryption key(s) added is not the first encrypted key, then it was failing due to invalid early failure when uid was not found in decrypted keys. This changes such behavior and just returns empty key instead in such case.
29 lines
603 B
PHP
29 lines
603 B
PHP
--TEST--
|
|
encrypt and decrypt a text with multiple keys
|
|
--SKIPIF--
|
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
|
--FILE--
|
|
<?php
|
|
require_once "gnupgt.inc";
|
|
gnupgt::import_keys();
|
|
|
|
$gpg = new gnupg();
|
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
|
$gpg->addencryptkey($fingerprint);
|
|
$gpg->addencryptkey($fingerprint2);
|
|
$gpg->addencryptkey($fingerprint3);
|
|
$enc = $gpg->encrypt($plaintext);
|
|
|
|
$gpg = new gnupg();
|
|
$gpg->adddecryptkey($fingerprint2, $passphrase2);
|
|
$ret = $gpg->decrypt($enc);
|
|
|
|
var_dump($ret);
|
|
?>
|
|
--EXPECTF--
|
|
string(7) "foo bar"
|
|
--CLEAN--
|
|
<?php
|
|
require_once "gnupgt.inc";
|
|
gnupgt::delete_key();
|
|
?>
|