File: gpg.pm

package info (click to toggle)
debsigs 0.1.18
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 192 kB
  • ctags: 21
  • sloc: perl: 668; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 2,183 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#    debsigs: Package signing/verification system 
#    Copyright (C) 2000   Progeny Linux Systems, Inc. <jgoerzen@progeny.com>
#    Copyright (C) 2009   Peter Pentchev <roam@ringlet.net>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

package Debian::debsigs::gpg;

use strict;
use warnings;

use Debian::debsigs::forktools ':all';

#my $CVSVERSION = '$Progeny: gpg.pm,v 1.5 2001/05/09 11:21:52 epg Exp $'; #'
#my ($VERSION) = $CVSVERSION =~ /^\$Progeny: .+,v ([0-9.]+) /;
our $VERSION = '1.06';

sub getkeyfromfd {
  my $forkfd = shift @_;

  my ($gpgfd, $gpgpid) = forkreader($forkfd,
					       "/usr/bin/gpg",
					       "--list-packets");
  
  my ($keyid, $date);

  my $line = <$gpgfd>;
  # print STDERR "gpg: got first line: $line";
  die 'bad gpg line' unless ($line =~ '^:signature packet:');
  ($keyid) = $line =~ /^:signature packet: .+ keyid ([0-9a-fA-F]+)/;
  die 'invalid gpg line' unless($keyid);
  while (defined($line = <$gpgfd>)) {
    # print STDERR "gpg: got line: $line";
    unless ($date) {
      ($date) = $line =~ /^\s+.*created ([0-9]+)/;
    }
  }
  
  assertsuccess($gpgpid, 'gpg --list-packets');
  # print STDERR "gpg: returning ($keyid, $date)\n";
  return ($keyid, $date);
}

sub getkeynamefromid {
  my $keyid = shift @_;

  my ($gpgfd, $gpgpid) = forkreader(undef, "/usr/bin/gpg",
					       "--list-keys", $keyid);
  
  my $line = <$gpgfd>;
  chomp $line;
  
  my ($name) = $line =~ m'pub\s+.+/[0-9A-Fa-f]+ \d\d\d\d-\d\d-\d\d (.+)$';
  return $name;
}

1;