Permalink
Browse files

Implement OpenPGP_SignaturePacket_EmbeddedSignaturePacket

  • Loading branch information...
1 parent 3fcc8c1 commit f171b85d0ea08403a286ca958d9a2d3594c06007 @singpolyma singpolyma committed with Arto Bendiken Apr 1, 2010
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/openpgp.php
View
15 lib/openpgp.php
@@ -719,8 +719,19 @@ class OpenPGP_SignaturePacket_SignatureTargetPacket extends OpenPGP_SignaturePac
// TODO
}
-class OpenPGP_SignaturePacket_EmbeddedSignaturePacket extends OpenPGP_SignaturePacket_Subpacket {
- // TODO
+class OpenPGP_SignaturePacket_EmbeddedSignaturePacket extends OpenPGP_SignaturePacket {
+ // TODO: This is duplicated from subpacket... improve?
+ function __construct($data=NULL) {
+ parent::__construct($data);
+ $this->tag = array_search(substr(substr(get_class($this), 8+16), 0, -6), OpenPGP_SignaturePacket::$subpacket_types);
+ }
+
+ function header_and_body() {
+ $body = $this->body(); // Get body first, we will need it's length
+ $size = chr(255).pack('N', strlen($body)+1); // Use 5-octet lengths + 1 for tag as first packet body octet
+ $tag = chr($this->tag);
+ return array('header' => $size.$tag, 'body' => $body);
+ }
}
/**

0 comments on commit f171b85

Please sign in to comment.