mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-12-23 02:11:40 +00:00
more tests
removed examples
This commit is contained in:
parent
f98e3c57e4
commit
ba4ad8960b
33 changed files with 478 additions and 121 deletions
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$gnupg -> addSignKey ($fingerprint,$passphrase);
|
||||
$text = $gnupg -> sign ($mailtext);
|
||||
echo $text;
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$mailtext = '
|
||||
-----BEGIN PGP MESSAGE-----
|
||||
Version: GnuPG v1.2.5 (GNU/Linux)
|
||||
|
||||
hQIOA8VdBLDv7dV1EAgAtEMlQ1K/iXYIgPLiojfEhaTOvyEhDjZZ/9Gr5IQ/UvXZ
|
||||
nQW0KYuIpYB8Oe7SC/n3NDqcLuS9Q8GMBgcQjLQKIjEtu0I2xcXATjpNEooKgSqp
|
||||
KxWtoobsPNkCrVyK1dEH911vr/sGcjpiX5L0dYMldq5So45979AaUirpX4pmu7ay
|
||||
1YB81iciq3/KmR+ocOMWzT+v6WJFB0rXSoFc1WiwSiw6TcotXdZA9hAllwaRuBMQ
|
||||
2Vct7/F+dTqZRD4mBt8WiksJFvPm8bb+5p4QVt9eVkuxJv8w7mROVEDFYsDeh8GG
|
||||
FxEzYBr1yv+9DG3Hkmtqk6Ns6VZH4roB9RdwKU2XlggAq/6DiqYnuV9+xuKYvF1G
|
||||
+8X/MWOg2Di6xqe8GqujGmq3ztFb5wNDc+Rp4aW9YgbHHLf9VFc21QAEozjfTe6S
|
||||
hQbcY02UrkJ8bQ4LigWtNnvM3XzQw/J+LQFYij/QogvO3inNVMFd+/WEoJNZ7EMB
|
||||
sE68F32hPsumPhpheyfD19SX2Nejrlaqa4qYCuhNUR0luI4Xti6ymX3jAXJsozNa
|
||||
zP/Ho1T/fCwohyJYaOe7S+u99fcVrchmGP77qiPNQUMsY1LthY1LMihq+0Kd+ORM
|
||||
Hc7HHGvV8/ufIB9WFWNOhQW+gOfIfGzQidLaw+AI7ar68FciKwce9aX99yffVx3U
|
||||
y9JHAWS6GctPfUHl1ZiS/1hq5s7xcWHsh7KTPwv449OsXIWFitnDH6jCL1sqQPjq
|
||||
3pNJXapRMRsyKi60i8jV+KIDl0O0Q9S6eEY=
|
||||
=Rb4q
|
||||
-----END PGP MESSAGE-----
|
||||
|
||||
';
|
||||
$gnupg -> addDecryptKey ($fingerprint,$passphrase);
|
||||
$plaintext = $gnupg -> decrypt ($mailtext);
|
||||
|
||||
echo "\n".$plaintext."\n";
|
||||
?>
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$gnupg -> addEncryptKey ($fingerprint);
|
||||
$text = $gnupg -> encrypt ($mailtext);
|
||||
echo $text;
|
||||
?>
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$gnupg -> addSignKey ($fingerprint,$passphrase);
|
||||
$gnupg -> addEncryptKey ($fingerprint);
|
||||
$text = $gnupg -> encryptsign ($mailtext);
|
||||
echo $text;
|
||||
echo "\n-------------------------\n";
|
||||
$plaintext = false;
|
||||
$gnupg -> addDecryptKey ($fingerprint,$passphrase);
|
||||
$retval = $gnupg -> decryptverify ($text,$plaintext);
|
||||
print_r($retval);
|
||||
print_r($plaintext);
|
||||
?>
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
$result = $gnupg -> export($fingerprint);
|
||||
print_r($result);
|
||||
?>
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$keyinfo = $gnupg -> keyinfo ($fingerprint);
|
||||
print_r($keyinfo)
|
||||
?>
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$iterator = new gnupg_keylistiterator("php.net");
|
||||
foreach($iterator as $key => $value){
|
||||
echo $key." -> ".$value."\n";
|
||||
}
|
||||
?>
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
dl("gnupg.so");
|
||||
|
||||
$fingerprint = "8660281B6051D071D94B5B230549F9DC851566DC";
|
||||
$mailtext = "Test test Test TeSt";
|
||||
$passphrase = "incorrect";
|
||||
|
||||
$gnupg = new gnupg ();
|
||||
?>
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
|
||||
$mailtext = '
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
Test test Test TeSt
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.2.5 (GNU/Linux)
|
||||
|
||||
iD8DBQFDRWw6BUn53IUVZtwRAoVKAJ9P0E0PKcpEuWeHNxgZRbctpETbGQCgv0Nq
|
||||
TmrOEDxc5AihrFREY+IYPp4=
|
||||
=933C
|
||||
-----END PGP SIGNATURE-----
|
||||
';
|
||||
|
||||
$plaintext = false;
|
||||
|
||||
$info = $gnupg -> verify ($mailtext,false,$plaintext);
|
||||
|
||||
print_r($info);
|
||||
echo "\n".$plaintext."\n";
|
||||
?>
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
import a new key into the keyring
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
encrypt and decrypt a text
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
encryptsign and decryptverify a text
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
export a key
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
get keyinfo
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
list signatures
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with sigmode SIG_MODE_CLEAR
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH and without armored output
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL and without armored output
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
14
tests/gnupg_oo_zzz_deletekey.phpt
Normal file
14
tests/gnupg_oo_zzz_deletekey.phpt
Normal file
|
@ -0,0 +1,14 @@
|
|||
--TEST--n
|
||||
delete a key from the keyring
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = new gnupg();
|
||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
||||
$ret = $gpg -> deletekey($fingerprint,true);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
33
tests/gnupg_res_0001_import.phpt
Normal file
33
tests/gnupg_res_0001_import.phpt
Normal file
|
@ -0,0 +1,33 @@
|
|||
--TEST--n
|
||||
import a new key into the keyring
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
@unlink (dirname(__FILE__)."/pubring.gpg");
|
||||
@unlink (dirname(__FILE__)."/secring.gpg");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_import($gpg, $testkey);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(9) {
|
||||
["imported"]=>
|
||||
int(1)
|
||||
["unchanged"]=>
|
||||
int(0)
|
||||
["newuserids"]=>
|
||||
int(0)
|
||||
["newsubkeys"]=>
|
||||
int(0)
|
||||
["secretimported"]=>
|
||||
int(1)
|
||||
["secretunchanged"]=>
|
||||
int(0)
|
||||
["newsignatures"]=>
|
||||
int(0)
|
||||
["skippedkeys"]=>
|
||||
int(0)
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
}
|
20
tests/gnupg_res_encrypt.phpt
Normal file
20
tests/gnupg_res_encrypt.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
encrypt and decrypt a text
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_addencryptkey($gpg, $fingerprint);
|
||||
$enc = gnupg_encrypt($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
gnupg_adddecryptkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_decrypt ($gpg, $enc);
|
||||
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(7) "foo bar"
|
38
tests/gnupg_res_encryptsign.phpt
Normal file
38
tests/gnupg_res_encryptsign.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--
|
||||
encryptsign and decryptverify a text
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_addencryptkey($gpg, $fingerprint);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$enc = gnupg_encryptsign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
$plaintext = false;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
gnupg_adddecryptkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_decryptverify ($gpg, $enc, $plaintext);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(5) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["validity"]=>
|
||||
int(0)
|
||||
["timestamp"]=>
|
||||
int(%d)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["summary"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
string(7) "foo bar"
|
|
@ -1,7 +1,16 @@
|
|||
--TEST--
|
||||
export a key
|
||||
--FILE--
|
||||
<?php
|
||||
require_once (dirname(__FILE__)."/main.php");
|
||||
$testkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.2.6 (GNU/Linux)
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_export($gpg, $fingerprint);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(1336) "-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.3 (GNU/Linux)
|
||||
|
||||
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
|
||||
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
|
||||
|
@ -13,18 +22,15 @@ fXHfBACl3EWgvLhVBo5ExZbrtlOA2q0x9UGhhNaSkeBWBr2qDeZErQjMTO0+viaN
|
|||
/SX0zxeWtM3z06rkUHd1DKORDRM5R7shBTv9/Quojn0gbYbOem+e1mlCe27TRxcP
|
||||
yeIKk00PqbVuff9QlK9GqKEWGzsEXCmxZ160Dul3CGlf/vQZHbQkdGVzdGtleSAo
|
||||
dGVzdGtleSkgPHRlc3RAZXhhbXBsZS5uZXQ+iF4EExECAB4FAkNQAKwCGwMGCwkI
|
||||
BwMCAxUCAwMWAgECHgECF4AACgkQLpbxQbPdKy58pwCfWttBa4bojGc+oVQbmx43
|
||||
lMMTuP8An3INHAxsm0DkdhfergYi2f6BNMPmuQENBENQAK0QBACNXzJQG4NHUJqL
|
||||
BwMCAxUCAwMWAgECHgECF4AACgkQLpbxQbPdKy58pwCcDz9qEBEVt1gcKCwNay0f
|
||||
m4vLqCkAn1P0KV1giECUVXBuZ5YUndDB1QqtuQENBENQAK0QBACNXzJQG4NHUJqL
|
||||
PImezbl+ii+93MjMo8LpSlv9Np5ruWIKtxuqmVEe4k+r1DDmSl8hppifpRtx2hef
|
||||
bDTl8Tdf5MNGvf5JE3AHYUehZ+ldjgYCOZ53fJDgKV65ZidQSGGXsRcyE7SHgMQ6
|
||||
rTL92PA2IQmkcf9xkg6xM2h55UusMwADBQP9EGQ0BAdWRUtA21/cR6F+t97KZnVS
|
||||
et225UYv8azv8p8cK4R1lrZXChFadK9Kt+/My4HAx7J7zd1IPuKQ0QniuvuLT3Mw
|
||||
z19B7FGXaJenwTw0P1ihtmSPq9GAOkOA4ZPhHLl9OFwIeAZzjfshRfvm0haO3vwl
|
||||
xdjhwxyJ/a/JEF2ISQQYEQIACQUCQ1AArQIbDAAKCRAulvFBs90rLrBkAJ9rzjkU
|
||||
UZk4JQ9uw4sme5lJxDBYKQCgwW+pIlvGpU8C4CYSrTK/ySUNUnE=
|
||||
=ah4i
|
||||
xdjhwxyJ/a/JEF2ISQQYEQIACQUCQ1AArQIbDAAKCRAulvFBs90rLrBkAJ9tScp6
|
||||
drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI=
|
||||
=twR+
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
';
|
||||
$result = $gnupg -> import($testkey);
|
||||
print_r($result);
|
||||
?>
|
||||
"
|
97
tests/gnupg_res_keyinfo.phpt
Normal file
97
tests/gnupg_res_keyinfo.phpt
Normal file
|
@ -0,0 +1,97 @@
|
|||
--TEST--n
|
||||
get keyinfo
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_keyinfo($gpg, $fingerprint);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(8) {
|
||||
["disabled"]=>
|
||||
bool(false)
|
||||
["expired"]=>
|
||||
bool(false)
|
||||
["revoked"]=>
|
||||
bool(false)
|
||||
["is_secret"]=>
|
||||
bool(false)
|
||||
["can_sign"]=>
|
||||
bool(true)
|
||||
["can_encrypt"]=>
|
||||
bool(true)
|
||||
["uids"]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(6) {
|
||||
["name"]=>
|
||||
string(7) "testkey"
|
||||
["comment"]=>
|
||||
string(7) "testkey"
|
||||
["email"]=>
|
||||
string(16) "test@example.net"
|
||||
["uid"]=>
|
||||
string(36) "testkey (testkey) <test@example.net>"
|
||||
["revoked"]=>
|
||||
bool(false)
|
||||
["invalid"]=>
|
||||
bool(false)
|
||||
}
|
||||
}
|
||||
["subkeys"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(11) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["keyid"]=>
|
||||
string(16) "2E96F141B3DD2B2E"
|
||||
["timestamp"]=>
|
||||
int(1129316524)
|
||||
["expires"]=>
|
||||
int(0)
|
||||
["is_secret"]=>
|
||||
bool(false)
|
||||
["invalid"]=>
|
||||
bool(false)
|
||||
["can_encrypt"]=>
|
||||
bool(false)
|
||||
["can_sign"]=>
|
||||
bool(true)
|
||||
["disabled"]=>
|
||||
bool(false)
|
||||
["expired"]=>
|
||||
bool(false)
|
||||
["revoked"]=>
|
||||
bool(false)
|
||||
}
|
||||
[1]=>
|
||||
array(10) {
|
||||
["keyid"]=>
|
||||
string(16) "BFE8D07DDACDEAC8"
|
||||
["timestamp"]=>
|
||||
int(1129316525)
|
||||
["expires"]=>
|
||||
int(0)
|
||||
["is_secret"]=>
|
||||
bool(false)
|
||||
["invalid"]=>
|
||||
bool(false)
|
||||
["can_encrypt"]=>
|
||||
bool(true)
|
||||
["can_sign"]=>
|
||||
bool(false)
|
||||
["disabled"]=>
|
||||
bool(false)
|
||||
["expired"]=>
|
||||
bool(false)
|
||||
["revoked"]=>
|
||||
bool(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
tests/gnupg_res_listsignatures.phpt
Normal file
35
tests/gnupg_res_listsignatures.phpt
Normal file
|
@ -0,0 +1,35 @@
|
|||
--TEST--n
|
||||
list signatures
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_listsignatures($gpg, $fingerprint);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["testkey (testkey) <test@example.net>"]=>
|
||||
array(1) {
|
||||
["2E96F141B3DD2B2E"]=>
|
||||
array(8) {
|
||||
["uid"]=>
|
||||
string(36) "testkey (testkey) <test@example.net>"
|
||||
["name"]=>
|
||||
string(7) "testkey"
|
||||
["email"]=>
|
||||
string(16) "test@example.net"
|
||||
["comment"]=>
|
||||
string(7) "testkey"
|
||||
["expires"]=>
|
||||
int(0)
|
||||
["revoked"]=>
|
||||
bool(false)
|
||||
["expired"]=>
|
||||
bool(false)
|
||||
["invalid"]=>
|
||||
bool(false)
|
||||
}
|
||||
}
|
||||
}
|
38
tests/gnupg_res_sign_clear.phpt
Normal file
38
tests/gnupg_res_sign_clear.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with sigmode SIG_MODE_CLEAR
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_CLEAR);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$ret = gnupg_verify($gpg, $ret, false, $tmp);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($tmp);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(5) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["validity"]=>
|
||||
int(0)
|
||||
["timestamp"]=>
|
||||
int(%d)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["summary"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
string(8) "foo bar
|
||||
"
|
37
tests/gnupg_res_sign_detach.phpt
Normal file
37
tests/gnupg_res_sign_detach.phpt
Normal file
|
@ -0,0 +1,37 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$ret = gnupg_verify($gpg,$plaintext, $ret);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(5) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["validity"]=>
|
||||
int(0)
|
||||
["timestamp"]=>
|
||||
int(%d)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["summary"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
string(7) "foo bar"
|
38
tests/gnupg_res_sign_detach_nonarmor.phpt
Normal file
38
tests/gnupg_res_sign_detach_nonarmor.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH and without armored output
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setarmor($gpg, 0);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$ret = gnupg_verify($gpg, $plaintext, $ret);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(5) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["validity"]=>
|
||||
int(0)
|
||||
["timestamp"]=>
|
||||
int(%d)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["summary"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
string(7) "foo bar"
|
38
tests/gnupg_res_sign_normal.phpt
Normal file
38
tests/gnupg_res_sign_normal.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg,$plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$plaintext = false;
|
||||
$ret = gnupg_verify($gpg, $ret, false, $plaintext);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(5) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["validity"]=>
|
||||
int(0)
|
||||
["timestamp"]=>
|
||||
int(%d)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["summary"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
string(7) "foo bar"
|
38
tests/gnupg_res_sign_normal_noarmor.phpt
Normal file
38
tests/gnupg_res_sign_normal_noarmor.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL and without armored output
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setarmor($gpg, 0);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$plaintext = false;
|
||||
$ret = gnupg_verify($gpg, $ret, false, $plaintext);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(5) {
|
||||
["fingerprint"]=>
|
||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||
["validity"]=>
|
||||
int(0)
|
||||
["timestamp"]=>
|
||||
int(%d)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["summary"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
string(7) "foo bar"
|
12
tests/gnupg_res_zzz_deletekey.phpt
Normal file
12
tests/gnupg_res_zzz_deletekey.phpt
Normal file
|
@ -0,0 +1,12 @@
|
|||
--TEST--n
|
||||
delete a key from the keyring
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_deletekey($gpg, $fingerprint,true);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
Loading…
Reference in a new issue