summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2010-05-02 02:32:40 -0400
committerJesse Vincent <jesse@bestpractical.com>2010-05-08 16:51:28 -0400
commit828604d0e5d0e408ac3c872a945ce6145559f114 (patch)
tree9138dfd535cbb8393b6c98b62d2f099b05dabee3 /lib
parentd32052f5968b88a13ab8a0585566dca800c01d69 (diff)
expose signature expiration times
Diffstat (limited to 'lib')
-rw-r--r--lib/GnuPG/Interface.pm41
-rw-r--r--lib/GnuPG/Key.pm6
-rw-r--r--lib/GnuPG/Signature.pm13
3 files changed, 47 insertions, 13 deletions
diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm
index a8bac99..5d25c61 100644
--- a/lib/GnuPG/Interface.pm
+++ b/lib/GnuPG/Interface.pm
@@ -428,11 +428,15 @@ sub get_keys {
$usage_flags,
) = @fields[ 1 .. $#fields ];
-
- # --fixed-list-mode uses epoch time for creation and expiration date strings.
- # For backward compatibility, we convert them back using GMT;
- my $creation_date_string = $self->_downrez_date($creation_date);
- my $expiration_date_string = $self->_downrez_date($expiration_date);
+ # --fixed-list-mode uses epoch time for creation and expiration date strings.
+ # For backward compatibility, we convert them back using GMT;
+ my $expiration_date_string;
+ if ($expiration_date eq '') {
+ $expiration_date = undef;
+ } else {
+ $expiration_date_string = $self->_downrez_date($expiration_date);
+ }
+ my $creation_date_string = $self->_downrez_date($creation_date);
$current_key = $current_fingerprinted_key
= $record_type eq 'pub'
@@ -461,15 +465,26 @@ sub get_keys {
elsif ( $record_type eq 'sig' ) {
my (
$algo_num, $hex_key_id,
- $signature_date, $user_id_string
- ) = @fields[ 3 .. 5, 9 ];
+ $signature_date,
+ $expiration_date,
+ $user_id_string
+ ) = @fields[ 3 .. 6, 9 ];
+
+ my $expiration_date_string;
+ if ($expiration_date eq '') {
+ $expiration_date = undef;
+ } else {
+ $expiration_date_string = $self->_downrez_date($expiration_date);
+ }
+ my $signature_date_string = $self->_downrez_date($signature_date);
- my $signature_date_string = $self->_downrez_date($signature_date);
my $signature = GnuPG::Signature->new(
algo_num => $algo_num,
hex_id => $hex_key_id,
date => $signature_date,
date_string => $signature_date_string,
+ expiration_date => $expiration_date,
+ expiration_date_string => $expiration_date_string,
user_id_string => unescape_string($user_id_string),
);
@@ -502,8 +517,14 @@ sub get_keys {
$usage_flags,
) = @fields[ 1 .. 11 ];
- my $creation_date_string = $self->_downrez_date($creation_date);
- my $expiration_date_string = $self->_downrez_date($expiration_date);
+ my $expiration_date_string;
+ if ($expiration_date eq '') {
+ $expiration_date = undef;
+ } else {
+ $expiration_date_string = $self->_downrez_date($expiration_date);
+ }
+ my $creation_date_string = $self->_downrez_date($creation_date);
+
$current_signed_item = $current_fingerprinted_key
= GnuPG::SubKey->new(
validity => $validity,
diff --git a/lib/GnuPG/Key.pm b/lib/GnuPG/Key.pm
index d3fc5e1..bd27611 100644
--- a/lib/GnuPG/Key.pm
+++ b/lib/GnuPG/Key.pm
@@ -122,14 +122,16 @@ the short hex id, which is 8 hex characters.
=item expiration_date_string
-Formatted date of the key's creation and expiration.
+Formatted date of the key's creation and expiration. If the key has
+no expiration, expiration_date_string will return undef.
=item creation_date
=item expiration_date
Date of the key's creation and expiration, stored as the number of
-seconds since midnight 1970-01-01 UTC.
+seconds since midnight 1970-01-01 UTC. If the key has no expiration,
+expiration_date will return undef.
=item fingerprint
diff --git a/lib/GnuPG/Signature.pm b/lib/GnuPG/Signature.pm
index fb1dd95..f0e200d 100644
--- a/lib/GnuPG/Signature.pm
+++ b/lib/GnuPG/Signature.pm
@@ -16,7 +16,7 @@
package GnuPG::Signature;
use Any::Moose;
-has [qw( algo_num hex_id user_id_string date date_string )] => (
+has [qw( algo_num hex_id user_id_string date date_string expiration_date expiration_date_string )] => (
isa => 'Any',
is => 'rw',
);
@@ -79,6 +79,17 @@ The formatted date the signature was performed on.
The date the signature was performed, represented as the number of
seconds since midnight 1970-01-01 UTC.
+=item expiration_date_string
+
+The formatted date the signature will expire (signatures without
+expiration return undef).
+
+=item expiration_date
+
+The date the signature will expire, represented as the number of
+seconds since midnight 1970-01-01 UTC (signatures without expiration
+return undef)
+
=back
=head1 SEE ALSO