home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / perl5 / GnuPG / Signature.pm < prev    next >
Encoding:
Perl POD Document  |  2010-05-10  |  4.0 KB  |  171 lines

  1. #  Signature.pm
  2. #    - providing an object-oriented approach to GnuPG key signatures
  3. #
  4. #  Copyright (C) 2000 Frank J. Tobin <ftobin@cpan.org>
  5. #
  6. #  This module is free software; you can redistribute it and/or modify it
  7. #  under the same terms as Perl itself.
  8. #
  9. #  This program is distributed in the hope that it will be useful,
  10. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. #
  13. #  $Id: Signature.pm,v 1.4 2001/08/21 13:31:50 ftobin Exp $
  14. #
  15.  
  16. package GnuPG::Signature;
  17. use Any::Moose;
  18.  
  19. has [qw(
  20.          validity
  21.          algo_num
  22.          hex_id
  23.          user_id_string
  24.          date
  25.          date_string
  26.          expiration_date
  27.          expiration_date_string
  28.          sig_class
  29.          is_exportable
  30.       )] => (
  31.     isa => 'Any',
  32.     is  => 'rw',
  33. );
  34.  
  35. sub is_valid {
  36.     my $self = shift;
  37.     return $self->validity eq '!';
  38. }
  39.  
  40. sub compare {
  41.   my ($self, $other) = @_;
  42.  
  43.   my @compared_fields = qw(
  44.                             validity
  45.                             algo_num
  46.                             hex_id
  47.                             date
  48.                             date_string
  49.                             sig_class
  50.                             is_exportable
  51.                          );
  52.  
  53.   foreach my $field ( @compared_fields ) {
  54.     return 0 unless $self->$field eq $other->$field;
  55.   }
  56.   # check for expiration if present?
  57.   return 0 unless (defined $self->expiration_date) == (defined $other->expiration_date);
  58.   if (defined $self->expiration_date) {
  59.     return 0 unless (($self->expiration_date == $other->expiration_date) ||
  60.       ($self->expiration_date_string eq $other->expiration_date_string));
  61.   }
  62.   return 1;
  63. }
  64.  
  65. __PACKAGE__->meta->make_immutable;
  66.  
  67. 1;
  68.  
  69. __END__
  70.  
  71. =head1 NAME
  72.  
  73. GnuPG::Signature - GnuPG Key Signature Objects
  74.  
  75. =head1 SYNOPSIS
  76.  
  77.   # assumes a GnuPG::Key or GnuPG::UserID or GnuPG::UserAttribute object in $signed
  78.   my $signing_id = $signed->signatures->[0]->hex_id();
  79.  
  80. =head1 DESCRIPTION
  81.  
  82. GnuPG::Signature objects are generally not instantiated
  83. on their own, but rather as part of GnuPG::Key objects.
  84. They embody various aspects of a GnuPG signature on a key.
  85.  
  86. =head1 OBJECT METHODS
  87.  
  88. =over 4
  89.  
  90. =item new( I<%initialization_args> )
  91.  
  92. This methods creates a new object.  The optional arguments are
  93. initialization of data members.
  94.  
  95. =item is_valid()
  96.  
  97. Returns 1 if GnuPG was able to cryptographically verify the signature,
  98. otherwise 0.
  99.  
  100. =item compare( I<$other> )
  101.  
  102. Returns non-zero only when this Signature is identical to the other
  103. GnuPG::Signature.
  104.  
  105. =back
  106.  
  107. =head1 OBJECT DATA MEMBERS
  108.  
  109. =over 4
  110.  
  111. =item validity
  112.  
  113. A character indicating the cryptographic validity of the key.  GnuPG
  114. uses at least the following characters: "!" means valid, "-" means not
  115. valid, "?" means unknown (e.g. if the supposed signing key is not
  116. present in the local keyring), and "%" means an error occurred (e.g. a
  117. non-supported algorithm).  See the documentation for --check-sigs in
  118. gpg(1).
  119.  
  120. =item algo_num
  121.  
  122. The number of the algorithm used for the signature.
  123.  
  124. =item hex_id
  125.  
  126. The hex id of the signing key.
  127.  
  128. =item user_id_string
  129.  
  130. The first user id string on the key that made the signature.
  131. This may not be defined if the signing key is not on the local keyring.
  132.  
  133. =item sig_class
  134.  
  135. Signature class.  This is the numeric value of the class of signature.
  136.  
  137. A table of possible classes of signatures and their numeric types can
  138. be found at http://tools.ietf.org/html/rfc4880#section-5.2.1
  139.  
  140. =item is_exportable
  141.  
  142. returns 0 for local-only signatures, non-zero for exportable
  143. signatures.
  144.  
  145. =item date_string
  146.  
  147. The formatted date the signature was performed on.
  148.  
  149. =item date
  150.  
  151. The date the signature was performed, represented as the number of
  152. seconds since midnight 1970-01-01 UTC.
  153.  
  154. =item expiration_date_string
  155.  
  156. The formatted date the signature will expire (signatures without
  157. expiration return undef).
  158.  
  159. =item expiration_date
  160.  
  161. The date the signature will expire, represented as the number of
  162. seconds since midnight 1970-01-01 UTC (signatures without expiration
  163. return undef)
  164.  
  165. =back
  166.  
  167. =head1 SEE ALSO
  168.  
  169.  
  170. =cut
  171.