From 0b2942e382afcd646c36f402da9f9fef25f69144 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Thu, 1 Apr 2010 09:24:14 -0500 Subject: [PATCH] SignaturePacket method to do actual signing --- lib/openpgp.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/openpgp.php b/lib/openpgp.php index e87857e..4d9b528 100644 --- a/lib/openpgp.php +++ b/lib/openpgp.php @@ -414,6 +414,17 @@ class OpenPGP_SignaturePacket extends OpenPGP_Packet { $this->data = $data; // Store to-be-signed data in here until the signing happens } + /** + * $this->data must be set to the data to sign (done by constructor) + * $signers in the same format as $verifiers for OpenPGP_Message. + */ + function sign_data($signers) { + $this->trailer = $this->body(true); + $signer = $signers[$this->key_algorithm_name()][$this->hash_algorithm_name()]; + $this->data = call_user_func($signer, $this->data.$this->trailer); + $this->hash_head = array_pop(unpack('n', substr($this->data, 0, 2))); + } + function read() { switch($this->version = ord($this->read_byte())) { case 3: