summaryrefslogtreecommitdiff
path: root/lib/package.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-11-09 13:43:09 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-11-09 13:44:31 +0200
commit24eb3257f6335ab58d90ef21f0b0925ca9b9df24 (patch)
treeb9411a570e0f5c00c972c0088f75e8fee048623d /lib/package.c
parent5722245dd82f95185dd549f9de5af9549d7ccf02 (diff)
downloadlibrpm-tizen-24eb3257f6335ab58d90ef21f0b0925ca9b9df24.tar.gz
librpm-tizen-24eb3257f6335ab58d90ef21f0b0925ca9b9df24.tar.bz2
librpm-tizen-24eb3257f6335ab58d90ef21f0b0925ca9b9df24.zip
Eliminate uses of pgpDig in package reading & signature checking
- No functional changes, just eliminates pile of unnecessary allocations and other calls, simplifying the code a bit.
Diffstat (limited to 'lib/package.c')
-rw-r--r--lib/package.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/lib/package.c b/lib/package.c
index b5e238e20..3df81c97a 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -20,8 +20,6 @@
#include "debug.h"
-static int _print_pkts = 0;
-
static const unsigned int nkeyids_max = 256;
static unsigned int nkeyids = 0;
static unsigned int nextkeyid = 0;
@@ -137,19 +135,12 @@ static int stashKeyid(pgpDigParams sigp)
return 0;
}
-pgpDigParams parsePGPSig(rpmtd sigtd, const char *type, const char *fn,
- pgpDig *digp)
+int parsePGPSig(rpmtd sigtd, const char *type, const char *fn,
+ pgpDigParams *sig)
{
- int debug = (_print_pkts & rpmIsDebug());
- pgpDig dig = pgpNewDig();
- pgpDigParams sig = NULL;
-
- if ((pgpPrtPkts(sigtd->data, sigtd->count, dig, debug) == 0))
- sig = pgpDigGetParams(dig, PGPTAG_SIGNATURE);
+ int rc = pgpPrtParams(sigtd->data, sigtd->count, PGPTAG_SIGNATURE, sig);
- if (sig) {
- *digp = dig;
- } else {
+ if (rc != 0) {
if (type && fn) {
rpmlog(RPMLOG_ERR,
_("skipping %s %s with unverifiable signature\n"), type, fn);
@@ -157,9 +148,8 @@ pgpDigParams parsePGPSig(rpmtd sigtd, const char *type, const char *fn,
rpmlog(RPMLOG_ERR,
_("skipping %s with unverifiable signature\n"), type);
}
- pgpFreeDig(dig);
}
- return sig;
+ return rc;
}
/*
@@ -173,7 +163,6 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags,
{
size_t siglen = 0;
rpmRC rc = RPMRC_FAIL;
- pgpDig dig = NULL;
pgpDigParams sig = NULL;
struct rpmtd_s sigtd;
struct entryInfo_s info, einfo;
@@ -254,8 +243,7 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags,
switch (info.tag) {
case RPMTAG_RSAHEADER:
case RPMTAG_DSAHEADER:
- sig = parsePGPSig(&sigtd, "header", NULL, &dig);
- if (sig == NULL)
+ if (parsePGPSig(&sigtd, "header", NULL, &sig))
goto exit;
hashalgo = pgpDigParamsAlgo(sig, PGPVAL_HASHALGO);
break;
@@ -282,7 +270,7 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags,
exit:
rpmtdFreeData(&sigtd);
- pgpFreeDig(dig);
+ pgpDigParamsFree(sig);
return rc;
}
@@ -503,7 +491,6 @@ rpmRC rpmReadHeader(rpmts ts, FD_t fd, Header *hdrp, char ** msg)
static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
FD_t fd, const char * fn, Header * hdrp)
{
- pgpDig dig = NULL;
pgpDigParams sig = NULL;
char buf[8*BUFSIZ];
ssize_t count;
@@ -606,8 +593,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
switch (sigtag) {
case RPMSIGTAG_RSA:
case RPMSIGTAG_DSA:
- sig = parsePGPSig(&sigtd, "package", fn, &dig);
- if (sig == NULL)
+ if (parsePGPSig(&sigtd, "package", fn, &sig))
goto exit;
/* fallthrough */
case RPMSIGTAG_SHA1:
@@ -626,8 +612,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
case RPMSIGTAG_GPG:
case RPMSIGTAG_PGP5: /* XXX legacy */
case RPMSIGTAG_PGP:
- sig = parsePGPSig(&sigtd, "package", fn, &dig);
- if (sig == NULL)
+ if (parsePGPSig(&sigtd, "package", fn, &sig))
goto exit;
/* fallthrough */
case RPMSIGTAG_MD5:
@@ -704,7 +689,7 @@ exit:
rpmtdFreeData(&sigtd);
rpmDigestFinal(ctx, NULL, NULL, 0);
h = headerFree(h);
- pgpFreeDig(dig);
+ pgpDigParamsFree(sig);
sigh = rpmFreeSignature(sigh);
return rc;
}