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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
#include "system.h"
#include "rpmio/rpmio_internal.h"
#include <rpmmacro.h>
#include <rpmlog.h>
#include <popt.h>
#include "debug.h"
static int _debug = 0;
static int _printing = 0;
#if 0
#define HKPPATH "hkp://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF5C75256"
#else
#if 0
#define HKPPATH "hkp://pgp.mit.edu"
#else
#define HKPPATH "hkp://sks.keyserver.penguin.de"
#endif
#endif
static char * hkppath = HKPPATH;
static unsigned int keyids[] = {
#if 0
0xc2b079fc, 0xf5c75256,
0x94cd5742, 0xe418e3aa,
0xb44269d0, 0x4f2a6fd2,
0xda84cbd4, 0x30c9ecf8,
0x29d5ba24, 0x8df56d05,
0xa520e8f1, 0xcba29bf9,
0x219180cd, 0xdb42a60e,
0xfd372689, 0x897da07a,
0xe1385d4e, 0x1cddbca9,
0xb873641b, 0x2039b291,
#endif
0x58e727c4, 0xc621be0f,
0
};
static int readKeys(const char * uri)
{
unsigned int * kip;
const uint8_t * pkt;
size_t pktlen;
uint8_t keyid[8];
char fn[BUFSIZ];
pgpDig dig;
int rc;
int ec = 0;
rpmInitCrypto();
dig = pgpNewDig();
for (kip = keyids; *kip; kip += 2) {
pgpArmor pa;
sprintf(fn, "%s/pks/lookup?op=get&search=0x%08x%08x", uri, kip[0], kip[1]);
fprintf(stderr, "======================= %s\n", fn);
pkt = NULL;
pktlen = 0;
pa = pgpReadPkts(fn, &pkt, &pktlen);
if (pa == PGPARMOR_ERROR || pa == PGPARMOR_NONE
|| pkt == NULL || pktlen <= 0)
{
ec++;
continue;
}
rc = pgpPrtPkts(pkt, pktlen, dig, _printing);
if (rc)
ec++;
#if 0
fprintf(stderr, "%s\n", pgpHexStr(pkt, pktlen));
#endif
if (!pgpPubkeyFingerprint(pkt, pktlen, keyid))
fprintf(stderr, "KEYID: %08x %08x\n", pgpGrab(keyid, 4), pgpGrab(keyid+4, 4));
pgpCleanDig(dig);
free((void *)pkt);
pkt = NULL;
}
dig = pgpFreeDig(dig);
return ec;
}
static struct poptOption optionsTable[] = {
{ "print", 'p', POPT_ARG_VAL, &_printing, 1, NULL, NULL },
{ "noprint", 'n', POPT_ARG_VAL, &_printing, 0, NULL, NULL },
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
N_("debug rpmio I/O"), NULL},
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
N_("debug URL cache handling"), NULL},
{ "verbose", 'v', 0, 0, 'v', NULL, NULL },
POPT_AUTOHELP
POPT_TABLEEND
};
int
main(int argc, char *argv[])
{
poptContext optCon = poptGetContext(argv[0], argc, (const char **) argv, optionsTable, 0);
int rc;
while ((rc = poptGetNextOpt(optCon)) > 0) {
switch (rc) {
case 'v':
rpmIncreaseVerbosity();
break;
default:
break;
}
}
if (_debug) {
rpmIncreaseVerbosity();
rpmIncreaseVerbosity();
}
readKeys(hkppath);
return 0;
}
|