2006-05-18 19:32:32 +00:00
|
|
|
--TEST--
|
|
|
|
encryptsign and decryptverify a text
|
2018-05-17 19:15:14 +00:00
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
2006-05-18 19:32:32 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2018-05-17 19:15:14 +00:00
|
|
|
require_once "gnupgt.inc";
|
|
|
|
gnupgt::import_key();
|
|
|
|
|
2006-11-03 12:39:53 +00:00
|
|
|
$gpg = gnupg_init();
|
|
|
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
|
|
|
gnupg_addencryptkey($gpg, $fingerprint);
|
|
|
|
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
|
|
|
$enc = gnupg_encryptsign($gpg, $plaintext);
|
2006-05-18 19:32:32 +00:00
|
|
|
|
|
|
|
$gpg = NULL;
|
|
|
|
$plaintext = false;
|
|
|
|
|
2006-11-03 12:39:53 +00:00
|
|
|
$gpg = gnupg_init();
|
|
|
|
gnupg_adddecryptkey($gpg, $fingerprint, $passphrase);
|
|
|
|
$ret = gnupg_decryptverify ($gpg, $enc, $plaintext);
|
2006-05-18 19:32:32 +00:00
|
|
|
|
|
|
|
var_dump($ret);
|
|
|
|
var_dump($plaintext);
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
array(1) {
|
|
|
|
[0]=>
|
|
|
|
array(5) {
|
|
|
|
["fingerprint"]=>
|
2019-09-29 16:14:01 +00:00
|
|
|
string(40) "2DF0DD02DC9B70B7F64F572E669E775E0A6284B3"
|
2006-05-18 19:32:32 +00:00
|
|
|
["validity"]=>
|
|
|
|
int(0)
|
|
|
|
["timestamp"]=>
|
|
|
|
int(%d)
|
|
|
|
["status"]=>
|
|
|
|
int(0)
|
|
|
|
["summary"]=>
|
|
|
|
int(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string(7) "foo bar"
|
2018-05-17 19:15:14 +00:00
|
|
|
--CLEAN--
|
|
|
|
<?php
|
|
|
|
require_once "gnupgt.inc";
|
|
|
|
gnupgt::delete_key();
|
|
|
|
?>
|