RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/lib/ package.c rpmchecksig.c rpmts.c rpmts...

From: Jeff Johnson <jbj@rpm5.org>
Date: Sun 09 Sep 2007 - 17:42:52 CEST
Message-Id: <20070909154252.46119348459@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   09-Sep-2007 17:42:52
  Branch: HEAD                             Handle: 2007090916425001

  Modified files:
    rpm                     CHANGES
    rpm/lib                 package.c rpmchecksig.c rpmts.c rpmts.h
                            signature.c
    rpm/rpmio               librpmio.vers rpmio_internal.h rpmpgp.c rpmpgp.h

  Log:
    - refactor signature components from ts into dig container.

  Summary:
    Revision    Changes     Path
    1.1629      +1  -0      rpm/CHANGES
    2.157       +5  -5      rpm/lib/package.c
    1.142       +2  -2      rpm/lib/rpmchecksig.c
    2.93        +14 -37     rpm/lib/rpmts.c
    2.71        +2  -7      rpm/lib/rpmts.h
    2.188       +20 -20     rpm/lib/signature.c
    2.9         +7  -0      rpm/rpmio/librpmio.vers
    2.78        +5  -0      rpm/rpmio/rpmio_internal.h
    2.56        +45 -0      rpm/rpmio/rpmpgp.c
    2.46        +64 -0      rpm/rpmio/rpmpgp.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1628 -r1.1629 CHANGES
  --- rpm/CHANGES	8 Sep 2007 23:44:00 -0000	1.1628
  +++ rpm/CHANGES	9 Sep 2007 15:42:50 -0000	1.1629
  @@ -1,4 +1,5 @@
   4.5 -> 5.0:
  +    - jbj: refactor signature components from ts into dig container.
       - jbj: add size_t *lenp to headerUnload().
       - jbj: consistent naming in rpmdb/pkgio.c
       - jbj: eliminate rpmNewSignature() and rpmFreeSignature().
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/package.c
  ============================================================================
  $ cvs diff -u -r2.156 -r2.157 package.c
  --- rpm/lib/package.c	9 Sep 2007 05:02:44 -0000	2.156
  +++ rpm/lib/package.c	9 Sep 2007 15:42:50 -0000	2.157
  @@ -208,7 +208,7 @@
   {
       const void * sig = rpmtsSig(ts);
       pgpDig dig = rpmtsDig(ts);
  -    pgpDigParams sigp = rpmtsSignature(ts);
  +    pgpDigParams sigp = pgpGetSignature(dig);
       unsigned int keyid;
       int i;
   
  @@ -477,7 +477,7 @@
   	    rpmMessage(RPMMESS_ERROR,
   		_("skipping header with unverifiable V%u signature\n"),
   		dig->signature.version);
  -	    ts->sig = headerFreeData(ts->sig, ts->sigtype);
  +	    (void) rpmtsSetSig(ts, 0, 0, NULL, 0);	/* XXX headerFreeData */
   	    ts->dig = pgpFreeDig(ts->dig);
   	    rc = RPMRC_FAIL;
   	    goto exit;
  @@ -521,7 +521,7 @@
   	    rpmMessage(RPMMESS_ERROR,
   		_("skipping header with unverifiable V%u signature\n"),
   		dig->signature.version);
  -	    ts->sig = headerFreeData(ts->sig, ts->sigtype);
  +	    (void) rpmtsSetSig(ts, 0, 0, NULL, 0);	/* XXX headerFreeData */
   	    ts->dig = pgpFreeDig(ts->dig);
   	    rc = RPMRC_FAIL;
   	    goto exit;
  @@ -578,7 +578,7 @@
   
       /* XXX headerCheck can recurse, free info only at top level. */
       if (hclvl == 1) {
  -	ts->sig = headerFreeData(ts->sig, ts->sigtype);
  +	(void) rpmtsSetSig(ts, 0, 0, NULL, 0);	/* XXX headerFreeData */
   	ts->dig = pgpFreeDig(ts->dig);
       }
       if (info->tag == RPMTAG_SHA1HEADER)
  @@ -1041,7 +1041,7 @@
       (void) rpmswSub(rpmtsOp(ts, RPMTS_OP_READHDR),
   		opsave);
   
  -    ts->sig = headerFreeData(ts->sig, ts->sigtype);
  +    (void) rpmtsSetSig(ts, 0, 0, NULL, 0);	/* XXX headerFreeData */
       ts->dig = pgpFreeDig(ts->dig);
       sigh = headerFree(sigh);
       return rc;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmchecksig.c
  ============================================================================
  $ cvs diff -u -r1.141 -r1.142 rpmchecksig.c
  --- rpm/lib/rpmchecksig.c	8 Sep 2007 22:47:37 -0000	1.141
  +++ rpm/lib/rpmchecksig.c	9 Sep 2007 15:42:50 -0000	1.142
  @@ -844,7 +844,7 @@
   
   	dig = rpmtsDig(ts);
   assert(dig != NULL);
  -	sigp = rpmtsSignature(ts);
  +	sigp = pgpGetSignature(dig);
   
   	/* XXX RSA needs the hash_algo, so decode early. */
   	if (sigtag == RPMSIGTAG_RSA
  @@ -1134,7 +1134,7 @@
       }
   
   exit:
  -    ts->sig = headerFreeData(ts->sig, ts->sigtype);
  +    (void) rpmtsSetSig(ts, 0, 0, NULL, 0);	/* XXX headerFreeData */
       ts->dig = pgpFreeDig(ts->dig);
       sigh = headerFree(sigh);
       return res;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmts.c
  ============================================================================
  $ cvs diff -u -r2.92 -r2.93 rpmts.c
  --- rpm/lib/rpmts.c	8 Sep 2007 21:01:25 -0000	2.92
  +++ rpm/lib/rpmts.c	9 Sep 2007 15:42:50 -0000	2.93
  @@ -737,7 +737,7 @@
   
       ts->probs = rpmpsFree(ts->probs);
   
  -    ts->sig = headerFreeData(ts->sig, ts->sigtype);
  +    (void) rpmtsSetSig(ts, 0, 0, NULL, 0);	/* XXX headerFreeData */
       ts->dig = pgpFreeDig(ts->dig);
   }
   
  @@ -1097,50 +1097,36 @@
   
   int_32 rpmtsSigtag(const rpmts ts)
   {
  -    int_32 sigtag = 0;
  -    if (ts != NULL)
  -	sigtag = ts->sigtag;
  -    return sigtag;
  +    return pgpGetSigtag(rpmtsDig(ts));
   }
   
   int_32 rpmtsSigtype(const rpmts ts)
   {
  -    int_32 sigtype = 0;
  -    if (ts != NULL)
  -	sigtype = ts->sigtype;
  -    return sigtype;
  +    return pgpGetSigtype(rpmtsDig(ts));
   }
   
   const void * rpmtsSig(const rpmts ts)
   {
  -    const void * sig = NULL;
  -    if (ts != NULL)
  -	sig = ts->sig;
  -    return sig;
  +    return pgpGetSig(rpmtsDig(ts));
   }
   
   int_32 rpmtsSiglen(const rpmts ts)
   {
  -    int_32 siglen = 0;
  -    if (ts != NULL)
  -	siglen = ts->siglen;
  -    return siglen;
  +    return pgpGetSiglen(rpmtsDig(ts));
   }
   
   int rpmtsSetSig(rpmts ts,
   		int_32 sigtag, int_32 sigtype, const void * sig, int_32 siglen)
   {
  +    int ret = 0;
       if (ts != NULL) {
  -	if (ts->sig && ts->sigtype)
  -	    ts->sig = headerFreeData(ts->sig, ts->sigtype);
  -	ts->sigtag = sigtag;
  -	ts->sigtype = (sig ? sigtype : 0);
  -/*@-assignexpose -kepttrans@*/
  -	ts->sig = sig;
  -/*@=assignexpose =kepttrans@*/
  -	ts->siglen = siglen;
  +	const void * osig = pgpGetSig(rpmtsDig(ts));
  +	int_32 osigtype = pgpGetSiglen(rpmtsDig(ts));
  +	if (osig && osigtype)
  +	    osig = headerFreeData(osig, osigtype);
  +	ret = pgpSetSig(rpmtsDig(ts), sigtag, sigtype, sig, siglen);
       }
  -    return 0;
  +    return ret;
   }
   
   pgpDig rpmtsDig(rpmts ts)
  @@ -1156,20 +1142,12 @@
   
   pgpDigParams rpmtsSignature(const rpmts ts)
   {
  -    pgpDig dig = rpmtsDig(ts);
  -    if (dig == NULL) return NULL;
  -/*@-immediatetrans@*/
  -    return &dig->signature;
  -/*@=immediatetrans@*/
  +    return pgpGetSignature(rpmtsDig(ts));
   }
   
   pgpDigParams rpmtsPubkey(const rpmts ts)
   {
  -    pgpDig dig = rpmtsDig(ts);
  -    if (dig == NULL) return NULL;
  -/*@-immediatetrans@*/
  -    return &dig->pubkey;
  -/*@=immediatetrans@*/
  +    return pgpGetPubkey(rpmtsDig(ts));
   }
   
   rpmdb rpmtsGetRdb(rpmts ts)
  @@ -1637,7 +1615,6 @@
   
       ts->probs = NULL;
   
  -    ts->sig = NULL;
       ts->pkpkt = NULL;
       ts->pkpktlen = 0;
       memset(ts->pksignid, 0, sizeof(ts->pksignid));
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmts.h
  ============================================================================
  $ cvs diff -u -r2.70 -r2.71 rpmts.h
  --- rpm/lib/rpmts.h	8 Sep 2007 21:01:25 -0000	2.70
  +++ rpm/lib/rpmts.h	9 Sep 2007 15:42:50 -0000	2.71
  @@ -252,11 +252,6 @@
   
   /*@observer@*/ /*@dependent@*/ /*@null@*/
       const char * fn;		/*!< Current package fn. */
  -    int_32  sigtag;		/*!< Current package signature tag. */
  -    int_32  sigtype;		/*!< Current package signature data type. */
  -/*@null@*/
  -    const void * sig;		/*!< Current package signature. */
  -    int_32 siglen;		/*!< Current package signature length. */
   
   /*@only@*/ /*@null@*/
       const unsigned char * pkpkt;/*!< Current pubkey packet. */
  @@ -785,7 +780,7 @@
   	/*@*/;
   
   /** \ingroup rpmts
  - * Get OpenPGP signature constants.
  + * Return OpenPGP signature constants.
    * @param ts		transaction set
    * @return		signature constants.
    */
  @@ -794,7 +789,7 @@
   	/*@*/;
   
   /** \ingroup rpmts
  - * Get OpenPGP pubkey constants.
  + * Return OpenPGP pubkey constants.
    * @param ts		transaction set
    * @return		pubkey constants.
    */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/signature.c
  ============================================================================
  $ cvs diff -u -r2.187 -r2.188 signature.c
  --- rpm/lib/signature.c	8 Sep 2007 22:42:36 -0000	2.187
  +++ rpm/lib/signature.c	9 Sep 2007 15:42:51 -0000	2.188
  @@ -708,8 +708,8 @@
   verifySizeSignature(const rpmts ts, /*@out@*/ char * t)
   	/*@modifies *t @*/
   {
  -    const void * sig = rpmtsSig(ts);
       pgpDig dig = rpmtsDig(ts);
  +    const void * sig = pgpGetSig(dig);
       rpmRC res;
       int_32 size = 0x7fffffff;
   
  @@ -745,9 +745,9 @@
   	/*@globals internalState @*/
   	/*@modifies *t, internalState @*/
   {
  -    const void * sig = rpmtsSig(ts);
  -    int_32 siglen = rpmtsSiglen(ts);
       pgpDig dig = rpmtsDig(ts);
  +    const void * sig = pgpGetSig(dig);
  +    int_32 siglen = pgpGetSiglen(dig);
       rpmRC res;
       byte * md5sum = NULL;
       size_t md5len = 0;
  @@ -801,11 +801,11 @@
   	/*@globals internalState @*/
   	/*@modifies *t, internalState @*/
   {
  -    const void * sig = rpmtsSig(ts);
  +    pgpDig dig = rpmtsDig(ts);
  +    const void * sig = pgpGetSig(dig);
   #ifdef	NOTYET
  -    int_32 siglen = rpmtsSiglen(ts);
  +    int_32 siglen = pgpGetSiglen(dig);
   #endif
  -    pgpDig dig = rpmtsDig(ts);
       rpmRC res;
       const char * SHA1 = NULL;
   
  @@ -873,13 +873,13 @@
   	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
   	/*@modifies ts, *t, rpmGlobalMacroContext, fileSystem, internalState */
   {
  -    const void * sig = rpmtsSig(ts);
  +    pgpDig dig = rpmtsDig(ts);
  +    const void * sig = pgpGetSig(dig);
   #ifdef	NOTYET
  -    int_32 siglen = rpmtsSiglen(ts);
  +    int_32 siglen = pgpGetSiglen(dig);
   #endif
  -    int_32 sigtag = rpmtsSigtag(ts);
  -    pgpDig dig = rpmtsDig(ts);
  -    pgpDigParams sigp = rpmtsSignature(ts);
  +    int_32 sigtag = pgpGetSigtag(dig);
  +    pgpDigParams sigp = pgpGetSignature(dig);
       const char * prefix = NULL;
       rpmRC res = RPMRC_OK;
       int xx;
  @@ -1067,13 +1067,13 @@
   	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
   	/*@modifies ts, *t, rpmGlobalMacroContext, fileSystem, internalState */
   {
  -    const void * sig = rpmtsSig(ts);
  +    pgpDig dig = rpmtsDig(ts);
  +    const void * sig = pgpGetSig(dig);
   #ifdef	NOTYET
  -    int_32 siglen = rpmtsSiglen(ts);
  +    int_32 siglen = pgpGetSiglen(dig);
   #endif
  -    int_32 sigtag = rpmtsSigtag(ts);
  -    pgpDig dig = rpmtsDig(ts);
  -    pgpDigParams sigp = rpmtsSignature(ts);
  +    int_32 sigtag = pgpGetSigtag(dig);
  +    pgpDigParams sigp = pgpGetSignature(dig);
       rpmRC res;
       int xx;
   
  @@ -1166,13 +1166,13 @@
   rpmRC
   rpmVerifySignature(const rpmts ts, char * result)
   {
  -    const void * sig = rpmtsSig(ts);
  -    int_32 siglen = rpmtsSiglen(ts);
  -    int_32 sigtag = rpmtsSigtag(ts);
       pgpDig dig = rpmtsDig(ts);
  +    const void * sig = pgpGetSig(dig);
  +    int_32 siglen = pgpGetSiglen(dig);
  +    int_32 sigtag = pgpGetSigtag(dig);
       rpmRC res;
   
  -    if (sig == NULL || siglen <= 0 || dig == NULL) {
  +    if (dig == NULL || sig == NULL || siglen <= 0) {
   	sprintf(result, _("Verify signature: BAD PARAMETERS\n"));
   	return RPMRC_NOTFOUND;
       }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/librpmio.vers
  ============================================================================
  $ cvs diff -u -r2.8 -r2.9 librpmio.vers
  --- rpm/rpmio/librpmio.vers	28 Aug 2007 20:00:07 -0000	2.8
  +++ rpm/rpmio/librpmio.vers	9 Sep 2007 15:42:51 -0000	2.9
  @@ -148,6 +148,12 @@
       pgpCleanDig;
       pgpCompressionTbl;
       pgpFreeDig;
  +    pgpGetPubkey;
  +    pgpGetSignature;
  +    pgpGetSigtag;
  +    pgpGetSigtype;
  +    pgpGetSig;
  +    pgpGetSiglen;
       pgpHashTbl;
       pgpKeyServerPrefsTbl;
       pgpNewDig;
  @@ -164,6 +170,7 @@
       pgpPktLen;
       pgpPubkeyTbl;
       pgpReadPkts;
  +    pgpSetSig;
       pgpSigTypeTbl;
       pgpSubTypeTbl;
       pgpSymkeyTbl;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio_internal.h
  ============================================================================
  $ cvs diff -u -r2.77 -r2.78 rpmio_internal.h
  --- rpm/rpmio/rpmio_internal.h	16 Jul 2007 09:14:57 -0000	2.77
  +++ rpm/rpmio/rpmio_internal.h	9 Sep 2007 15:42:51 -0000	2.78
  @@ -63,6 +63,11 @@
       struct pgpDigParams_s signature;
       struct pgpDigParams_s pubkey;
   
  +    int32_t sigtag;		/*!< Package signature tag. */
  +    int32_t sigtype;		/*!< Package signature data type. */
  +    const void * sig;		/*!< Package signature. */
  +    int32_t siglen;		/*!< Package signature length. */
  +
       byte ** ppkts;
       int npkts;
       size_t nbytes;		/*!< No. bytes of plain text. */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmpgp.c
  ============================================================================
  $ cvs diff -u -r2.55 -r2.56 rpmpgp.c
  --- rpm/rpmio/rpmpgp.c	10 Jul 2007 19:04:55 -0000	2.55
  +++ rpm/rpmio/rpmpgp.c	9 Sep 2007 15:42:51 -0000	2.56
  @@ -1131,6 +1131,51 @@
       return dig;
   }
   
  +pgpDigParams pgpGetSignature(pgpDig dig)
  +{
  +    return (dig ? &dig->signature : NULL);
  +}
  +
  +pgpDigParams pgpGetPubkey(pgpDig dig)
  +{
  +    return (dig ? &dig->pubkey : NULL);
  +}
  +
  +int32_t pgpGetSigtag(pgpDig dig)
  +{
  +    return (dig ? dig->sigtag : 0);
  +}
  +
  +int32_t pgpGetSigtype(pgpDig dig)
  +{
  +    return (dig ? dig->sigtype : 0);
  +}
  +
  +const void * pgpGetSig(pgpDig dig)
  +{
  +    return (dig ? dig->sig : NULL);
  +}
  +
  +int32_t pgpGetSiglen(pgpDig dig)
  +{
  +    return (dig ? dig->siglen : 0);
  +}
  +
  +int pgpSetSig(pgpDig dig,
  +	int32_t sigtag, int32_t sigtype, const void * sig, int32_t siglen)
  +{
  +    if (dig != NULL) {
  +	/* XXX lazy free? */
  +	dig->sigtag = sigtag;
  +	dig->sigtype = (sig ? sigtype : 0);
  +/*@-assignexpose -kepttrans@*/
  +	dig->sig = sig;
  +/*@=assignexpose =kepttrans@*/
  +	dig->siglen = siglen;
  +    }
  +    return 0;
  +}
  +
   static int pgpGrabPkts(const byte * pkts, unsigned int pktlen,
   		/*@out@*/ byte *** pppkts, /*@out@*/ int * pnpkts)
   	/*@modifies *pppkts, *pnpkts @*/
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmpgp.h
  ============================================================================
  $ cvs diff -u -r2.45 -r2.46 rpmpgp.h
  --- rpm/rpmio/rpmpgp.h	10 Jul 2007 13:09:24 -0000	2.45
  +++ rpm/rpmio/rpmpgp.h	9 Sep 2007 15:42:51 -0000	2.46
  @@ -1344,6 +1344,70 @@
   	/*@modifies dig @*/;
   
   /**
  + * Return OpenPGP pubkey parameters.
  + * @param dig		container
  + * @return		pubkey parameters
  + */
  +pgpDigParams pgpGetPubkey(const pgpDig dig)
  +	/*@*/;
  +
  +/**
  + * Return OpenPGP signature parameters.
  + * @param dig		container
  + * @return		signature parameters
  + */
  +pgpDigParams pgpGetSignature(const pgpDig dig)
  +	/*@*/;
  +
  +/**
  + * Get signature tag.
  + * @param dig		container
  + * @return		signature tag
  + */
  +int32_t pgpGetSigtag(const pgpDig dig)
  +	/*@*/;
  +
  +/** \ingroup rpmts
  + * Get signature tag type.
  + * @param dig		container
  + * @param ts		transaction set
  + * @return		signature tag type
  + */
  +int32_t pgpGetSigtype(const pgpDig dig)
  +	/*@*/;
  +
  +/**
  + * Get signature tag data, i.e. from header.
  + * @param dig		container
  + * @return		signature tag data
  + */
  +/*@observer@*/ /*@null@*/
  +extern const void * pgpGetSig(const pgpDig dig)
  +	/*@*/;
  +
  +/**
  + * Get signature tag data length, i.e. no. of bytes of data.
  + * @param dig		container
  + * @return		signature tag data length
  + */
  +int32_t pgpGetSiglen(const pgpDig dig)
  +	/*@*/;
  +
  +/**
  + * Set signature tag info, i.e. from header.
  + * @param dig		container
  + * @param sigtag	signature tag
  + * @param sigtype	signature tag type
  + * @param sig		signature tag data
  + * @param siglen	signature tag data length
  + * @return		0 always
  + */
  +int pgpSetSig(pgpDig dig,
  +		int32_t sigtag, int32_t sigtype,
  +		/*@kept@*/ /*@null@*/ const void * sig, int32_t siglen)
  +	/*@modifies dig @*/;
  +
  +/**
    * Is buffer at beginning of an OpenPGP packet?
    * @param p		buffer
    * @return		1 if an OpenPGP packet, 0 otherwise
  @@ .
Received on Sun Sep 9 17:42:52 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.