summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-03-25 13:23:19 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-03-25 13:23:19 +0200
commit14468255716a211064f7653e9f582f94f4c25f9a (patch)
tree64bc2a4c256db9e551b6ebc191eb1e8ef316052e /rpmio
parent3f6b2f8c7b7b79a59664e16d6d350acb54802171 (diff)
downloadrpm-14468255716a211064f7653e9f582f94f4c25f9a.tar.gz
rpm-14468255716a211064f7653e9f582f94f4c25f9a.tar.bz2
rpm-14468255716a211064f7653e9f582f94f4c25f9a.zip
Eliminate header/payload digests from pgpDig_s, they dont belong
- allocate+free digests locally where needed, pass around in separate argument - use digest bundles to handle rpmVerifySignatures() needs - kill-kill-kill fdStealDigest(), dup the contexts from bundles as needed
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/digest.c29
-rw-r--r--rpmio/digest.h6
-rw-r--r--rpmio/rpmio_internal.h11
-rw-r--r--rpmio/rpmpgp.c17
4 files changed, 7 insertions, 56 deletions
diff --git a/rpmio/digest.c b/rpmio/digest.c
index 0779b90de..181a920f3 100644
--- a/rpmio/digest.c
+++ b/rpmio/digest.c
@@ -279,32 +279,3 @@ void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
fdstat_exit(fd, FDSTAT_DIGEST, (ssize_t) 0);
}
}
-
-void fdStealDigest(FD_t fd, pgpDig dig)
-{
- if (fd && fd->digests) {
- rpmDigestBundle bundle = fd->digests;
- for (int i = bundle->index_max; i >= bundle->index_min; i--) {
- DIGEST_CTX ctx = bundle->digests[i];
- if (ctx == NULL)
- continue;
- switch (ctx->algo) {
- case PGPHASHALGO_MD5:
- assert(dig->md5ctx == NULL);
- dig->md5ctx = ctx;
- bundle->digests[i] = NULL;
- break;
- case PGPHASHALGO_SHA1:
- case PGPHASHALGO_SHA256:
- case PGPHASHALGO_SHA384:
- case PGPHASHALGO_SHA512:
- assert(dig->sha1ctx == NULL);
- dig->sha1ctx = ctx;
- bundle->digests[i] = NULL;
- break;
- default:
- break;
- }
- }
- }
-}
diff --git a/rpmio/digest.h b/rpmio/digest.h
index 987063215..32856e435 100644
--- a/rpmio/digest.h
+++ b/rpmio/digest.h
@@ -44,12 +44,6 @@ struct pgpDig_s {
size_t nbytes; /*!< No. bytes of plain text. */
- DIGEST_CTX sha1ctx; /*!< (dsa) sha1 hash context. */
- DIGEST_CTX hdrsha1ctx; /*!< (dsa) header sha1 hash context. */
-
- DIGEST_CTX md5ctx; /*!< (rsa) md5 hash context. */
- DIGEST_CTX hdrmd5ctx; /*!< (rsa) header md5 hash context. */
-
/* DSA/RSA parameters */
SECKEYPublicKey *keydata;
SECItem *sigdata;
diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h
index b00c35d7a..65d6eaded 100644
--- a/rpmio/rpmio_internal.h
+++ b/rpmio/rpmio_internal.h
@@ -254,6 +254,13 @@ void fdSetCpioPos(FD_t fd, rpm_loff_t cpioPos)
fd->fd_cpioPos = cpioPos;
}
+static inline
+void fdSetBundle(FD_t fd, rpmDigestBundle bundle)
+{
+ FDSANE(fd);
+ fd->digests = bundle;
+}
+
/** \ingroup rpmio
*/
static inline
@@ -281,10 +288,6 @@ void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
size_t * lenp,
int asAscii);
-
-/* XXX Steal the digest-in-progress from the file handle. */
-void fdStealDigest(FD_t fd, pgpDig dig);
-
/**
* Read an entire file into a buffer.
* @param fn file name to read
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index c4fd4060c..2cb10a5d0 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -1252,23 +1252,6 @@ pgpDig pgpFreeDig(pgpDig dig)
/* DUmp the signature/pubkey data. */
pgpCleanDig(dig);
-
- if (dig->hdrsha1ctx != NULL)
- (void) rpmDigestFinal(dig->hdrsha1ctx, NULL, NULL, 0);
- dig->hdrsha1ctx = NULL;
-
- if (dig->sha1ctx != NULL)
- (void) rpmDigestFinal(dig->sha1ctx, NULL, NULL, 0);
- dig->sha1ctx = NULL;
-
- if (dig->hdrmd5ctx != NULL)
- (void) rpmDigestFinal(dig->hdrmd5ctx, NULL, NULL, 0);
- dig->hdrmd5ctx = NULL;
-
- if (dig->md5ctx != NULL)
- (void) rpmDigestFinal(dig->md5ctx, NULL, NULL, 0);
- dig->md5ctx = NULL;
-
dig = _free(dig);
}
return dig;