diff options
-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 | ||||
-rw-r--r-- | sign/rpmgensig.c | 16 |
5 files changed, 26 insertions, 20 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" diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c index 368f2aa41..e6c7659e8 100644 --- a/sign/rpmgensig.c +++ b/sign/rpmgensig.c @@ -17,7 +17,6 @@ #include <rpm/rpmlog.h> #include <rpm/rpmstring.h> -#include "rpmio/digest.h" #include "lib/rpmlead.h" #include "lib/signature.h" @@ -120,6 +119,8 @@ static int putSignature(Header sigh, int ishdr, uint8_t *pkt, size_t pktlen) rpmTagVal sigtag; struct rpmtd_s sigtd; int rc = 1; /* assume failure */ + unsigned int hash_algo; + unsigned int pubkey_algo; if (pgpPrtPkts(pkt, pktlen, dig, 0) == 0) sigp = pgpDigGetParams(dig, PGPTAG_SIGNATURE); @@ -129,13 +130,14 @@ static int putSignature(Header sigh, int ishdr, uint8_t *pkt, size_t pktlen) goto exit; } - if (rpmDigestLength(sigp->hash_algo) == 0) { - rpmlog(RPMLOG_ERR, _("Unsupported PGP hash algorithm %d\n"), - sigp->hash_algo); + hash_algo = pgpDigParamsAlgo(sigp, PGPVAL_HASHALGO); + if (rpmDigestLength(hash_algo) == 0) { + rpmlog(RPMLOG_ERR, _("Unsupported PGP hash algorithm %u\n"), hash_algo); goto exit; } - switch (sigp->pubkey_algo) { + pubkey_algo = pgpDigParamsAlgo(sigp, PGPVAL_PUBKEYALGO); + switch (pubkey_algo) { case PGPPUBKEYALGO_DSA: sigtag = ishdr ? RPMSIGTAG_DSA : RPMSIGTAG_GPG; break; @@ -143,8 +145,8 @@ static int putSignature(Header sigh, int ishdr, uint8_t *pkt, size_t pktlen) sigtag = ishdr ? RPMSIGTAG_RSA : RPMSIGTAG_PGP; break; default: - rpmlog(RPMLOG_ERR, _("Unsupported PGP pubkey algorithm %d\n"), - sigp->pubkey_algo); + rpmlog(RPMLOG_ERR, _("Unsupported PGP pubkey algorithm %u\n"), + pubkey_algo); goto exit; break; } |