package PGP::Certificate::Subkey;

use strict;

BEGIN {
    no strict 'refs';

    foreach my $accessor (qw(created expires pkalg modlength
			     fingerprint keyid)) {
	*{$accessor} = sub {
	    my ($this) = @_;
	    $this->{"packet"}->{$accessor};
	};
    }

    foreach my $accessor (qw(packet revocation binding)) {
	*{$accessor} = sub {
	    my ($this) = @_;
	    $this->{$accessor};
	};
    }
};

sub new {
    my ($classname, $packet) = @_;

    bless {
	"packet" => $packet,
    }, $classname;
}

sub set_revocation {
    my ($self, $sig) = @_;

    if (!$self->{"revocation"} ||
	$self->{"revocation"}->created < $sig->created) {
	$self->{"revocation"} = $sig;
    }
}

sub set_binding {
    my ($self, $sig) = @_;

    if (!$self->{"binding"} ||
	$self->{"binding"}->created < $sig->created) {
	$self->{"binding"} = $sig;
    }
}

1;
