diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-03-10 14:27:08 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-03-10 14:27:08 +0200 |
commit | eab03f0e3b1d10e82ee20110bee8bc1d00ee991f (patch) | |
tree | 7b75fefe6ef513d3c90b9d63601742569d6a44fd /lib/rpmchecksig.c | |
parent | 65f7f7c3ce1a9b5245bcd9deba0c6346cce9acd0 (diff) | |
download | librpm-tizen-eab03f0e3b1d10e82ee20110bee8bc1d00ee991f.tar.gz librpm-tizen-eab03f0e3b1d10e82ee20110bee8bc1d00ee991f.tar.bz2 librpm-tizen-eab03f0e3b1d10e82ee20110bee8bc1d00ee991f.zip |
Lift best signature detection out of rpmVerifySignatures()
Diffstat (limited to 'lib/rpmchecksig.c')
-rw-r--r-- | lib/rpmchecksig.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c index c993c9a9d..6e1093b60 100644 --- a/lib/rpmchecksig.c +++ b/lib/rpmchecksig.c @@ -522,6 +522,33 @@ static rpmRC parsePGP(rpmtd sigtd, const char *fn, pgpDig dig) } return rc; } + +/* + * Figure best available signature. + * XXX TODO: Similar detection in rpmReadPackageFile(), unify these. + */ +static rpmSigTag bestSig(Header sigh, int nosignatures, int nodigests) +{ + rpmSigTag sigtag = 0; + if (sigtag == 0 && !nosignatures) { + if (headerIsEntry(sigh, RPMSIGTAG_DSA)) + sigtag = RPMSIGTAG_DSA; + else if (headerIsEntry(sigh, RPMSIGTAG_RSA)) + sigtag = RPMSIGTAG_RSA; + else if (headerIsEntry(sigh, RPMSIGTAG_GPG)) + sigtag = RPMSIGTAG_GPG; + else if (headerIsEntry(sigh, RPMSIGTAG_PGP)) + sigtag = RPMSIGTAG_PGP; + } + if (sigtag == 0 && !nodigests) { + if (headerIsEntry(sigh, RPMSIGTAG_MD5)) + sigtag = RPMSIGTAG_MD5; + else if (headerIsEntry(sigh, RPMSIGTAG_SHA1)) + sigtag = RPMSIGTAG_SHA1; /* XXX never happens */ + } + return sigtag; +} + static const char *sigtagname(rpmSigTag sigtag, int upper) { const char *n = NULL; @@ -646,23 +673,7 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd, msg = _free(msg); /* Grab a hint of what needs doing to avoid duplication. */ - sigtag = 0; - if (sigtag == 0 && !nosignatures) { - if (headerIsEntry(sigh, RPMSIGTAG_DSA)) - sigtag = RPMSIGTAG_DSA; - else if (headerIsEntry(sigh, RPMSIGTAG_RSA)) - sigtag = RPMSIGTAG_RSA; - else if (headerIsEntry(sigh, RPMSIGTAG_GPG)) - sigtag = RPMSIGTAG_GPG; - else if (headerIsEntry(sigh, RPMSIGTAG_PGP)) - sigtag = RPMSIGTAG_PGP; - } - if (sigtag == 0 && !nodigests) { - if (headerIsEntry(sigh, RPMSIGTAG_MD5)) - sigtag = RPMSIGTAG_MD5; - else if (headerIsEntry(sigh, RPMSIGTAG_SHA1)) - sigtag = RPMSIGTAG_SHA1; /* XXX never happens */ - } + sigtag = bestSig(sigh, nosignatures, nodigests); dig = pgpNewDig(); sigp = &dig->signature; |