Parse pubkey parameters on rpmPubkeyNew() already and store results
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 9 Nov 2011 09:59:31 +0000 (11:59 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 9 Nov 2011 09:59:31 +0000 (11:59 +0200)
- 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.

rpmio/rpmkeyring.c

index 30aa61a..3be7bd1 100644 (file)
@@ -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;