6 #define _RPMIOB_INTERNAL
9 #define _RPMHKP_INTERNAL
14 #define _RPMPGP_INTERNAL
19 #define _RPMEVR_INTERNAL
21 #define _RPMNS_INTERNAL
26 #define _RPMTS_INTERNAL
48 "i386",
"i486",
"i586",
"i686",
"athlon",
"pentium3",
"pentium4",
49 "x86_64",
"amd64",
"ia32e",
50 "alpha",
"alphaev5",
"alphaev56",
"alphapca56",
"alphaev6",
"alphaev67",
51 "sparc",
"sun4",
"sun4m",
"sun4c",
"sun4d",
"sparcv8",
52 "sparcv9",
"sparcv9b",
"sparcv9v",
"sparcv9v2",
53 "sparc64",
"sun4u",
"sparc64v",
54 "mips",
"mipsel",
"IP",
55 "ppc",
"ppciseries",
"ppcpseries",
56 "ppc64",
"ppc64iseries",
"ppc64pseries",
60 "armv3l",
"armv4b",
"armv4l",
61 "armv5teb",
"armv5tel",
"armv5tejl",
63 "s390",
"i370",
"s390x",
64 "sh",
"sh3",
"sh4",
"sh4a",
"xtensa",
75 #if defined(RPM_VENDOR_WINDRIVER)
77 const char *
p, *pe, *
t;
80 pe =
p ;
while (*pe && !
xisspace(*pe)) pe++;
83 t = strndup(p, (pe - p));
89 known_arch =
_free(known_arch);
93 for (av = rpmnsArches; *av !=
NULL; av++) {
107 #define _ENTRY(_s, _type) { #_s, sizeof(#_s)-1, _type }
172 const char *
se = strchr(s,
')');
176 if (se ==
NULL || (slen = (se - s)) <
sizeof(
"ABC()")-1)
182 size_t i = (l +
u)/2;
185 int rc = strncmp(s, av->
NS, NSlen);
202 if (slen == 0) slen = strlen(s);
210 if (s[0] ==
'%' && s[1] ==
'{' && se[-1] ==
'}')
212 if ((se - s) > 3 && se[-3] ==
'.' && se[-2] ==
's' && se[-1] ==
'o')
217 for (se = s; *se !=
'\0'; se++) {
218 if (se[0] ==
'(' || se[--slen] ==
')')
220 if (se[0] ==
'.' && se[1] ==
's' && se[2] ==
'o')
224 if (_rpmns_N_at_A && _rpmns_N_at_A[0]) {
225 if (se[0] == _rpmns_N_at_A[0] &&
rpmnsArch(se+1))
239 size_t tlen = strlen(t);
251 if ((t = strrchr(t, _rpmns_N_at_A[0])) !=
NULL)
275 if (ns->NS[0] ==
'!')
277 if ((t = strchr(t,
'(')) !=
NULL) {
280 t[strlen(t)-1] =
'\0';
314 if (c >=
'0' && c <=
'9')
315 return (
unsigned char)(c -
'0');
316 if (c >=
'A' && c <=
'F')
317 return (
unsigned char)((
int)(c -
'A') + 10);
318 if (c >=
'a' && c <=
'f')
319 return (
unsigned char)((
int)(c -
'a') + 10);
324 const char * pubfn,
const char * pubid,
332 size_t sigpktlen = 0;
342 fprintf(stderr,
"==> check(%s, %s, %s, %s)\n", fn,
343 (sigfn ? sigfn :
"(null)"),
344 (pubfn ? pubfn :
"(null)"),
345 (pubid ? pubid :
"(null)"));
348 if (sigfn && *sigfn) {
353 fprintf(stderr,
"==> pgpReadPkts(%s) SIG %p[%u] ret %d\n", _sigfn, sigpkt, (
unsigned)sigpktlen, xx);
354 _sigfn =
_free(_sigfn);
357 _sigfn =
_free(_sigfn);
363 fprintf(stderr,
"==> pgpReadPkts(%s) SIG %p[%u] ret %d\n", _sigfn, sigpkt, (
unsigned)sigpktlen, xx);
364 _sigfn =
_free(_sigfn);
367 _sigfn =
_free(_sigfn);
372 xx = rpmhkpLoadSignature(
NULL, dig, pp);
377 fprintf(stderr,
"==> unverifiable V%u\n", (
unsigned)sigp->version);
382 ts->hkp = rpmhkpNew(
NULL, 0);
383 hkp = rpmhkpLink(ts->hkp);
386 if (pubfn && *pubfn) {
389 hkp->pkt =
_free(hkp->pkt);
395 fprintf(stderr,
"==> pgpReadPkts(%s) PUB %p[%u] ret %d\n", _pubfn, hkp->pkt, (
unsigned)hkp->pktlen, xx);
396 _pubfn =
_free(_pubfn);
399 _pubfn =
_free(_pubfn);
402 hkp->pkts =
_free(hkp->pkts);
404 xx =
pgpGrabPkts(hkp->pkt, hkp->pktlen, &hkp->pkts, &hkp->npkts);
408 memcpy(pubp->signid, hkp->keyid,
sizeof(pubp->signid));
412 xx = rpmhkpValidate(hkp,
NULL);
427 xx = rpmhkpFindKey(hkp, dig, sigp->signid, sigp->pubkey_algo);
431 _rpmhkpDumpDig(__FUNCTION__, dig);
436 fprintf(stderr,
"==> pgpFindPubkey ret %d\n", xx);
442 if (pubid && *pubid) {
443 size_t ns = strlen(pubid);
449 for (i = 0, s = pubid; *s && isxdigit(*s); s++, i++)
451 if (!(*s ==
'\0' && i > 8 && (i%2) == 0))
462 for (i = 0; i <
ns; i++)
463 t[i] = (
char)((
nibble(s[2*i]) << 4) |
nibble(s[2*i+1]));
466 s = (
const char *)pubp->signid;
467 xx = memcmp(t, s + (8 - ns),
ns);
475 fprintf(stderr,
"==> mismatched: pubkey id (%08x %08x) != %s\n",
482 if (!(sigp->pubkey_algo == pubp->pubkey_algo
484 && sigp->hash_algo == pubp->hash_algo
489 fprintf(stderr,
"==> mismatch between signature and pubkey\n");
490 fprintf(stderr,
"\tpubkey_algo: %u %u\n", (
unsigned)sigp->pubkey_algo, (
unsigned)pubp->pubkey_algo);
491 fprintf(stderr,
"\tsignid: %08X %08X %08X %08X\n",
502 static const char clrtxt[] =
"-----BEGIN PGP SIGNED MESSAGE-----";
503 static const char sigtxt[] =
"-----BEGIN PGP SIGNATURE-----";
508 if (!(_rc == 0 && iob !=
NULL)) {
510 fprintf(stderr,
"==> rpmiobSlurp(%s) MSG ret %d\n", _fn, _rc);
518 if (!strncmp((
char *)iob->b, clrtxt, strlen(clrtxt))) {
519 const char *
be = (
char *) (iob->b + iob->blen);
524 while (t && t < be && *t !=
'\n')
525 t = strchr(t,
'\n') + 1;
534 if (strncmp(t,
"- ", 2) == 0)
536 if ((teol = te = strchr(t,
'\n')) ==
NULL)
538 while (te > t && strchr(
" \t\r\n", te[-1]))
541 if (!strncmp((t = teol + 1), sigtxt, strlen(sigtxt)))
551 if (sigp->hash !=
NULL)
556 trailer[0] = sigp->version;
558 trailer[2] = (sigp->hashlen >> 24) & 0xff;
559 trailer[3] = (sigp->hashlen >> 16) & 0xff;
560 trailer[4] = (sigp->hashlen >> 8) & 0xff;
561 trailer[5] = (sigp->hashlen ) & 0xff;
566 switch(sigp->pubkey_algo) {
579 fprintf(stderr,
"==> can't load pubkey_algo(%u)\n", (
unsigned)sigp->pubkey_algo);
584 switch(sigp->pubkey_algo) {
595 sigpkt =
_free(sigpkt);
596 (
void) rpmhkpFree(hkp);
603 fprintf(stderr,
"============================ verify: %s\n",
static unsigned char nibble(char c)
Convert hex to binary nibble.
int pgpGrabPkts(const rpmuint8_t *pkts, size_t pktlen, rpmuint8_t ***pppkts, int *pnpkts)
Return array of packet pointers.
nsType rpmnsArch(const char *str)
Is string a known arch suffix?
enum nsType_e nsType
Dependency types.
int pgpPktLen(const rpmuint8_t *pkt, size_t pleft, pgpPkt pp)
OpenPGP constants and structures from RFC-2440.
int pgpPubkeyFingerprint(const rpmuint8_t *pkt, size_t pktlen, rpmuint8_t *keyid)
Print/parse an OpenPGP subtype packet.
#define _ENTRY(_s, _type)
Dependency probe table (must be sorted).
struct rpmts_s * rpmts
The RPM Transaction Set.
pgpDig rpmtsDig(rpmts ts)
Get OpenPGP packet parameters, i.e.
int pgpFindPubkey(pgpDig dig)
Call find pubkey vector.
nsType rpmnsProbe(const char *s, size_t slen)
Is string a known probe namespace?
static struct _rpmnsProbes_s rpmnsProbes[]
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
nsType rpmnsClassify(const char *s, size_t slen)
Classify a string as a dependency type.
static int pgpImplSetDSA(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
int rpmiobSlurp(const char *fn, rpmiob *iobp)
pgpArmor pgpReadPkts(const char *fn, rpmuint8_t **pkt, size_t *pktlen)
Parse armored OpenPGP packets from a file.
enum evrFlags_e evrFlags
Dependency Attributes.
enum rpmRC_e rpmRC
RPM return codes.
memset(_r, 0, sizeof(*_r))
rpmRC rpmnsProbeSignature(void *_ts, const char *fn, const char *sigfn, const char *pubfn, const char *pubid, int flags)
Verify OpenPGP signature on a file.
Structures and prototypes used for an "rpmps" problem set.
static const char * rpmnsArches[]
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
enum pgpHashAlgo_e pgpHashAlgo
9.4.
static int xisspace(int c)
int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
Update context with next plain text buffer.
pgpDigParams pgpGetSignature(pgpDig dig)
Return OpenPGP signature parameters.
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
Initialize digest.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
static int pgpImplSetRSA(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
static const char *char c
Return text between pl and matching pr characters.
return strcmp(ame->name, bme->name)
static int xisdigit(int c)
Structures and prototypes used for an "rpmts" transaction set.
static int pgpImplVerify(pgpDig dig)
struct pgpDigParams_s * pgpDigParams
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
int
Save source and expand field into target.
static unsigned int pgpGrab(const rpmuint8_t *s, size_t nbytes)
Return (native-endian) integer from big-endian representation.
Access RPM indices using Berkeley DB interface(s).
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
while((rc=poptGetNextOpt(optCon)) > 0)
static size_t rpmnsProbesCount
int rpmnsParse(const char *s, rpmns ns)
Expand and split NS(N).A string into namespace, name and arch components.
const char * _rpmns_N_at_A
pgpDigParams pgpGetPubkey(pgpDig dig)
Return OpenPGP pubkey parameters.
const unsigned char * digest
void rpmtsCleanDig(rpmts ts)
Free signature verification data.