From 5756085e8593e0a092d09f759416568fcc0f63eb Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Thu, 1 Apr 2010 18:39:36 -0500 Subject: [PATCH] Convenience function for expiry time of keys --- lib/openpgp.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/openpgp.php b/lib/openpgp.php index d467572..ad77852 100644 --- a/lib/openpgp.php +++ b/lib/openpgp.php @@ -816,6 +816,18 @@ class OpenPGP_PublicKeyPacket extends OpenPGP_Packet { return $sigs; } + // Find expiry time of this key based on the self signatures in a message + function expires($message) { + foreach($this->self_signatures($message) as $p) { + foreach(array_merge($p->hashed_subpackets, $p->unhashed_subpackets) as $s) { + if($s instanceof OpenPGP_SignaturePacket_KeyExpirationTimePacket) { + return $this->timestamp + $s->data; + } + } + } + return NULL; // Never expires + } + /** * @see http://tools.ietf.org/html/rfc4880#section-5.5.2 */