summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-11-09 11:59:31 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-11-09 11:59:31 +0200
commit564242f23b9b449556c6ed21b8fb3cf8099d956a (patch)
tree82fc029bc9747e50b3c9261785d1724ecd708536 /rpmio
parent345a0612409ef8bc82b2cae90a71c8131bd84f7a (diff)
downloadrpm-564242f23b9b449556c6ed21b8fb3cf8099d956a.tar.gz
rpm-564242f23b9b449556c6ed21b8fb3cf8099d956a.tar.bz2
rpm-564242f23b9b449556c6ed21b8fb3cf8099d956a.zip
Parse pubkey parameters on rpmPubkeyNew() already and store results
- Yet more pre-requisites for separating key and signature management. In addition this gains us more thorough initial sanity checking and will allow reusing the parameters instead of having to parse the same packets over and over again on every single verification against this key. Unfortunately rpmKeyringLookup() is so braindead it prevents us from doing this right now, we'll need a better interface to take advantage of the stored pgp key parameters.
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmkeyring.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/rpmio/rpmkeyring.c b/rpmio/rpmkeyring.c
index 30aa61a63..3be7bd1c0 100644
--- a/rpmio/rpmkeyring.c
+++ b/rpmio/rpmkeyring.c
@@ -15,6 +15,7 @@ struct rpmPubkey_s {
uint8_t *pkt;
size_t pktlen;
pgpKeyID_t keyid;
+ pgpDigParams pgpkey;
int nrefs;
};
@@ -124,6 +125,7 @@ exit:
rpmPubkey rpmPubkeyNew(const uint8_t *pkt, size_t pktlen)
{
rpmPubkey key = NULL;
+ pgpDigParams pgpkey = NULL;
pgpKeyID_t keyid;
if (pkt == NULL || pktlen == 0)
@@ -132,9 +134,13 @@ rpmPubkey rpmPubkeyNew(const uint8_t *pkt, size_t pktlen)
if (pgpPubkeyFingerprint(pkt, pktlen, keyid))
goto exit;
+ if (pgpPrtParams(pkt, pktlen, PGPTAG_PUBLIC_KEY, &pgpkey))
+ goto exit;
+
key = xcalloc(1, sizeof(*key));
key->pkt = xmalloc(pktlen);
key->pktlen = pktlen;
+ key->pgpkey = pgpkey;
key->nrefs = 0;
memcpy(key->pkt, pkt, pktlen);
memcpy(key->keyid, keyid, sizeof(keyid));
@@ -151,6 +157,7 @@ rpmPubkey rpmPubkeyFree(rpmPubkey key)
if (key->nrefs > 1)
return rpmPubkeyUnlink(key);
+ pgpDigParamsFree(key->pgpkey);
free(key->pkt);
free(key);
return NULL;