~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to tools/ring-a-party

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2006-01-24 04:31:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060124043142-pbg192or6qxv3yk2
Tags: 1.9.20-1
* New Upstream version. Closes:#306890,#344530
  * Closes:#320490: gpg-protect-tool fails to decrypt PKCS-12 files 
* Depend on libopensc2-dev, not -1-. Closes:#348106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# ring-a-party  - print a keyring suitable for a key signing party
 
3
# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
 
4
#
 
5
# This file is free software; as a special exception the author gives
 
6
# unlimited permission to copy and/or distribute it, with or without
 
7
# modifications, as long as this notice is preserved.
 
8
#
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 
11
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
12
 
 
13
if [ $# -lt 1 ]; then
 
14
    echo "usage: ring-a-party keyring [headerline]" >&2
 
15
    exit 1
 
16
fi
 
17
 
 
18
keyring="$1"
 
19
hdrline="$1"
 
20
if [ $# -gt 1 ]; then
 
21
    hdrline="$2"
 
22
fi
 
23
 
 
24
if [ ! -f $keyring ]; then
 
25
    echo "ring-a-party: '$keyring': no such file" >&2
 
26
    exit 1
 
27
fi
 
28
 
 
29
echo "ring-a-party: output will be written to 'a.pub'" >&2
 
30
 
 
31
 
 
32
gpg --dry-run --with-fingerprint --with-colons $keyring \
 
33
    | gawk -v "KEYRING=$hdrline" '
 
34
BEGIN { FS=":"
 
35
        algos[1] = "RSA";
 
36
        algos[16] = "ElGamal";
 
37
        algos[17] = "DSA";
 
38
        any = 0;
 
39
        lines = -1;
 
40
        page = 0;
 
41
        now = strftime("%b %d %H:%M %Y");
 
42
      }
 
43
END { 
 
44
    if (any) myflush(); 
 
45
}
 
46
$1 == "pub" {
 
47
              if( any ) myflush();
 
48
              uidcount = 0;
 
49
              signencrypt = 0;
 
50
              uids[uidcount++] = $10;
 
51
              nbits = $3;
 
52
              keyid = substr($5,9);
 
53
              created = $6;
 
54
              expires = $7;
 
55
              algostr = mapalgo($4);
 
56
              if( $4 == 20 || $4 == 1 ) signencrypt = 1;
 
57
              any = 1;
 
58
            }
 
59
$1 == "fpr" { fpr = $10 }
 
60
$1 == "uid" { uids[uidcount++] = $10 }
 
61
$1 == "sub" { if( $4 != 17 && $4 != 3 )  signencrypt=1 }
 
62
 
 
63
function myflush()
 
64
{
 
65
    # fixme: take lines to print here into account
 
66
    if( lines > 45 || lines == -1 ) {
 
67
        if( lines != -1 ) printf "\f";
 
68
        page++;
 
69
        printf "%s  %-50.50s Page %d\n\n", now, KEYRING, page ;
 
70
        printf "    Type Bits KeyID      Created    Expires    Algorithm                 Use\n\n";
 
71
        lines = 1;
 
72
    }
 
73
    printf "[ ] pub  %04d 0x%s %10s %10s %-10s     %15s\n",
 
74
          nbits, keyid, created, expires == ""? "----------":expires, algostr,
 
75
                        signencrypt == 1? "Sign & Encrypt":"Sign only";
 
76
    length(fpr) == 40 ? printfpr20( fpr ) : printfpr16( fpr );
 
77
    lnes += 2;
 
78
    for( i=0; i < uidcount; i++ ) {
 
79
        printf "( ) uid  %s\n", uids[i];
 
80
        lines++;
 
81
    }
 
82
    printf "\n\n";
 
83
    lines += 2;
 
84
}
 
85
 
 
86
function mapalgo( no )
 
87
{
 
88
    if( no in algos )
 
89
        return algos[no];
 
90
    return sprintf( "algoID=%ds", no );
 
91
}
 
92
 
 
93
 
 
94
function printfpr16( s )
 
95
{
 
96
    printf "    f16    Fingerprint16 =";
 
97
    for(i=0; i < 16; i++ ) {
 
98
        if( i == 8 ) printf " ";
 
99
        printf " %s", substr( s, i*2+1, 2 );
 
100
    }
 
101
    printf "\n"
 
102
}
 
103
 
 
104
function printfpr20( s )
 
105
{
 
106
    printf "    f20    Fingerprint20 =";
 
107
    for(i=0; i < 10; i++ ) {
 
108
        if( i == 5 ) printf " ";
 
109
        printf " %s", substr( s, i*4+1, 4 );
 
110
    }
 
111
    printf "\n"
 
112
}
 
113
 
 
114
' | tee a.pub | gpg --print-mds
 
115
 
 
116
 
 
117
 
 
118