pgpPacketSignature() публичный Метод

Returns only information on the first ID that matches the email address input.
public pgpPacketSignature ( string $pgpdata, string $email ) : array
$pgpdata string The PGP data block.
$email string An e-mail address.
Результат 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 elements: - comment: Comment - created: Signature creation (UNIX timestamp) - email: E-mail Address - key_created: Key creation (UNIX timestamp) - key_expires: Key expiration (UNIX timestamp; 0 = never expires) - key_size: Size of the key in bits - key_type: The key type (public_key or secret_key) - keyid: 16-bit hex value - micalg: The hash used to create the signature - name: Full Name
Пример #1
0
 /**
  * Returns the first matching key ID for an email address from a public
  * keyserver.
  *
  * @param string $address  The email address of the PGP key.
  *
  * @return string  The PGP key ID.
  * @throws Horde_Crypt_Exception
  */
 public function getKeyId($address)
 {
     $pubkey = null;
     /* Connect to the public keyserver. */
     $url = $this->_createUrl('/pks/lookup', array('op' => 'index', 'options' => 'mr', 'search' => $address));
     try {
         $output = $this->_http->get($url)->getBody();
     } catch (Horde_Http_Exception $e) {
         throw new Horde_Crypt_Exception($e);
     }
     if (strpos($output, '-----BEGIN PGP PUBLIC KEY BLOCK') !== false) {
         $pubkey = $output;
     } elseif (strpos($output, 'pub:') !== false) {
         $output = explode("\n", $output);
         $keyids = $keyuids = array();
         $curid = null;
         foreach ($output as $line) {
             if (substr($line, 0, 4) == 'pub:') {
                 $line = explode(':', $line);
                 /* Ignore invalid lines and expired keys. */
                 if (count($line) != 7 || !empty($line[5]) && $line[5] <= time()) {
                     continue;
                 }
                 $curid = $line[4];
                 $keyids[$curid] = $line[1];
             } elseif (!is_null($curid) && substr($line, 0, 4) == 'uid:') {
                 preg_match("/<([^>]+)>/", $line, $matches);
                 $keyuids[$curid][] = $matches[1];
             }
         }
         /* Remove keys without a matching UID. */
         foreach ($keyuids as $id => $uids) {
             $match = false;
             foreach ($uids as $uid) {
                 if ($uid == $address) {
                     $match = true;
                     break;
                 }
             }
             if (!$match) {
                 unset($keyids[$id]);
             }
         }
         /* Sort by timestamp to use the newest key. */
         if (count($keyids)) {
             ksort($keyids);
             $pubkey = $this->get(array_pop($keyids));
         }
     }
     if ($pubkey) {
         $sig = $this->_pgp->pgpPacketSignature($pubkey, $address);
         if (!empty($sig['keyid']) && (empty($sig['public_key']['expires']) || $sig['public_key']['expires'] > time())) {
             return substr($this->_pgp->getKeyIDString($sig['keyid']), 2);
         }
     }
     throw new Horde_Crypt_Exception(Horde_Crypt_Translation::t("Could not obtain public key from the keyserver."));
 }
Пример #2
0
 /**
  * Returns only information on the first ID that matches the email address
  * input.
  *
  * @param string $pgpdata  The PGP data block.
  * @param string $email    An e-mail address.
  *
  * @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 elements:
  *   - comment: Comment
  *   - created: Signature creation (UNIX timestamp)
  *   - email: E-mail Address
  *   - key_created: Key creation (UNIX timestamp)
  *   - key_expires: Key expiration (UNIX timestamp; 0 = never expires)
  *   - key_size: Size of the key in bits
  *   - key_type: The key type (public_key or secret_key)
  *   - keyid: 16-bit hex value
  *   - micalg: The hash used to create the signature
  *   - name: Full Name
  */
 public function pgpPacketSignature($pgpdata, $email)
 {
     return $this->_pgp->pgpPacketSignature($pgpdata, $email);
 }