Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Abstract extracting a signature packet along with data

  • Loading branch information...
commit 82aee72d1b18065ee546c91e74922cf858daafa2 1 parent 6183772
@singpolyma singpolyma authored committed
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/openpgp.php
View
15 lib/openpgp.php
@@ -149,11 +149,7 @@ function to_bytes() {
return $bytes;
}
- /**
- * Function to verify signature number $index
- * $verifiers is an array of callbacks formatted like array('RSA' => array('SHA256' => CALLBACK)) that take two parameters: message and signature
- */
- function verify($verifiers, $index=0) {
+ function signature_and_data($index=0) {
$msg = $this;
while($msg[0] instanceof OpenPGP_CompressedDataPacket) $msg = $msg[0];
@@ -167,6 +163,15 @@ function verify($verifiers, $index=0) {
if($signature_packet && $data_packet) break;
}
+ return array($signature_packet, $data_packet);
+ }
+
+ /**
+ * Function to verify signature number $index
+ * $verifiers is an array of callbacks formatted like array('RSA' => array('SHA256' => CALLBACK)) that take two parameters: message and signature
+ */
+ function verify($verifiers, $index=0) {
+ list($signature_packet, $data_packet) = $this->signature_and_data($index);
if(!$signature_packet || !$data_packet) return NULL; // No signature or no data
$verifier = $verifiers[$signature_packet->key_algorithm_name()][$signature_packet->hash_algorithm_name()];
Please sign in to comment.
Something went wrong with that request. Please try again.