示例#1
0
 function __construct($data = NULL, $key_algorithm = NULL, $hash_algorithm = NULL)
 {
     parent::__construct();
     $this->version = 4;
     // Default to version 4 sigs
     if (is_string($this->hash_algorithm = $hash_algorithm)) {
         $this->hash_algorithm = array_search($this->hash_algorithm, self::$hash_algorithms);
     }
     if (is_string($this->key_algorithm = $key_algorithm)) {
         $this->key_algorithm = array_search($this->key_algorithm, \OpenPGP\Packets\PublicKeyPacket::$algorithms);
     }
     if ($data) {
         // If we have any data, set up the creation time
         $this->hashed_subpackets = array(new \OpenPGP\Packets\Signatures\CreationTimePacket(time()));
     }
     if ($data instanceof \OpenPGP\Packets\LiteralDataPacket) {
         $this->signature_type = $data->format == 'b' ? 0x0 : 0x1;
         $data->normalize();
         $data = $data->data;
     } else {
         if ($data instanceof \OpenPGP\Message && $data[0] instanceof \OpenPGP\Packets\PublicKeyPacket) {
             // $data is a message with PublicKey first, UserID second
             $key = implode('', $data[0]->fingerprint_material());
             $user_id = $data[1]->body();
             $data = $key . chr(0xb4) . pack('N', strlen($user_id)) . $user_id;
         }
     }
     $this->data = $data;
     // Store to-be-signed data in here until the signing happens
 }
 function __construct($key_algorithm = '', $keyid = '', $encrypted_data = '', $version = 3)
 {
     parent::__construct();
     $this->version = $version;
     $this->keyid = substr($keyid, -16);
     $this->key_algorithm = $key_algorithm;
     $this->encrypted_data = $encrypted_data;
 }
示例#3
0
 function __construct($data = NULL, $opt = array())
 {
     parent::__construct();
     $this->data = $data;
     $this->format = isset($opt['format']) ? $opt['format'] : 'b';
     $this->filename = isset($opt['filename']) ? $opt['filename'] : 'data';
     $this->timestamp = isset($opt['timestamp']) ? $opt['timestamp'] : time();
 }
 function __construct($s2k = NULL, $encrypted_data = '', $symmetric_algorithm = 9, $version = 3)
 {
     parent::__construct();
     $this->version = $version;
     $this->symmetric_algorithm = $symmetric_algorithm;
     $this->s2k = $s2k;
     $this->encrypted_data = $encrypted_data;
 }
示例#5
0
 function __construct($name = '', $comment = '', $email = '')
 {
     parent::__construct();
     if (!$comment && !$email) {
         $this->input = $name;
         $this->read();
     } else {
         $this->name = $name;
         $this->comment = $comment;
         $this->email = $email;
     }
 }
示例#6
0
 function __construct($key = array(), $algorithm = 'RSA', $timestamp = NULL, $version = 4)
 {
     parent::__construct();
     $this->key = $key;
     if (is_string($this->algorithm = $algorithm)) {
         $this->algorithm = array_search($this->algorithm, self::$algorithms);
     }
     $this->timestamp = $timestamp ? $timestamp : time();
     $this->version = $version;
     if (count($this->key) > 0) {
         $this->key_id = substr($this->fingerprint(), -8);
     }
 }
示例#7
0
 static function parse_string($input)
 {
     $msg = new self();
     while (($length = strlen($input)) > 0) {
         if ($packet = \OpenPGP\Packet::parse($input)) {
             $msg[] = $packet;
         }
         if ($length == strlen($input)) {
             // is parsing stuck?
             break;
         }
     }
     return $msg;
 }
示例#8
0
 function __construct($data = NULL)
 {
     parent::__construct($data);
     $this->tag = array_search(substr(substr(get_class($this), 8 + 16), 0, -6), \OpenPGP\Packets\SignaturePacket::$subpacket_types);
 }