00001 #include "system.h"
00002
00003 #include <rpmio_internal.h>
00004 #include <rpmmacro.h>
00005 #include <rpmmessages.h>
00006 #include <popt.h>
00007
00008 #include "debug.h"
00009
00010 static int _debug = 0;
00011 static int _printing = 0;
00012
00013
00014 #if 0
00015 #define HKPPATH "hkp://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF5C75256"
00016 #else
00017 #if 0
00018 #define HKPPATH "hkp://pgp.mit.edu"
00019 #else
00020 #define HKPPATH "hkp://sks.keyserver.penguin.de"
00021 #endif
00022 #endif
00023 static char * hkppath = HKPPATH;
00024
00025 static unsigned int keyids[] = {
00026 #if 0
00027 0xc2b079fc, 0xf5c75256,
00028 0x94cd5742, 0xe418e3aa,
00029 0xb44269d0, 0x4f2a6fd2,
00030 0xda84cbd4, 0x30c9ecf8,
00031 0x29d5ba24, 0x8df56d05,
00032 0xa520e8f1, 0xcba29bf9,
00033 0x219180cd, 0xdb42a60e,
00034 0xfd372689, 0x897da07a,
00035 0xe1385d4e, 0x1cddbca9,
00036 0xb873641b, 0x2039b291,
00037 #endif
00038 0x58e727c4, 0xc621be0f,
00039 0
00040 };
00041
00042 static int readKeys(const char * uri)
00043 {
00044 unsigned int * kip;
00045 const byte * pkt;
00046 ssize_t pktlen;
00047 byte keyid[8];
00048 char fn[BUFSIZ];
00049 pgpDig dig;
00050 int rc;
00051 int ec = 0;
00052
00053 dig = pgpNewDig();
00054 for (kip = keyids; *kip; kip += 2) {
00055 pgpArmor pa;
00056
00057 sprintf(fn, "%s/pks/lookup?op=get&search=0x%08x%08x", uri, kip[0], kip[1]);
00058 fprintf(stderr, "======================= %s\n", fn);
00059 pkt = NULL;
00060 pktlen = 0;
00061 pa = pgpReadPkts(fn, &pkt, &pktlen);
00062 if (pa == PGPARMOR_ERROR || pa == PGPARMOR_NONE
00063 || pkt == NULL || pktlen <= 0)
00064 {
00065 ec++;
00066 continue;
00067 }
00068
00069 rc = pgpPrtPkts(pkt, pktlen, dig, _printing);
00070 if (rc)
00071 ec++;
00072 #if 0
00073 fprintf(stderr, "%s\n", pgpHexStr(pkt, pktlen));
00074 #endif
00075 if (!pgpPubkeyFingerprint(pkt, pktlen, keyid))
00076 fprintf(stderr, "KEYID: %08x %08x\n", pgpGrab(keyid, 4), pgpGrab(keyid+4, 4));
00077
00078
00079 pgpCleanDig(dig);
00080
00081 free((void *)pkt);
00082 pkt = NULL;
00083 }
00084 dig = pgpFreeDig(dig);
00085
00086 return ec;
00087 }
00088
00089 static struct poptOption optionsTable[] = {
00090 { "print", 'p', POPT_ARG_VAL, &_printing, 1, NULL, NULL },
00091 { "noprint", 'n', POPT_ARG_VAL, &_printing, 0, NULL, NULL },
00092 { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
00093 { "davdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_dav_debug, -1,
00094 N_("debug protocol data stream"), NULL},
00095 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
00096 N_("debug protocol data stream"), NULL},
00097 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
00098 N_("debug rpmio I/O"), NULL},
00099 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
00100 N_("debug URL cache handling"), NULL},
00101 { "verbose", 'v', 0, 0, 'v', NULL, NULL },
00102 POPT_AUTOHELP
00103 POPT_TABLEEND
00104 };
00105
00106 int
00107 main(int argc, const char *argv[])
00108 {
00109 poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
00110 int rc;
00111
00112 while ((rc = poptGetNextOpt(optCon)) > 0) {
00113 switch (rc) {
00114 case 'v':
00115 rpmIncreaseVerbosity();
00116 break;
00117 default:
00118 break;
00119 }
00120 }
00121
00122 if (_debug) {
00123 rpmIncreaseVerbosity();
00124 rpmIncreaseVerbosity();
00125 }
00126
00127 readKeys(hkppath);
00128
00129 urlFreeCache();
00130
00131 return 0;
00132 }