From e3f332c6ca9d8f9adf68e2c25be0e15a254dfeb1 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 30 Mar 2010 13:04:32 -0500 Subject: [PATCH] Implement most of the "new" packet format --- lib/openpgp.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/openpgp.php b/lib/openpgp.php index d6a67e6..bb63ae0 100644 --- a/lib/openpgp.php +++ b/lib/openpgp.php @@ -213,7 +213,17 @@ class OpenPGP_Packet { */ static function parse_new_format($input) { $tag = ord($input[0]) & 63; - // TODO + $len = ord($input[1]); + if($len < 192) { // One octet length + return array($tag, 2, $len); + } + if($len > 191 && $len < 224) { // Two octet length + return array($tag, 3, (($len - 192) << 8) + ord($input[2]) + 192); + } + if($len == 255) { // Five octet length + return array($tag, 6, unpack('N', substr($input, 2, 4))); + } + // TODO: Partial body lengths. 1 << ($len & 0x1F) } /**