2005-10-07 18:59:50 +00:00
|
|
|
|
Installation
|
|
|
|
|
------------
|
|
|
|
|
tar xvzf gnupg-x.y.tgz
|
2005-10-25 19:37:32 +00:00
|
|
|
|
cd gnupg-x.y
|
2005-10-07 18:59:50 +00:00
|
|
|
|
phpize
|
|
|
|
|
make
|
|
|
|
|
make install
|
|
|
|
|
|
|
|
|
|
This extension requires the gpgme library, which is available at http://www.gnupg.org/(en)/download/index.html#gpgme
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Notes
|
|
|
|
|
-----
|
2005-10-18 12:40:03 +00:00
|
|
|
|
- This extension requires at least PHP 4.3.0
|
2005-10-25 19:37:32 +00:00
|
|
|
|
To use this extension in an OOP style, PHP 5 is required
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
|
|
|
|
- This is a beta version.
|
|
|
|
|
Don<6F>t use it on production systems.
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- It is now possible to specify multiple keys.
|
|
|
|
|
see "addsignkey", "addencryptkey" and "adddecryptkey"
|
|
|
|
|
|
|
|
|
|
- Verify can now handle all signature-types
|
|
|
|
|
|
2005-10-07 18:59:50 +00:00
|
|
|
|
- Only the Open_PGP protocol is currently supported.
|
|
|
|
|
This shouldn<64>t be a problem for the most people.
|
|
|
|
|
|
|
|
|
|
- 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.
|
|
|
|
|
The best would be to provide the fingerprint, whenever needed.
|
|
|
|
|
|
|
|
|
|
- The underlying lib checks for the presence of the gpg-agent.
|
|
|
|
|
If a passphrase is required for an operation, this agent is asked first.
|
|
|
|
|
To avoid this, clear the enviroment-variable GPG_AGENT_INFO (see http://de3.php.net/manual/en/function.putenv.php)
|
|
|
|
|
|
2005-10-10 17:37:19 +00:00
|
|
|
|
- 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.
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
SIG_MODE_NORMAL
|
|
|
|
|
SIG_MODE_DETACH
|
|
|
|
|
SIG_MODE_CLEAR
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
VALIDITY_UNKNOWN
|
|
|
|
|
VALIDITY_UNDEFINED
|
|
|
|
|
VALIDITY_NEVER
|
|
|
|
|
VALIDITY_MARGINAL
|
|
|
|
|
VALIDITY_FULL
|
|
|
|
|
VALIDITY_ULTIMATE
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
PROTOCOL_OpenPGP
|
|
|
|
|
PROTOCOL_CMS
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
SIGSUM_VALID
|
|
|
|
|
SIGSUM_GREEN
|
|
|
|
|
SIGSUM_RED
|
|
|
|
|
SIGSUM_KEY_REVOKED
|
|
|
|
|
SIGSUM_KEY_EXPIRED
|
|
|
|
|
SIGSUM_SIG_EXPIRED
|
|
|
|
|
SIGSUM_KEY_MISSING
|
|
|
|
|
SIGSUM_CRL_MISSING
|
|
|
|
|
SIGSUM_CRL_TOO_OLD
|
|
|
|
|
SIGSUM_BAD_POLICY
|
|
|
|
|
SIGSUM_SYS_ERROR
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
|
|
|
|
|
-------
|
2005-10-18 13:50:56 +00:00
|
|
|
|
Note: the following explanations are describing the usage of this extension in the OO style, which is only
|
2005-10-18 12:40:03 +00:00
|
|
|
|
available in PHP 5
|
|
|
|
|
To use this extension in a procedural style, simply call "gnupg_init", which returns a resource.
|
|
|
|
|
Pass this resource as the first parameter to each function.
|
|
|
|
|
In procedural style, all methods gets "gnupg_" prefixed. (setarmor becomes gnupg_setarmor)
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
$res = gnupg_init();
|
|
|
|
|
gnupg_setarmor($res,1);
|
|
|
|
|
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
|
2005-10-07 18:59:50 +00:00
|
|
|
|
- __construct()
|
|
|
|
|
sets up a new gnupg object
|
|
|
|
|
( new gnupg() )
|
|
|
|
|
|
2005-10-18 12:40:03 +00:00
|
|
|
|
- resource gnupg_init()
|
|
|
|
|
sets up a new gnupg object for procedural use and returns a resource identifier
|
|
|
|
|
|
2005-10-07 18:59:50 +00:00
|
|
|
|
- bool setarmor(int armor)
|
|
|
|
|
turn on/off armor mode
|
|
|
|
|
0 = off
|
|
|
|
|
>0 = on (default)
|
|
|
|
|
|
|
|
|
|
- bool setsignmode(int signmode)
|
|
|
|
|
sets the mode for signing operations
|
2005-10-25 19:37:32 +00:00
|
|
|
|
see the SIG_MODE_* constants
|
|
|
|
|
default is SIG_MODE_CLEAR
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
|
|
|
|
- string geterror(void)
|
|
|
|
|
returns the last errormessage
|
|
|
|
|
|
|
|
|
|
- int getprotocol(void)
|
|
|
|
|
returns the currently used pgp-protocol.
|
2005-10-25 19:37:32 +00:00
|
|
|
|
atm only PROTOCOL_OpenPGP is supported
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
|
|
|
|
- array keyinfo(string pattern)
|
|
|
|
|
returns an array with informations about all keys, that matches the given pattern
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- bool addsignkey(string key [,string passphrase])
|
|
|
|
|
adds a key for signing.
|
|
|
|
|
|
|
|
|
|
- bool addencryptkey(string key)
|
|
|
|
|
adds a key for encrypting.
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- bool adddecryptkey(string key (,string passphrase])
|
|
|
|
|
adds a key for decrypting
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- bool clearsignerkeys(void)
|
2005-10-07 18:59:50 +00:00
|
|
|
|
removes all keys which are set for signing
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- bool clearencryptkeys(void)
|
2005-10-07 18:59:50 +00:00
|
|
|
|
removes all keys which are set for encryption
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- bool cleardecryptkeys(void)
|
|
|
|
|
removes all key which are set for decryption
|
|
|
|
|
|
2005-10-07 18:59:50 +00:00
|
|
|
|
- string sign(string text)
|
|
|
|
|
signs the given test with the key, which was set with setsignerkey before
|
|
|
|
|
and returns the signed text
|
|
|
|
|
the signmode depends on gnupg_setsignmode
|
|
|
|
|
|
|
|
|
|
- string encrypt(string text)
|
|
|
|
|
encrypts the given text with the key, which was set with setencryptkey before
|
|
|
|
|
and returns the encrypted text
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- array verify(string text, string signature [, string &plaintext])
|
|
|
|
|
verifies the given text with the signature.
|
|
|
|
|
To verify a clearsigned text, pass false as signature.
|
|
|
|
|
if plaintext is passed, it is filled with the plaintext (the text without signature).
|
|
|
|
|
This only makes sense for a clearsigned text
|
2005-10-07 18:59:50 +00:00
|
|
|
|
|
|
|
|
|
- string decrypt(string enctext)
|
|
|
|
|
decrypts the given enctext
|
2005-10-25 19:37:32 +00:00
|
|
|
|
see adddecryptkey
|
2005-10-09 15:55:02 +00:00
|
|
|
|
|
|
|
|
|
- string encryptsign(string text)
|
2005-10-25 19:37:32 +00:00
|
|
|
|
encrypts and signs the given text with the keys, which are set with addencryptkey and addsignerkey
|
2005-10-09 15:55:02 +00:00
|
|
|
|
|
|
|
|
|
- array decryptverify(string text, string &plaintext)
|
2005-10-25 19:37:32 +00:00
|
|
|
|
decrypts and verifies the given text and returns information about the result in an array
|
2005-10-09 15:55:02 +00:00
|
|
|
|
the plaintext is passed into $plaintext
|
|
|
|
|
|
2005-10-15 14:44:33 +00:00
|
|
|
|
- string export(string key)
|
|
|
|
|
returns the given key
|
|
|
|
|
|
|
|
|
|
- array import(string key)
|
|
|
|
|
imports the given key and returns an array with informations about the import-process
|
|
|
|
|
|
2005-10-25 19:37:32 +00:00
|
|
|
|
- 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!
|
2005-10-09 15:55:02 +00:00
|
|
|
|
|
|
|
|
|
gnupg_keylistiterator
|
|
|
|
|
---------------------
|
|
|
|
|
This extension comes with an iterator for looping through the keyring
|
|
|
|
|
see examples/keylistiterator.php
|
|
|
|
|
if an argument is passed in the constructor, only keys that are matching this argument gets returned
|