diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-11-07 14:47:03 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-11-07 14:47:03 +0200 |
commit | cde47f5945e16033395b5d0023a550b4c01ba0e7 (patch) | |
tree | 096c96ee0c840df3703de913e4da47209bcf1092 /lib | |
parent | a6f25aff4343c2f67d3fcbfe69929d518327d35f (diff) | |
download | librpm-tizen-cde47f5945e16033395b5d0023a550b4c01ba0e7.tar.gz librpm-tizen-cde47f5945e16033395b5d0023a550b4c01ba0e7.tar.bz2 librpm-tizen-cde47f5945e16033395b5d0023a550b4c01ba0e7.zip |
Use pgpDigParamsAlgo() throughout the codebase
- Tedious but straightforward conversion to use the API instead
of going to the struct directly.
- Remove digest.h includes where no longer necessary
Diffstat (limited to 'lib')
-rw-r--r-- | lib/formats.c | 6 | ||||
-rw-r--r-- | lib/package.c | 14 | ||||
-rw-r--r-- | lib/rpmchecksig.c | 9 | ||||
-rw-r--r-- | lib/signature.c | 1 |
4 files changed, 17 insertions, 13 deletions
diff --git a/lib/formats.c b/lib/formats.c index 5b9f26a7d..4d0500ece 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -434,6 +434,8 @@ static char * pgpsigFormat(rpmtd td) unsigned int dateint = pgpGrab(sigp->time, sizeof(sigp->time)); time_t date = dateint; struct tm * tms = localtime(&date); + unsigned int key_algo = pgpDigParamsAlgo(sigp, PGPVAL_PUBKEYALGO); + unsigned int hash_algo = pgpDigParamsAlgo(sigp, PGPVAL_HASHALGO); if (!(tms && strftime(dbuf, sizeof(dbuf), "%c", tms) > 0)) { snprintf(dbuf, sizeof(dbuf), @@ -442,8 +444,8 @@ static char * pgpsigFormat(rpmtd td) } rasprintf(&val, "%s/%s, %s, Key ID %s\n", - pgpValString(PGPVAL_PUBKEYALGO, sigp->pubkey_algo), - pgpValString(PGPVAL_HASHALGO, sigp->hash_algo), + pgpValString(PGPVAL_PUBKEYALGO, key_algo), + pgpValString(PGPVAL_HASHALGO, hash_algo), dbuf, keyid); free(keyid); diff --git a/lib/package.c b/lib/package.c index 4cd99ff45..e29c23c9f 100644 --- a/lib/package.c +++ b/lib/package.c @@ -177,7 +177,7 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags, pgpDigParams sig = NULL; struct rpmtd_s sigtd; struct entryInfo_s info, einfo; - int hashalgo = 0; + unsigned int hashalgo = 0; rpmtdReset(&sigtd); memset(&info, 0, sizeof(info)); @@ -257,7 +257,7 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags, sig = parsePGPSig(&sigtd, "header", NULL, &dig); if (sig == NULL) goto exit; - hashalgo = sig->hash_algo; + hashalgo = pgpDigParamsAlgo(sig, PGPVAL_HASHALGO); break; case RPMTAG_SHA1HEADER: hashalgo = PGPHASHALGO_SHA1; @@ -612,8 +612,9 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags, /* fallthrough */ case RPMSIGTAG_SHA1: { struct rpmtd_s utd; - int hashalgo = (sigtag == RPMSIGTAG_SHA1) ? - PGPHASHALGO_SHA1 : sig->hash_algo; + unsigned int hashalgo = (sigtag == RPMSIGTAG_SHA1) ? + PGPHASHALGO_SHA1 : + pgpDigParamsAlgo(sig, PGPVAL_HASHALGO); if (!headerGet(h, RPMTAG_HEADERIMMUTABLE, &utd, hgeflags)) break; @@ -639,8 +640,9 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags, goto exit; } - ctx = rpmDigestBundleDupCtx(fdGetBundle(fd), (sigtag == RPMSIGTAG_MD5) ? - PGPHASHALGO_MD5 : sig->hash_algo); + ctx = rpmDigestBundleDupCtx(fdGetBundle(fd),(sigtag == RPMSIGTAG_MD5) ? + PGPHASHALGO_MD5 : + pgpDigParamsAlgo(sig, PGPVAL_HASHALGO)); break; default: break; diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c index 879868f2f..597ceafbb 100644 --- a/lib/rpmchecksig.c +++ b/lib/rpmchecksig.c @@ -17,7 +17,6 @@ #include <rpm/rpmstring.h> #include <rpm/rpmkeyring.h> -#include "rpmio/digest.h" #include "rpmio/rpmio_internal.h" /* fdSetBundle() */ #include "lib/rpmlead.h" #include "lib/signature.h" @@ -291,6 +290,7 @@ static int rpmpkgVerifySigs(rpmKeyring keyring, rpmQueryFlags flags, /* XXX RSA needs the hash_algo, so decode early. */ if (sigtag == RPMSIGTAG_RSA || sigtag == RPMSIGTAG_PGP || sigtag == RPMSIGTAG_DSA || sigtag == RPMSIGTAG_GPG) { + unsigned int hashalgo; if (headerGet(sigh, sigtag, &sigtd, HEADERGET_DEFAULT)) { sig = parsePGPSig(&sigtd, "package", fn, &dig); rpmtdFreeData(&sigtd); @@ -298,8 +298,9 @@ static int rpmpkgVerifySigs(rpmKeyring keyring, rpmQueryFlags flags, if (sig == NULL) goto exit; /* XXX assume same hash_algo in header-only and header+payload */ - rpmDigestBundleAdd(plbundle, sig->hash_algo, RPMDIGEST_NONE); - rpmDigestBundleAdd(hdrbundle, sig->hash_algo, RPMDIGEST_NONE); + hashalgo = pgpDigParamsAlgo(sig, PGPVAL_HASHALGO); + rpmDigestBundleAdd(plbundle, hashalgo, RPMDIGEST_NONE); + rpmDigestBundleAdd(hdrbundle, hashalgo, RPMDIGEST_NONE); } if (headerIsEntry(sigh, RPMSIGTAG_PGP) || @@ -346,7 +347,7 @@ static int rpmpkgVerifySigs(rpmKeyring keyring, rpmQueryFlags flags, if (sig == NULL) goto exit; ctx = rpmDigestBundleDupCtx(havekey ? plbundle : hdrbundle, - sig->hash_algo); + pgpDigParamsAlgo(sig, PGPVAL_HASHALGO)); break; case RPMSIGTAG_SHA1: if (nodigests) diff --git a/lib/signature.c b/lib/signature.c index 971a752d9..eec5ff7a3 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -13,7 +13,6 @@ #include <rpm/rpmlog.h> #include <rpm/rpmkeyring.h> -#include "rpmio/digest.h" #include "lib/rpmlead.h" #include "lib/signature.h" #include "lib/header_internal.h" |