- splint annotationsm, signature cleanup.

CVS patchset: 5351
CVS date: 2002/03/10 19:00:31
This commit is contained in:
jbj 2002-03-10 19:00:31 +00:00
parent f5dbab424b
commit 0a71efcfc0
10 changed files with 111 additions and 176 deletions

View File

@ -94,6 +94,7 @@
- only V3 signatures for now.
- wire --nodigest/--nosignature options to checksig/query/verify modes.
- make --addsign and --resign behave exactly the same.
- splint annotationsm, signature cleanup.
4.0.3 -> 4.0.4:
- solaris: translate i86pc to i386 (#57182).

View File

@ -21,7 +21,8 @@
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
/*@access rpmTransactionSet@*/
/*@access Header@*/ /* XXX compared with NULL */
/*@access Header @*/ /* XXX compared with NULL */
/*@access FD_t @*/ /* XXX stealing digests */
/*@unchecked@*/
static int _print_pkts = 0;
@ -35,9 +36,7 @@ void headerMergeLegacySigs(Header h, const Header sig)
const void * ptr;
int xx;
/*@-mods@*/ /* FIX: undocumented modification of sig */
for (hi = headerInitIterator(sig);
/*@=mods@*/
headerNextIterator(hi, &tag, &type, &ptr, &count);
ptr = hfd(ptr, type))
{
@ -91,9 +90,7 @@ Header headerRegenSigHeader(const Header h)
const void * ptr;
int xx;
/*@-mods@*/ /* FIX: undocumented modification of h */
for (hi = headerInitIterator(h);
/*@=mods@*/
headerNextIterator(hi, &tag, &type, &ptr, &count);
ptr = hfd(ptr, type))
{
@ -442,31 +439,37 @@ fprintf(stderr, "*** RPF: legacy %d nodigests %d nosignatures %d sigtag %d\n", t
ts->dig->nbytes += count;
/* XXX Steal the digest-in-progress from the file handle. */
/*@-type@*/ /* FIX: cast? */
for (i = fd->ndigests - 1; i >= 0; i--) {
FDDIGEST_t fddig = fd->digests + i;
if (fddig->hashctx == NULL)
continue;
if (fddig->hashalgo == PGPHASHALGO_MD5) {
#ifdef DYING
/*@-branchstate@*/
if (ts->dig->md5ctx != NULL)
(void) rpmDigestFinal(ts->dig->md5ctx, NULL, NULL, 0);
/*@=branchstate@*/
#else
assert(ts->dig->md5ctx != NULL);
#endif
ts->dig->md5ctx = fddig->hashctx;
fddig->hashctx = NULL;
continue;
}
if (fddig->hashalgo == PGPHASHALGO_SHA1) {
#ifdef DYING
/*@-branchstate@*/
if (ts->dig->sha1ctx != NULL)
(void) rpmDigestFinal(ts->dig->sha1ctx, NULL, NULL, 0);
/*@=branchstate@*/
#else
assert(ts->dig->sha1ctx != NULL);
#endif
ts->dig->sha1ctx = fddig->hashctx;
fddig->hashctx = NULL;
continue;
}
}
/*@=type@*/
break;
}

View File

@ -18,7 +18,7 @@
/*@access rpmTransactionSet @*/ /* ts->rpmdb, ts->id */
/*@access Header @*/ /* XXX compared with NULL */
/*@access FD_t @*/
/*@access FD_t @*/ /* XXX stealing digests */
/*@access pgpDig @*/
/*@unchecked@*/
@ -148,6 +148,7 @@ static int rpmReSign(/*@unused@*/ rpmTransactionSet ts,
int_32 uht, uhc;
int res = EXIT_FAILURE;
rpmRC rc;
int xx;
tmprpm[0] = '\0';
/*@-branchstate@*/
@ -206,32 +207,32 @@ static int rpmReSign(/*@unused@*/ rpmTransactionSet ts,
}
/* Eliminate broken digest values. */
(void) headerRemoveEntry(sig, RPMSIGTAG_LEMD5_1);
(void) headerRemoveEntry(sig, RPMSIGTAG_LEMD5_2);
(void) headerRemoveEntry(sig, RPMSIGTAG_BADSHA1_1);
(void) headerRemoveEntry(sig, RPMSIGTAG_BADSHA1_2);
xx = headerRemoveEntry(sig, RPMSIGTAG_LEMD5_1);
xx = headerRemoveEntry(sig, RPMSIGTAG_LEMD5_2);
xx = headerRemoveEntry(sig, RPMSIGTAG_BADSHA1_1);
xx = headerRemoveEntry(sig, RPMSIGTAG_BADSHA1_2);
/* Toss and recalculate header+payload size and digests. */
(void) headerRemoveEntry(sig, RPMSIGTAG_SIZE);
(void) rpmAddSignature(sig, sigtarget, RPMSIGTAG_SIZE, qva->passPhrase);
(void) headerRemoveEntry(sig, RPMSIGTAG_MD5);
(void) rpmAddSignature(sig, sigtarget, RPMSIGTAG_MD5, qva->passPhrase);
(void) headerRemoveEntry(sig, RPMSIGTAG_SHA1);
(void) rpmAddSignature(sig, sigtarget, RPMSIGTAG_SHA1, qva->passPhrase);
xx = headerRemoveEntry(sig, RPMSIGTAG_SIZE);
xx = rpmAddSignature(sig, sigtarget, RPMSIGTAG_SIZE, qva->passPhrase);
xx = headerRemoveEntry(sig, RPMSIGTAG_MD5);
xx = rpmAddSignature(sig, sigtarget, RPMSIGTAG_MD5, qva->passPhrase);
xx = headerRemoveEntry(sig, RPMSIGTAG_SHA1);
xx = rpmAddSignature(sig, sigtarget, RPMSIGTAG_SHA1, qva->passPhrase);
/* If gpg/pgp is configured, replace the signature. */
if ((sigtag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) > 0) {
switch (sigtag) {
case RPMSIGTAG_GPG:
(void) headerRemoveEntry(sig, RPMSIGTAG_DSA);
xx = headerRemoveEntry(sig, RPMSIGTAG_DSA);
/*@fallthrough@*/
case RPMSIGTAG_PGP5:
case RPMSIGTAG_PGP:
(void) headerRemoveEntry(sig, RPMSIGTAG_RSA);
break;
xx = headerRemoveEntry(sig, RPMSIGTAG_RSA);
/*@switchbreak@*/ break;
}
(void) headerRemoveEntry(sig, sigtag);
(void) rpmAddSignature(sig, sigtarget, sigtag, qva->passPhrase);
xx = headerRemoveEntry(sig, sigtag);
xx = rpmAddSignature(sig, sigtarget, sigtag, qva->passPhrase);
}
/* Reallocate the signature into one contiguous region. */
@ -269,12 +270,12 @@ static int rpmReSign(/*@unused@*/ rpmTransactionSet ts,
/* ASSERT: fd == NULL && ofd == NULL */
/* Clean up intermediate target */
(void) unlink(sigtarget);
xx = unlink(sigtarget);
sigtarget = _free(sigtarget);
/* Move final target into place. */
(void) unlink(rpm);
(void) rename(trpm, rpm);
xx = unlink(rpm);
xx = rename(trpm, rpm);
tmprpm[0] = '\0';
}
/*@=branchstate@*/
@ -288,11 +289,11 @@ exit:
sig = rpmFreeSignature(sig);
if (sigtarget) {
(void) unlink(sigtarget);
xx = unlink(sigtarget);
sigtarget = _free(sigtarget);
}
if (tmprpm[0] != '\0') {
(void) unlink(tmprpm);
xx = unlink(tmprpm);
tmprpm[0] = '\0';
}
@ -310,7 +311,7 @@ static int rpmImportPubkey(rpmTransactionSet ts,
/*@unused@*/ QVA_t qva,
/*@null@*/ const char ** argv)
/*@globals RPMVERSION, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
/*@modifies ts, fileSystem, internalState @*/
{
const char * fn;
int res = 0;
@ -427,9 +428,7 @@ static int rpmImportPubkey(rpmTransactionSet ts,
#endif
/* Add header to database. */
/*@-mods@*/ /* FIX: ts->rpmdb is modified */
xx = rpmdbAdd(ts->rpmdb, ts->id, h);
/*@=mods@*/
bottom:
/* Clean up. */
@ -459,8 +458,7 @@ static unsigned char header_magic[8] = {
*/
static int readFile(FD_t fd, const char * fn, pgpDig dig)
/*@globals fileSystem, internalState @*/
/*@modifies fd, *dig,
fileSystem, internalState @*/
/*@modifies fd, *dig, fileSystem, internalState @*/
{
byte buf[4*BUFSIZ];
ssize_t count;
@ -507,7 +505,6 @@ static int readFile(FD_t fd, const char * fn, pgpDig dig)
}
/* XXX Steal the digest-in-progress from the file handle. */
/*@-type@*/ /* FIX: cast? */
for (i = fd->ndigests - 1; i >= 0; i--) {
FDDIGEST_t fddig = fd->digests + i;
if (fddig->hashctx == NULL)
@ -525,7 +522,6 @@ assert(dig->sha1ctx == NULL);
continue;
}
}
/*@=type@*/
rc = 0;
@ -609,12 +605,10 @@ int rpmVerifySignatures(QVA_t qva, rpmTransactionSet ts, FD_t fd,
ts->dig = pgpNewDig();
/* Read the file, generating digest(s) on the fly. */
/*@-mods@*/ /* FIX: double indirection */
if (readFile(fd, fn, ts->dig)) {
res++;
goto bottom;
}
/*@=mods@*/
res2 = 0;
b = buf; *b = '\0';

View File

@ -119,8 +119,8 @@ typedef enum rpmVerifyAttrs_e {
* @todo Merge rpmQueryFlags, rpmVerifyFlags, and rpmVerifyAttrs?.
*/
typedef enum rpmQueryFlags_e {
QUERY_FOR_DEFAULT = 0, /*!< */
/*@-enummemuse@*/
QUERY_FOR_DEFAULT = 0, /*!< */
QUERY_MD5 = (1 << 0), /*!< from --nomd5 */
QUERY_SIZE = (1 << 1), /*!< from --nosize */
QUERY_LINKTO = (1 << 2), /*!< from --nolink */

View File

@ -112,19 +112,21 @@ int headerNVR(Header h,
/** \ingroup header
* Translate and merge legacy signature tags into header.
* @todo Remove headerSort() through headerInitIterator() modifies sig.
* @param h header
* @param sig signature header
*/
void headerMergeLegacySigs(Header h, const Header sig)
/*@modifies h @*/;
/*@modifies h, sig @*/;
/** \ingroup header
* Regenerate signature header.
* @todo Remove headerSort() through headerInitIterator() modifies h.
* @param h header
* @return regenerated signature header
*/
Header headerRegenSigHeader(const Header h)
/*@*/;
/*@modifies h @*/;
/**
* Retrieve file names from header.
@ -1814,7 +1816,7 @@ typedef enum rpmVerifySignatureReturn_e {
* - ts->sigtag type of signature
* - ts->sig signature itself (from signature header)
* - ts->siglen no. of bytes in signature
* - ts->dig signature parameters (malloc'd workspace)
* - ts->dig signature/pubkey parameters (malloc'd workspace)
*
* @param ts transaction set
* @retval result detailed text result of signature verification
@ -1822,7 +1824,8 @@ typedef enum rpmVerifySignatureReturn_e {
*/
rpmVerifySignatureReturn rpmVerifySignature(const rpmTransactionSet ts,
/*@out@*/ char * result)
/*@modifies ts, *result @*/;
/*@globals fileSystem, internalState @*/
/*@modifies ts, *result, fileSystem, internalState @*/;
/** \ingroup signature
* Destroy signature header from package.

View File

@ -22,9 +22,9 @@
/*@access DIGEST_CTX@*/ /* XXX compared with NULL */
/*@access pgpDig@*/
/*@-mustmod@*/ /* FIX: internalState not modified? */
int rpmLookupSignatureType(int action)
{
/*@unchecked@*/
static int disabled = 0;
int rc = 0;
@ -56,7 +56,6 @@ int rpmLookupSignatureType(int action)
}
return rc;
}
/*@=mustmod@*/
/* rpmDetectPGPVersion() returns the absolute path to the "pgp" */
/* executable of the requested version, or NULL when none found. */
@ -156,10 +155,8 @@ rpmRC rpmReadSignature(FD_t fd, Header * headerp, sigType sig_type)
case RPMSIGTYPE_PGP262_1024:
rpmMessage(RPMMESS_DEBUG, _("Old PGP signature\n"));
/* These are always 256 bytes */
/*@-type@*/ /* FIX: eliminate timedRead @*/
if (timedRead(fd, buf, 256) != 256)
break;
/*@=type@*/
h = headerNew();
(void) headerAddEntry(h, RPMSIGTAG_PGP, RPM_BIN_TYPE, buf, 152);
rc = RPMRC_OK;
@ -190,19 +187,17 @@ rpmRC rpmReadSignature(FD_t fd, Header * headerp, sigType sig_type)
break;
rc = checkSize(fd, sigSize, pad, *archSize);
}
/*@-type@*/ /* FIX: eliminate timedRead @*/
if (pad && timedRead(fd, buf, pad) != pad)
rc = RPMRC_SHORTREAD;
/*@=type@*/
break;
default:
break;
}
if (headerp && rc == 0)
*headerp = h;
else
h = headerFree(h, "ReadSignature");
*headerp = headerLink(h, NULL);
h = headerFree(h, NULL);
return rc;
}
@ -248,8 +243,8 @@ Header rpmFreeSignature(Header h)
*/
static int makePGPSignature(const char * file, /*@out@*/ byte ** pkt,
/*@out@*/ int_32 * pktlen, /*@null@*/ const char * passPhrase)
/*@globals rpmGlobalMacroContext, fileSystem @*/
/*@modifies *pkt, *pktlen, rpmGlobalMacroContext, fileSystem @*/
/*@globals errno, rpmGlobalMacroContext, fileSystem @*/
/*@modifies errno, *pkt, *pktlen, rpmGlobalMacroContext, fileSystem @*/
{
char * sigfile = alloca(1024);
int pid, status;
@ -298,9 +293,7 @@ static int makePGPSignature(const char * file, /*@out@*/ byte ** pkt,
break;
case PGP_UNKNOWN:
case PGP_NOTDETECTED:
/*@-mods@*/ /* FIX: shrug */
errno = ENOENT;
/*@=mods@*/
break;
}
}
@ -340,9 +333,7 @@ static int makePGPSignature(const char * file, /*@out@*/ byte ** pkt,
rc = 0;
fd = Fopen(sigfile, "r.fdio");
if (fd != NULL && !Ferror(fd)) {
/*@-type@*/ /* FIX: eliminate timedRead @*/
rc = timedRead(fd, *pkt, *pktlen);
/*@=type@*/
if (sigfile) (void) unlink(sigfile);
(void) Fclose(fd);
}
@ -440,9 +431,7 @@ static int makeGPGSignature(const char * file, /*@out@*/ byte ** pkt,
rc = 0;
fd = Fopen(sigfile, "r.fdio");
if (fd != NULL && !Ferror(fd)) {
/*@-type@*/ /* FIX: eliminate timedRead @*/
rc = timedRead(fd, *pkt, *pktlen);
/*@=type@*/
if (sigfile) (void) unlink(sigfile);
(void) Fclose(fd);
}
@ -629,38 +618,35 @@ int rpmAddSignature(Header sig, const char * file, int_32 sigTag,
}
static int checkPassPhrase(const char * passPhrase, const int sigTag)
/*@globals rpmGlobalMacroContext,
fileSystem @*/
/*@modifies rpmGlobalMacroContext,
fileSystem @*/
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/
{
int passPhrasePipe[2];
int pid, status;
int fd;
const char * cmd;
char *const *av;
int rc;
int xx;
passPhrasePipe[0] = passPhrasePipe[1] = 0;
(void) pipe(passPhrasePipe);
xx = pipe(passPhrasePipe);
if (!(pid = fork())) {
(void) close(STDIN_FILENO);
(void) close(STDOUT_FILENO);
(void) close(passPhrasePipe[1]);
/*@-internalglobs@*/ /* FIX: shrug */
if (! rpmIsVerbose()) {
(void) close(STDERR_FILENO);
const char * cmd;
char *const *av;
int fdno;
xx = close(STDIN_FILENO);
xx = close(STDOUT_FILENO);
xx = close(passPhrasePipe[1]);
if (! rpmIsVerbose())
xx = close(STDERR_FILENO);
if ((fdno = open("/dev/null", O_RDONLY)) != STDIN_FILENO) {
xx = dup2(fdno, STDIN_FILENO);
xx = close(fdno);
}
/*@=internalglobs@*/
if ((fd = open("/dev/null", O_RDONLY)) != STDIN_FILENO) {
(void) dup2(fd, STDIN_FILENO);
(void) close(fd);
if ((fdno = open("/dev/null", O_WRONLY)) != STDOUT_FILENO) {
xx = dup2(fdno, STDOUT_FILENO);
xx = close(fdno);
}
if ((fd = open("/dev/null", O_WRONLY)) != STDOUT_FILENO) {
(void) dup2(fd, STDOUT_FILENO);
(void) close(fd);
}
(void) dup2(passPhrasePipe[0], 3);
xx = dup2(passPhrasePipe[0], 3);
switch (sigTag) {
case RPMSIGTAG_DSA:
@ -687,7 +673,7 @@ static int checkPassPhrase(const char * passPhrase, const int sigTag)
(void) dosetenv("PGPPASSFD", "3", 1);
if (pgp_path && *pgp_path != '\0')
(void) dosetenv("PGPPATH", pgp_path, 1);
xx = dosetenv("PGPPATH", pgp_path, 1);
if ((path = rpmDetectPGPVersion(&pgpVer)) != NULL) {
switch(pgpVer) {
@ -719,18 +705,14 @@ static int checkPassPhrase(const char * passPhrase, const int sigTag)
}
}
(void) close(passPhrasePipe[0]);
(void) write(passPhrasePipe[1], passPhrase, strlen(passPhrase));
(void) write(passPhrasePipe[1], "\n", 1);
(void) close(passPhrasePipe[1]);
xx = close(passPhrasePipe[0]);
xx = write(passPhrasePipe[1], passPhrase, strlen(passPhrase));
xx = write(passPhrasePipe[1], "\n", 1);
xx = close(passPhrasePipe[1]);
(void)waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
return 1;
}
(void) waitpid(pid, &status, 0);
/* passPhrase is good */
return 0;
return ((!WIFEXITED(status) || WEXITSTATUS(status)) ? 1 : 0);
}
char * rpmGetPassPhrase(const char * prompt, const int sigTag)
@ -790,8 +772,8 @@ static /*@observer@*/ const char * rpmSigString(rpmVerifySignatureReturn res)
case RPMSIG_BAD: str = "BAD"; break;
case RPMSIG_NOKEY: str = "NOKEY"; break;
case RPMSIG_NOTTRUSTED: str = "NOTRUSTED"; break;
case RPMSIG_UNKNOWN:
default: str = "UNKNOWN"; break;
default:
case RPMSIG_UNKNOWN: str = "UNKNOWN"; break;
}
return str;
}
@ -806,17 +788,15 @@ verifySizeSignature(const rpmTransactionSet ts, /*@out@*/ char * t)
*t = '\0';
t = stpcpy(t, _("Header+Payload size: "));
if (ts->sig == NULL || ts->dig == NULL) {
if (ts->sig == NULL || ts->dig == NULL || ts->dig->nbytes == 0) {
res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
res = RPMSIG_NOKEY;
t = stpcpy(t, rpmSigString(res));
goto exit;
}
/*@=nullpass =nullderef@*/ /* FIX: ts->{sig,dig} can be NULL */
memcpy(&size, ts->sig, sizeof(size));
/*@-type@*/
/*@-nullderef@*/ /* FIX: ts->dig can be NULL */
if (size != ts->dig->nbytes) {
res = RPMSIG_BAD;
t = stpcpy(t, rpmSigString(res));
@ -826,8 +806,6 @@ verifySizeSignature(const rpmTransactionSet ts, /*@out@*/ char * t)
t = stpcpy(t, rpmSigString(res));
sprintf(t, " (%d)", ts->dig->nbytes);
}
/*@=type@*/
/*@=nullpass =nullderef@*/
exit:
t = stpcpy(t, "\n");
@ -836,7 +814,7 @@ exit:
static rpmVerifySignatureReturn
verifyMD5Signature(const rpmTransactionSet ts, /*@out@*/ char * t,
DIGEST_CTX md5ctx)
/*@null@*/ DIGEST_CTX md5ctx)
/*@modifies *t @*/
{
rpmVerifySignatureReturn res;
@ -846,25 +824,14 @@ verifyMD5Signature(const rpmTransactionSet ts, /*@out@*/ char * t,
*t = '\0';
t = stpcpy(t, _("MD5 digest: "));
if (ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY;
if (md5ctx == NULL || ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
t = stpcpy(t, rpmSigString(res));
goto exit;
}
if (md5ctx == NULL) {
/*@-modfilesys@*/
fprintf(stderr, "*** MD5 md5ctx %p\n", md5ctx);
/*@=modfilesys@*/
res = RPMSIG_NOKEY;
t = stpcpy(t, rpmSigString(res));
goto exit;
}
/*@-type@*/
(void) rpmDigestFinal(rpmDigestDup(md5ctx),
(void **)&md5sum, &md5len, 0);
/*@=type@*/
if (md5len != ts->siglen || memcmp(md5sum, ts->sig, md5len)) {
res = RPMSIG_BAD;
@ -896,7 +863,7 @@ exit:
*/
static rpmVerifySignatureReturn
verifySHA1Signature(const rpmTransactionSet ts, /*@out@*/ char * t,
DIGEST_CTX sha1ctx)
/*@null@*/ DIGEST_CTX sha1ctx)
/*@modifies *t @*/
{
rpmVerifySignatureReturn res;
@ -905,25 +872,14 @@ verifySHA1Signature(const rpmTransactionSet ts, /*@out@*/ char * t,
*t = '\0';
t = stpcpy(t, _("Header SHA1 digest: "));
if (ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY;
if (sha1ctx == NULL || ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
t = stpcpy(t, rpmSigString(res));
goto exit;
}
if (sha1ctx == NULL) {
/*@-modfilesys@*/
fprintf(stderr, "*** SHA1 sha1ctx %p\n", sha1ctx);
/*@=modfilesys@*/
res = RPMSIG_NOKEY;
t = stpcpy(t, rpmSigString(res));
goto exit;
}
/*@-type@*/
(void) rpmDigestFinal(rpmDigestDup(sha1ctx),
(void **)&sha1, NULL, 1);
/*@=type@*/
if (sha1 == NULL || strlen(sha1) != strlen(ts->sig)) {
res = RPMSIG_BAD;
@ -953,7 +909,8 @@ exit:
*/
static rpmVerifySignatureReturn
rpmtsFindPubkey(rpmTransactionSet ts)
/*@modifies ts */
/*@globals fileSystem, internalState @*/
/*@modifies ts, fileSystem, internalState */
{
struct pgpDigParams_s * sigp = NULL;
rpmVerifySignatureReturn res;
@ -968,7 +925,6 @@ rpmtsFindPubkey(rpmTransactionSet ts)
}
sigp = &ts->dig->signature;
/*@-globs -internalglobs -mods -modfilesys@*/
if (pkpkt == NULL || memcmp(sigp->signid, pksignid, sizeof(pksignid))) {
int ix = -1;
rpmdbMatchIterator mi;
@ -1049,7 +1005,6 @@ rpmtsFindPubkey(rpmTransactionSet ts)
/* Retrieve parameters from pubkey packet(s). */
xx = pgpPrtPkts(pkpkt, pkpktlen, ts->dig, 0);
/*@=globs =internalglobs =mods =modfilesys@*/
/* Do the parameters match the signature? */
if (ts->dig->signature.pubkey_algo == ts->dig->pubkey.pubkey_algo
@ -1091,8 +1046,10 @@ static inline unsigned char nibble(char c)
* @return RPMSIG_OK on success
*/
static rpmVerifySignatureReturn
verifyPGPSignature(rpmTransactionSet ts, /*@out@*/ char * t, DIGEST_CTX md5ctx)
/*@modifies ts, *t */
verifyPGPSignature(rpmTransactionSet ts, /*@out@*/ char * t,
/*@null@*/ DIGEST_CTX md5ctx)
/*@globals fileSystem, internalState @*/
/*@modifies ts, *t, fileSystem, internalState */
{
struct pgpDigParams_s * sigp = NULL;
rpmVerifySignatureReturn res;
@ -1101,8 +1058,8 @@ verifyPGPSignature(rpmTransactionSet ts, /*@out@*/ char * t, DIGEST_CTX md5ctx)
*t = '\0';
t = stpcpy(t, _("V3 RSA/MD5 signature: "));
if (ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY;
if (md5ctx == NULL || ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
goto exit;
}
sigp = &ts->dig->signature;
@ -1116,15 +1073,6 @@ verifyPGPSignature(rpmTransactionSet ts, /*@out@*/ char * t, DIGEST_CTX md5ctx)
goto exit;
}
if (md5ctx == NULL) {
/*@-modfilesys@*/
fprintf(stderr, "*** RSA md5ctx %p\n", md5ctx);
/*@=modfilesys@*/
res = RPMSIG_NOKEY;
goto exit;
}
/*@-type@*/ /* FIX: cast? */
{ DIGEST_CTX ctx = rpmDigestDup(md5ctx);
byte signhash16[2];
const char * s;
@ -1132,7 +1080,7 @@ goto exit;
if (sigp->hash != NULL)
xx = rpmDigestUpdate(ctx, sigp->hash, sigp->hashlen);
#ifdef NOTYET /* XXX not for binary/text doccument signatures. */
#ifdef NOTYET /* XXX not for binary/text document signatures. */
if (sigp->sigtype == 4) {
int nb = ts->dig->nbytes + sigp->hashlen;
byte trailer[6];
@ -1156,7 +1104,6 @@ goto exit;
}
}
/*@=type@*/
{ const char * prefix = "3020300c06082a864886f70d020505000410";
unsigned int nbits = 1024;
@ -1184,12 +1131,10 @@ goto exit;
if (res != RPMSIG_OK)
goto exit;
/*@-type@*/
if (rsavrfy(&ts->dig->rsa_pk, &ts->dig->rsahm, &ts->dig->c))
res = RPMSIG_OK;
else
res = RPMSIG_BAD;
/*@=type@*/
exit:
t = stpcpy(t, rpmSigString(res));
@ -1209,8 +1154,10 @@ exit:
* @return RPMSIG_OK on success
*/
static rpmVerifySignatureReturn
verifyGPGSignature(rpmTransactionSet ts, /*@out@*/ char * t, DIGEST_CTX sha1ctx)
/*@modifies ts, *t @*/
verifyGPGSignature(rpmTransactionSet ts, /*@out@*/ char * t,
/*@null@*/ DIGEST_CTX sha1ctx)
/*@globals fileSystem, internalState @*/
/*@modifies ts, *t, fileSystem, internalState */
{
struct pgpDigParams_s * sigp = NULL;
rpmVerifySignatureReturn res;
@ -1221,8 +1168,8 @@ verifyGPGSignature(rpmTransactionSet ts, /*@out@*/ char * t, DIGEST_CTX sha1ctx)
t = stpcpy(t, _("Header "));
t = stpcpy(t, _("V3 DSA signature: "));
if (ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY;
if (sha1ctx == NULL || ts->sig == NULL || ts->dig == NULL) {
res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
goto exit;
}
sigp = &ts->dig->signature;
@ -1236,22 +1183,13 @@ verifyGPGSignature(rpmTransactionSet ts, /*@out@*/ char * t, DIGEST_CTX sha1ctx)
goto exit;
}
if (sha1ctx == NULL) {
/*@-modfilesys@*/
fprintf(stderr, "*** DSA sha1ctx %p\n", sha1ctx);
/*@=modfilesys@*/
res = RPMSIG_NOKEY;
goto exit;
}
/*@-type@*/ /* FIX: cast? */
{ DIGEST_CTX ctx = rpmDigestDup(sha1ctx);
byte signhash16[2];
if (sigp->hash != NULL)
xx = rpmDigestUpdate(ctx, sigp->hash, sigp->hashlen);
#ifdef NOTYET /* XXX not for binary/text doccument signatures. */
#ifdef NOTYET /* XXX not for binary/text document signatures. */
if (sigp->sigtype == 4) {
int nb = ts->dig->nbytes + sigp->hashlen;
byte trailer[6];
@ -1264,11 +1202,9 @@ goto exit;
#endif
xx = rpmDigestFinal(ctx, (void **)&ts->dig->sha1, &ts->dig->sha1len, 1);
/* XXX compare leading 16 bits of digest for quick check. */
mp32nzero(&ts->dig->hm); mp32nsethex(&ts->dig->hm, ts->dig->sha1);
/* XXX compare leading 16 bits of digest for quick check. */
/* Compare leading 16 bits of digest for quick check. */
signhash16[0] = (*ts->dig->hm.data >> 24) & 0xff;
signhash16[1] = (*ts->dig->hm.data >> 16) & 0xff;
if (memcmp(signhash16, sigp->signhash16, sizeof(signhash16))) {
@ -1276,20 +1212,17 @@ goto exit;
goto exit;
}
}
/*@=type@*/
/* Retrieve the matching public key. */
res = rpmtsFindPubkey(ts);
if (res != RPMSIG_OK)
goto exit;
/*@-type@*/
if (dsavrfy(&ts->dig->p, &ts->dig->q, &ts->dig->g,
&ts->dig->hm, &ts->dig->y, &ts->dig->r, &ts->dig->s))
res = RPMSIG_OK;
else
res = RPMSIG_BAD;
/*@=type@*/
exit:
t = stpcpy(t, rpmSigString(res));

View File

@ -107,8 +107,8 @@ int rpmLookupSignatureType(int action)
*/
/*@null@*/ char * rpmGetPassPhrase(/*@null@*/ const char * prompt,
const int sigTag)
/*@globals rpmGlobalMacroContext, fileSystem @*/
/*@modifies rpmGlobalMacroContext, fileSystem @*/;
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup signature
* Return path to pgp executable of given type, or NULL when not found.

View File

@ -363,8 +363,8 @@ int rpmVerifyDigest(Header h)
* @return 0 no problems, 1 problems found
*/
static int verifyHeader(QVA_t qva, /*@unused@*/ rpmTransactionSet ts, Header h)
/*@globals fileSystem@*/
/*@modifies h, fileSystem @*/
/*@globals fileSystem, internalState @*/
/*@modifies h, fileSystem, internalState @*/
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
char buf[BUFSIZ];
@ -390,7 +390,8 @@ static int verifyHeader(QVA_t qva, /*@unused@*/ rpmTransactionSet ts, Header h)
rpmBuildFileList(h, &fileNames, &count);
for (i = 0; i < count; i++) {
for (i = 0; i < count; i++)
{
rpmfileAttrs fileAttrs;
int rc;
@ -403,13 +404,11 @@ static int verifyHeader(QVA_t qva, /*@unused@*/ rpmTransactionSet ts, Header h)
rc = rpmVerifyFile(ts->rootDir, h, i, &verifyResult, omitMask);
if (rc) {
/*@-internalglobs@*/ /* FIX: shrug */
if (!(fileAttrs & RPMFILE_MISSINGOK) || rpmIsVerbose()) {
sprintf(te, _("missing %s"), fileNames[i]);
te += strlen(te);
ec = rc;
}
/*@=internalglobs@*/
} else if (verifyResult) {
const char * size, * md5, * link, * mtime, * mode;
const char * group, * user, * rdev;

View File

@ -526,6 +526,7 @@ fi
%changelog
* Sun Mar 10 2002 Jeff Johnson <jbj@redhat.com>
- make --addsign and --resign behave exactly the same.
- splint annotationsm, signature cleanup.
* Mon Sep 24 2001 Jeff Johnson <jbj@redhat.com>
- Start rpm-4.1.

View File

@ -526,6 +526,7 @@ fi
%changelog
* Sun Mar 10 2002 Jeff Johnson <jbj@redhat.com>
- make --addsign and --resign behave exactly the same.
- splint annotationsm, signature cleanup.
* Mon Sep 24 2001 Jeff Johnson <jbj@redhat.com>
- Start rpm-4.1.