6 #define _RPMIOB_INTERNAL
12 #define _RPMPGP_INTERNAL
17 #define _RPMEVR_INTERNAL
19 #define _RPMNS_INTERNAL
24 #define _RPMTS_INTERNAL
41 "i386",
"i486",
"i586",
"i686",
"athlon",
"pentium3",
"pentium4",
42 "x86_64",
"amd64",
"ia32e",
43 "alpha",
"alphaev5",
"alphaev56",
"alphapca56",
"alphaev6",
"alphaev67",
44 "sparc",
"sun4",
"sun4m",
"sun4c",
"sun4d",
"sparcv8",
45 "sparcv9",
"sparcv9b",
"sparcv9v",
"sparcv9v2",
46 "sparc64",
"sun4u",
"sparc64v",
47 "mips",
"mipsel",
"IP",
48 "ppc",
"ppciseries",
"ppcpseries",
49 "ppc64",
"ppc64iseries",
"ppc64pseries",
53 "armv3l",
"armv4b",
"armv4l",
54 "armv5teb",
"armv5tel",
"armv5tejl",
56 "s390",
"i370",
"s390x",
57 "sh",
"sh3",
"sh4",
"sh4a",
"xtensa",
68 #if defined(RPM_VENDOR_WINDRIVER)
69 const char * known_arch =
rpmExpand(
"%{?_known_arch}", NULL);
70 const char *p, *pe, *t;
73 pe = p ;
while (*pe && !
xisspace(*pe)) pe++;
76 t = strndup(p, (pe - p));
82 known_arch =
_free(known_arch);
161 size_t sn = strlen(str);
164 if (sn >= 5 && str[sn-1] ==
')')
167 if (sn > nb && str[nb] ==
'(' && !strncmp(str, av->
NS, nb))
182 s = str + strlen(str);
183 if (str[0] ==
'%' && str[1] ==
'{' && s[-1] ==
'}')
185 if ((s - str) > 3 && s[-3] ==
'.' && s[-2] ==
's' && s[-1] ==
'o')
190 for (s = str; *s !=
'\0'; s++) {
191 if (s[0] ==
'(' || s[strlen(s)-1] ==
')')
193 if (s[0] ==
'.' && s[1] ==
's' && s[2] ==
'o')
244 if (ns->NS[0] ==
'!')
246 if ((t = strchr(t,
'(')) != NULL) {
249 t[strlen(t)-1] =
'\0';
280 static inline unsigned char nibble(
char c)
283 if (c >=
'0' && c <=
'9')
284 return (
unsigned char)(c -
'0');
285 if (c >=
'A' && c <=
'F')
286 return (
unsigned char)((int)(c -
'A') + 10);
287 if (c >=
'a' && c <=
'f')
288 return (
unsigned char)((int)(c -
'a') + 10);
293 const char * pubfn,
const char * pubid,
301 size_t sigpktlen = 0;
308 fprintf(stderr,
"==> check(%s, %s, %s, %s)\n", fn,
309 (sigfn ? sigfn :
"(null)"),
310 (pubfn ? pubfn :
"(null)"),
311 (pubid ? pubid :
"(null)"));
314 if (sigfn && *sigfn) {
315 const char * _sigfn =
rpmExpand(sigfn, NULL);
319 fprintf(stderr,
"==> pgpReadPkts(%s) SIG %p[%u] ret %d\n", _sigfn, sigpkt, (
unsigned)sigpktlen, xx);
320 _sigfn =
_free(_sigfn);
323 _sigfn =
_free(_sigfn);
325 const char * _sigfn =
rpmExpand(fn, NULL);
329 fprintf(stderr,
"==> pgpReadPkts(%s) SIG %p[%u] ret %d\n", _sigfn, sigpkt, (
unsigned)sigpktlen, xx);
330 _sigfn =
_free(_sigfn);
333 _sigfn =
_free(_sigfn);
338 fprintf(stderr,
"==> pgpPrtPkts SIG %p[%u] ret %d\n", sigpkt, (
unsigned)sigpktlen, xx);
346 fprintf(stderr,
"==> unverifiable V%u\n", (
unsigned)sigp->version);
351 if (pubfn && *pubfn) {
352 const char * _pubfn =
rpmExpand(pubfn, NULL);
354 xx =
pgpReadPkts(_pubfn, &ts->pkpkt, &ts->pkpktlen);
358 fprintf(stderr,
"==> pgpReadPkts(%s) PUB %p[%u] ret %d\n", _pubfn, ts->pkpkt, (
unsigned int)ts->pkpktlen, xx);
359 _pubfn =
_free(_pubfn);
362 _pubfn =
_free(_pubfn);
366 fprintf(stderr,
"==> pgpPrtPkts PUB %p[%u] ret %d\n", ts->pkpkt, (
unsigned int)ts->pkpktlen, xx);
372 fprintf(stderr,
"==> pgpFindPubkey ret %d\n", xx);
380 if (pubid && *pubid) {
381 size_t ns = strlen(pubid);
387 for (i = 0, s = pubid; *s && isxdigit(*s); s++, i++)
389 if (!(*s ==
'\0' && i > 8 && (i%2) == 0))
399 t = memset(
alloca(ns), 0, ns);
400 for (i = 0; i < ns; i++)
401 t[i] = (
char)((
nibble(s[2*i]) << 4) |
nibble(s[2*i+1]));
404 s = (
const char *)pubp->signid;
405 xx = memcmp(t, s + (8 - ns), ns);
413 fprintf(stderr,
"==> mismatched: pubkey id (%08x %08x) != %s\n",
420 if (!(sigp->pubkey_algo == pubp->pubkey_algo
422 && sigp->hash_algo == pubp->hash_algo
427 fprintf(stderr,
"==> mismatch between signature and pubkey\n");
428 fprintf(stderr,
"\tpubkey_algo: %u %u\n", (
unsigned)sigp->pubkey_algo, (
unsigned)pubp->pubkey_algo);
429 fprintf(stderr,
"\tsignid: %08X %08X %08X %08X\n",
440 static const char clrtxt[] =
"-----BEGIN PGP SIGNED MESSAGE-----";
441 static const char sigtxt[] =
"-----BEGIN PGP SIGNATURE-----";
446 if (!(_rc == 0 && iob != NULL)) {
448 fprintf(stderr,
"==> rpmiobSlurp(%s) MSG ret %d\n", _fn, _rc);
456 if (!strncmp((
char *)iob->b, clrtxt, strlen(clrtxt))) {
457 const char * be = (
char *) (iob->b + iob->blen);
462 while (t && t < be && *t !=
'\n')
463 t = strchr(t,
'\n') + 1;
472 if (strncmp(t,
"- ", 2) == 0)
474 if ((teol = te = strchr(t,
'\n')) == NULL)
476 while (te > t && strchr(
" \t\r\n", te[-1]))
479 if (!strncmp((t = teol + 1), sigtxt, strlen(sigtxt)))
489 if (sigp->hash != NULL)
495 trailer[0] = sigp->version;
497 memcpy(trailer+2, &nb,
sizeof(nb));
502 switch(sigp->pubkey_algo) {
515 fprintf(stderr,
"==> can't load pubkey_algo(%u)\n", (
unsigned)sigp->pubkey_algo);
520 switch(sigp->pubkey_algo) {
533 sigpkt =
_free(sigpkt);
534 ts->pkpkt =
_free(ts->pkpkt);
541 fprintf(stderr,
"============================ verify: %s\n",