mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-22 14:27:09 +00:00
updated to match recent changes
This commit is contained in:
parent
05a9819d33
commit
f89504c92e
7 changed files with 66 additions and 61 deletions
109
README
109
README
|
@ -1,7 +1,7 @@
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
tar xvzf gnupg-x.y.tgz
|
tar xvzf gnupg-x.y.tgz
|
||||||
cd gnupg-x-y
|
cd gnupg-x.y
|
||||||
phpize
|
phpize
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
@ -12,17 +12,19 @@ This extension requires the gpgme library, which is available at http://www.gnup
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
- This extension requires at least PHP 4.3.0
|
- This extension requires at least PHP 4.3.0
|
||||||
To use this extension in an OO style, PHP 5 is required
|
To use this extension in an OOP style, PHP 5 is required
|
||||||
|
|
||||||
- This is a beta version.
|
- This is a beta version.
|
||||||
Don´t use it on production systems.
|
Don´t use it on production systems.
|
||||||
|
|
||||||
|
- It is now possible to specify multiple keys.
|
||||||
|
see "addsignkey", "addencryptkey" and "adddecryptkey"
|
||||||
|
|
||||||
|
- Verify can now handle all signature-types
|
||||||
|
|
||||||
- Only the Open_PGP protocol is currently supported.
|
- Only the Open_PGP protocol is currently supported.
|
||||||
This shouldn´t be a problem for the most people.
|
This shouldn´t be a problem for the most people.
|
||||||
|
|
||||||
- only 1 key per operation is currently supported.
|
|
||||||
so you can´t add x keys for encryption.
|
|
||||||
|
|
||||||
- Whenever you provide a key to a method, you should make sure, that your given pattern is unique.
|
- Whenever you provide a key to a method, you should make sure, that your given pattern is unique.
|
||||||
Otherwise it could happen, that the wrong key is selected from the keyring.
|
Otherwise it could happen, that the wrong key is selected from the keyring.
|
||||||
The best would be to provide the fingerprint, whenever needed.
|
The best would be to provide the fingerprint, whenever needed.
|
||||||
|
@ -34,33 +36,31 @@ Notes
|
||||||
- To specify a custom location of you keyring, simply store the path in the enviroment-variable GNUPGHOME
|
- To specify a custom location of you keyring, simply store the path in the enviroment-variable GNUPGHOME
|
||||||
This should make it easy, to use this extension with the apache-user.
|
This should make it easy, to use this extension with the apache-user.
|
||||||
|
|
||||||
- Constants:
|
SIG_MODE_NORMAL
|
||||||
|
SIG_MODE_DETACH
|
||||||
|
SIG_MODE_CLEAR
|
||||||
|
|
||||||
GNUPG_SIG_MODE_NORMAL
|
VALIDITY_UNKNOWN
|
||||||
GNUPG_SIG_MODE_DETACH
|
VALIDITY_UNDEFINED
|
||||||
GNUPG_SIG_MODE_CLEAR
|
VALIDITY_NEVER
|
||||||
|
VALIDITY_MARGINAL
|
||||||
|
VALIDITY_FULL
|
||||||
|
VALIDITY_ULTIMATE
|
||||||
|
|
||||||
GNUPG_VALIDITY_UNKNOWN
|
PROTOCOL_OpenPGP
|
||||||
GNUPG_VALIDITY_UNDEFINED
|
PROTOCOL_CMS
|
||||||
GNUPG_VALIDITY_NEVER
|
|
||||||
GNUPG_VALIDITY_MARGINAL
|
|
||||||
GNUPG_VALIDITY_FULL
|
|
||||||
GNUPG_VALIDITY_ULTIMATE
|
|
||||||
|
|
||||||
GNUPG_PROTOCOL_OpenPGP
|
SIGSUM_VALID
|
||||||
GNUPG_PROTOCOL_CMS
|
SIGSUM_GREEN
|
||||||
|
SIGSUM_RED
|
||||||
GNUPG_SIGSUM_VALID
|
SIGSUM_KEY_REVOKED
|
||||||
GNUPG_SIGSUM_GREEN
|
SIGSUM_KEY_EXPIRED
|
||||||
GNUPG_SIGSUM_RED
|
SIGSUM_SIG_EXPIRED
|
||||||
GNUPG_SIGSUM_KEY_REVOKED
|
SIGSUM_KEY_MISSING
|
||||||
GNUPG_SIGSUM_KEY_EXPIRED
|
SIGSUM_CRL_MISSING
|
||||||
GNUPG_SIGSUM_SIG_EXPIRED
|
SIGSUM_CRL_TOO_OLD
|
||||||
GNUPG_SIGSUM_KEY_MISSING
|
SIGSUM_BAD_POLICY
|
||||||
GNUPG_SIGSUM_CRL_MISSING
|
SIGSUM_SYS_ERROR
|
||||||
GNUPG_SIGSUM_CRL_TOO_OLD
|
|
||||||
GNUPG_SIGSUM_BAD_POLICY
|
|
||||||
GNUPG_SIGSUM_SYS_ERROR
|
|
||||||
|
|
||||||
|
|
||||||
Methods
|
Methods
|
||||||
|
@ -76,6 +76,7 @@ $res = gnupg_init();
|
||||||
gnupg_setarmor($res,1);
|
gnupg_setarmor($res,1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- __construct()
|
- __construct()
|
||||||
sets up a new gnupg object
|
sets up a new gnupg object
|
||||||
( new gnupg() )
|
( new gnupg() )
|
||||||
|
@ -90,38 +91,37 @@ gnupg_setarmor($res,1);
|
||||||
|
|
||||||
- bool setsignmode(int signmode)
|
- bool setsignmode(int signmode)
|
||||||
sets the mode for signing operations
|
sets the mode for signing operations
|
||||||
see the GNUPG_SIG_MODE_* constants
|
see the SIG_MODE_* constants
|
||||||
default is GNUPG_SIG_MODE_CLEAR
|
default is SIG_MODE_CLEAR
|
||||||
|
|
||||||
- bool setpassphrase(string passphrase)
|
|
||||||
sets the passphrase for all next operations
|
|
||||||
|
|
||||||
- string geterror(void)
|
- string geterror(void)
|
||||||
returns the last errormessage
|
returns the last errormessage
|
||||||
|
|
||||||
- int getprotocol(void)
|
- int getprotocol(void)
|
||||||
returns the currently used pgp-protocol.
|
returns the currently used pgp-protocol.
|
||||||
atm only GNUPG_PROTOCOL_OpenPGP is supported
|
atm only PROTOCOL_OpenPGP is supported
|
||||||
|
|
||||||
- array keyinfo(string pattern)
|
- array keyinfo(string pattern)
|
||||||
returns an array with informations about all keys, that matches the given pattern
|
returns an array with informations about all keys, that matches the given pattern
|
||||||
|
|
||||||
- bool setsignerkey(string key)
|
- bool addsignkey(string key [,string passphrase])
|
||||||
sets the private key for the next sign operation.
|
adds a key for signing.
|
||||||
please note, that the given key must return only 1 result from the keyring
|
|
||||||
it should be the best to provide a fingerprint here
|
|
||||||
|
|
||||||
- bool setencryptkey(string key)
|
- bool addencryptkey(string key)
|
||||||
sets the public key for next encrypt operation.
|
adds a key for encrypting.
|
||||||
please note, that the given key must return only 1 result from the keyring
|
|
||||||
it should be the best to provide a fingerprint here
|
|
||||||
|
|
||||||
- bool clearsignerkey(void)
|
- bool adddecryptkey(string key (,string passphrase])
|
||||||
|
adds a key for decrypting
|
||||||
|
|
||||||
|
- bool clearsignerkeys(void)
|
||||||
removes all keys which are set for signing
|
removes all keys which are set for signing
|
||||||
|
|
||||||
- bool clearencryptkey(void)
|
- bool clearencryptkeys(void)
|
||||||
removes all keys which are set for encryption
|
removes all keys which are set for encryption
|
||||||
|
|
||||||
|
- bool cleardecryptkeys(void)
|
||||||
|
removes all key which are set for decryption
|
||||||
|
|
||||||
- string sign(string text)
|
- string sign(string text)
|
||||||
signs the given test with the key, which was set with setsignerkey before
|
signs the given test with the key, which was set with setsignerkey before
|
||||||
and returns the signed text
|
and returns the signed text
|
||||||
|
@ -131,19 +131,21 @@ gnupg_setarmor($res,1);
|
||||||
encrypts the given text with the key, which was set with setencryptkey before
|
encrypts the given text with the key, which was set with setencryptkey before
|
||||||
and returns the encrypted text
|
and returns the encrypted text
|
||||||
|
|
||||||
- array verify(string text [, string &plaintext])
|
- array verify(string text, string signature [, string &plaintext])
|
||||||
verifies the given clearsigned text and returns information about the result in an array
|
verifies the given text with the signature.
|
||||||
if plaintext is passed, it is filled with the plaintext (the text without signature)
|
To verify a clearsigned text, pass false as signature.
|
||||||
currently only cleartext-signatures are supported
|
if plaintext is passed, it is filled with the plaintext (the text without signature).
|
||||||
|
This only makes sense for a clearsigned text
|
||||||
|
|
||||||
- string decrypt(string enctext)
|
- string decrypt(string enctext)
|
||||||
decrypts the given enctext
|
decrypts the given enctext
|
||||||
|
see adddecryptkey
|
||||||
|
|
||||||
- string encryptsign(string text)
|
- string encryptsign(string text)
|
||||||
encrypts and signs the given text with the keys, which are set with setencryptkey and setsignerkey
|
encrypts and signs the given text with the keys, which are set with addencryptkey and addsignerkey
|
||||||
|
|
||||||
- array decryptverify(string text, string &plaintext)
|
- array decryptverify(string text, string &plaintext)
|
||||||
verifies the given clearsigned text and returns information about the result in an array
|
decrypts and verifies the given text and returns information about the result in an array
|
||||||
the plaintext is passed into $plaintext
|
the plaintext is passed into $plaintext
|
||||||
|
|
||||||
- string export(string key)
|
- string export(string key)
|
||||||
|
@ -152,6 +154,11 @@ gnupg_setarmor($res,1);
|
||||||
- array import(string key)
|
- array import(string key)
|
||||||
imports the given key and returns an array with informations about the import-process
|
imports the given key and returns an array with informations about the import-process
|
||||||
|
|
||||||
|
- array listsignatures(string key)
|
||||||
|
returns an array of informations about the keysignatures
|
||||||
|
|
||||||
|
- array deletekey(string key)
|
||||||
|
deletes a key from the keyring. use with caution!
|
||||||
|
|
||||||
gnupg_keylistiterator
|
gnupg_keylistiterator
|
||||||
---------------------
|
---------------------
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require_once (dirname(__FILE__)."/main.php");
|
require_once (dirname(__FILE__)."/main.php");
|
||||||
|
|
||||||
$gnupg -> setSignerKey ($fingerprint);
|
$gnupg -> addSignKey ($fingerprint,$passphrase);
|
||||||
$gnupg -> setPassPhrase ($passphrase);
|
|
||||||
$text = $gnupg -> sign ($mailtext);
|
$text = $gnupg -> sign ($mailtext);
|
||||||
echo $text;
|
echo $text;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -22,8 +22,7 @@ y9JHAWS6GctPfUHl1ZiS/1hq5s7xcWHsh7KTPwv449OsXIWFitnDH6jCL1sqQPjq
|
||||||
-----END PGP MESSAGE-----
|
-----END PGP MESSAGE-----
|
||||||
|
|
||||||
';
|
';
|
||||||
|
$gnupg -> addDecryptKey ($fingerprint,$passphrase);
|
||||||
$gnupg -> setPassPhrase ($passphrase);
|
|
||||||
$plaintext = $gnupg -> decrypt ($mailtext);
|
$plaintext = $gnupg -> decrypt ($mailtext);
|
||||||
|
|
||||||
echo "\n".$plaintext."\n";
|
echo "\n".$plaintext."\n";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require_once (dirname(__FILE__)."/main.php");
|
require_once (dirname(__FILE__)."/main.php");
|
||||||
|
|
||||||
$gnupg -> setEncryptKey ($fingerprint);
|
$gnupg -> addEncryptKey ($fingerprint);
|
||||||
$text = $gnupg -> encrypt ($mailtext);
|
$text = $gnupg -> encrypt ($mailtext);
|
||||||
echo $text;
|
echo $text;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
require_once (dirname(__FILE__)."/main.php");
|
require_once (dirname(__FILE__)."/main.php");
|
||||||
|
|
||||||
$gnupg -> setSignerKey ($fingerprint);
|
$gnupg -> addSignKey ($fingerprint,$passphrase);
|
||||||
$gnupg -> setEncryptKey ($fingerprint);
|
$gnupg -> addEncryptKey ($fingerprint);
|
||||||
$gnupg -> setPassPhrase ($passphrase);
|
|
||||||
$text = $gnupg -> encryptsign ($mailtext);
|
$text = $gnupg -> encryptsign ($mailtext);
|
||||||
echo $text;
|
echo $text;
|
||||||
echo "\n-------------------------\n";
|
echo "\n-------------------------\n";
|
||||||
$plaintext = false;
|
$plaintext = false;
|
||||||
|
$gnupg -> addDecryptKey ($fingerprint,$passphrase);
|
||||||
$retval = $gnupg -> decryptverify ($text,$plaintext);
|
$retval = $gnupg -> decryptverify ($text,$plaintext);
|
||||||
print_r($retval);
|
print_r($retval);
|
||||||
print_r($plaintext);
|
print_r($plaintext);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once (dirname(__FILE__)."/main.php");
|
require_once (dirname(__FILE__)."/main.php");
|
||||||
$result = $gnupg -> export($testkey);
|
$result = $gnupg -> export($fingerprint);
|
||||||
print_r($result);
|
print_r($result);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -17,7 +17,7 @@ TmrOEDxc5AihrFREY+IYPp4=
|
||||||
|
|
||||||
$plaintext = false;
|
$plaintext = false;
|
||||||
|
|
||||||
$info = $gnupg -> verify ($mailtext,$plaintext);
|
$info = $gnupg -> verify ($mailtext,false,$plaintext);
|
||||||
|
|
||||||
print_r($info);
|
print_r($info);
|
||||||
echo "\n".$plaintext."\n";
|
echo "\n".$plaintext."\n";
|
||||||
|
|
Loading…
Reference in a new issue