OpenPGP_SignaturePacket::__construct PHP Method

__construct() public method

This is the literal bytes that get tacked on the end of the message when verifying the signature
public __construct ( $data = NULL, $key_algorithm = NULL, $hash_algorithm = NULL )
    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_PublicKeyPacket::$algorithms);
        }
        if ($data) {
            // If we have any data, set up the creation time
            $this->hashed_subpackets = array(new OpenPGP_SignaturePacket_SignatureCreationTimePacket(time()));
        }
        if ($data instanceof OpenPGP_LiteralDataPacket) {
            $this->signature_type = $data->format == 'b' ? 0x0 : 0x1;
            $data->normalize();
            $data = $data->data;
        } else {
            if ($data instanceof OpenPGP_Message && $data[0] instanceof OpenPGP_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
    }

Usage Example

Exemplo n.º 1
0
 function __construct($data = NULL)
 {
     parent::__construct($data);
     $this->tag = array_search(substr(substr(get_class($this), 8 + 16), 0, -6), OpenPGP_SignaturePacket::$subpacket_types);
 }