Horde_Crypt_Pgp::pgpPacketInformation PHP Method

pgpPacketInformation() public method

If the data block contains multiple keys, only the first is returned. To return all keys of this block, use pgpPacketInformationMultiple() instead.
See also: pgpPacketInformationMultiple()
public pgpPacketInformation ( string $pgpdata ) : array
$pgpdata string The PGP data block.
return array An array with information on the PGP data block. If an element is not present in the data block, it will likewise not be set in the array.
Array Format:
-------------
[public_key]/[secret_key] => Array
  (
    [created] => Key creation - UNIX timestamp
    [expires] => Key expiration - UNIX timestamp (0 = never expires)
    [size]    => Size of the key in bits
  )

[keyid] => Key ID of the PGP data (if available)
           16-bit hex value

[signature] => Array (
    [id{n}/'_SIGNATURE'] => Array (
        [name]        => Full Name
        [comment]     => Comment
        [email]       => E-mail Address
        [keyid]       => 16-bit hex value
        [created]     => Signature creation - UNIX timestamp
        [expires]     => Signature expiration - UNIX timestamp
        [micalg]      => The hash used to create the signature
        [sig_{hex}]   => Array [details of a sig verifying the ID] (
            [created]     => Signature creation - UNIX timestamp
            [expires]     => Signature expiration - UNIX timestamp
            [keyid]       => 16-bit hex value
            [micalg]      => The hash used to create the signature
        )
    )
)
Each user ID will be stored in the array 'signature' and have data associated with it, including an array for information on each signature that has signed that UID. Signatures not associated with a UID (e.g. revocation signatures and sub keys) will be stored under the special keyword '_SIGNATURE'.
    public function pgpPacketInformation($pgpdata)
    {
        $this->_initDrivers();
        foreach ($this->_backends as $val) {
            try {
                return $val->packetInfo($pgpdata);
            } catch (Horde_Crypt_Exception $e) {
            }
        }
        return array();
    }

Usage Example

Example #1
0
 /**
  * Sends a PGP public key to a public keyserver.
  *
  * @param string $pubkey  The PGP public key
  *
  * @throws Horde_Crypt_Exception
  */
 public function put($pubkey)
 {
     /* Get the key ID of the public key. */
     $info = $this->_pgp->pgpPacketInformation($pubkey);
     /* See if the public key already exists on the keyserver. */
     try {
         $this->get($info['keyid']);
     } catch (Horde_Crypt_Exception $e) {
         $pubkey = 'keytext=' . urlencode(rtrim($pubkey));
         try {
             $this->_http->post($this->_createUrl('/pks/add'), $pubkey, array('User-Agent: Horde Application Framework', 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($pubkey), 'Connection: close'));
         } catch (Horde_Http_Exception $e) {
             throw new Horde_Crypt_Exception($e);
         }
     }
     throw new Horde_Crypt_Exception(Horde_Crypt_Translation::t("Key already exists on the public keyserver."));
 }
All Usage Examples Of Horde_Crypt_Pgp::pgpPacketInformation