From 86c476807c080e901008c136b8cc8c9416cdad51 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Thu, 1 Apr 2010 09:23:43 -0500 Subject: [PATCH] Contructor for OpenPGP_SignaturePacket --- lib/openpgp.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/openpgp.php b/lib/openpgp.php index 319d369..e87857e 100644 --- a/lib/openpgp.php +++ b/lib/openpgp.php @@ -393,6 +393,27 @@ class OpenPGP_AsymmetricSessionKeyPacket extends OpenPGP_Packet { class OpenPGP_SignaturePacket extends OpenPGP_Packet { public $version, $signature_type, $hash_algorithm, $key_algorithm, $hashed_subpackets, $unhashed_subpackets, $hash_head; public $trailer; // This is the literal bytes that get tacked on the end of the message when verifying the signature + + 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') ? 0x00 : 0x01; + $data->normalize(); + $data = $data->data; + } + $this->data = $data; // Store to-be-signed data in here until the signing happens + } + function read() { switch($this->version = ord($this->read_byte())) { case 3: