php-gnupg/tests/gnupg_oo_decrypt_multi_key.phpt
Jakub Zelenka 74993ff4a2
Fix #32: Decryption of message encrypted with multiple keys (#55)
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.
2025-05-20 18:23:58 +02:00

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();
?>