Convenience function for expiry time of keys

This commit is contained in:
Stephen Paul Weber 2010-04-01 18:39:36 -05:00
parent 9cdc2500b1
commit 5756085e85
1 changed files with 12 additions and 0 deletions

View File

@ -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
*/