summaryrefslogtreecommitdiff
path: root/lib/signature.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-06-14 13:49:37 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-06-30 15:16:32 +0300
commitfcc1dc3369d5821b9780ece8cfeb1fe2bca6a15b (patch)
tree06281a25b631fa74175fc02686f63a427156cd65 /lib/signature.c
parenta89c861a3de113ebce481eb2e337e71dfb9e2c21 (diff)
downloadlibrpm-tizen-fcc1dc3369d5821b9780ece8cfeb1fe2bca6a15b.tar.gz
librpm-tizen-fcc1dc3369d5821b9780ece8cfeb1fe2bca6a15b.tar.bz2
librpm-tizen-fcc1dc3369d5821b9780ece8cfeb1fe2bca6a15b.zip
Start getting signature tag out of transaction set
- collect various signature items into rpmtd and pass around to verifyFooSignature() checkers
Diffstat (limited to 'lib/signature.c')
-rw-r--r--lib/signature.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/signature.c b/lib/signature.c
index 19906abf2..2341345ca 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -1001,7 +1001,7 @@ static const char * rpmSigString(rpmRC res)
}
static rpmRC
-verifySizeSignature(const rpmts ts, char ** msg)
+verifySizeSignature(const rpmts ts, rpmtd sigtd, char ** msg)
{
rpm_constdata_t sig = rpmtsSig(ts);
pgpDig dig = rpmtsDig(ts);
@@ -1034,7 +1034,7 @@ exit:
}
static rpmRC
-verifyMD5Signature(const rpmts ts, char ** msg,
+verifyMD5Signature(const rpmts ts, rpmtd sigtd, char ** msg,
DIGEST_CTX md5ctx)
{
rpm_constdata_t sig = rpmtsSig(ts);
@@ -1087,7 +1087,7 @@ exit:
* @return RPMRC_OK on success
*/
static rpmRC
-verifySHA1Signature(const rpmts ts, char ** msg,
+verifySHA1Signature(const rpmts ts, rpmtd sigtd, char ** msg,
DIGEST_CTX sha1ctx)
{
const char *sig = rpmtsSig(ts);
@@ -1135,7 +1135,7 @@ exit:
* @return RPMRC_OK on success
*/
static rpmRC
-verifyRSASignature(rpmts ts, char ** msg,
+verifyRSASignature(rpmts ts, rpmtd sigtd, char ** msg,
DIGEST_CTX md5ctx)
{
rpm_constdata_t sig = rpmtsSig(ts);
@@ -1280,7 +1280,7 @@ exit:
* @return RPMRC_OK on success
*/
static rpmRC
-verifyDSASignature(rpmts ts, char ** msg,
+verifyDSASignature(rpmts ts, rpmtd sigtd, char ** msg,
DIGEST_CTX sha1ctx)
{
rpm_constdata_t sig = rpmtsSig(ts);
@@ -1375,43 +1375,47 @@ exit:
rpmRC
rpmVerifySignature(const rpmts ts, char ** result)
{
- rpm_constdata_t sig = rpmtsSig(ts);
- size_t siglen = rpmtsSiglen(ts);
- rpmSigTag sigtag = rpmtsSigtag(ts);
+ struct rpmtd_s sigtd;
pgpDig dig = rpmtsDig(ts);
rpmRC res;
+
+ rpmtdReset(&sigtd);
+ sigtd.tag = rpmtsSigtag(ts);
+ sigtd.type = rpmtsSigtype(ts);
+ sigtd.data = (void *) rpmtsSig(ts);
+ sigtd.count = rpmtsSiglen(ts);
assert(result != NULL);
- if (sig == NULL || siglen <= 0 || dig == NULL) {
+ if (sigtd.data == NULL || sigtd.count <= 0 || dig == NULL) {
rasprintf(result, _("Verify signature: BAD PARAMETERS\n"));
return RPMRC_NOTFOUND;
}
- switch (sigtag) {
+ switch (sigtd.tag) {
case RPMSIGTAG_SIZE:
- res = verifySizeSignature(ts, result);
+ res = verifySizeSignature(ts, &sigtd, result);
break;
case RPMSIGTAG_MD5:
- res = verifyMD5Signature(ts, result, dig->md5ctx);
+ res = verifyMD5Signature(ts, &sigtd, result, dig->md5ctx);
break;
case RPMSIGTAG_SHA1:
- res = verifySHA1Signature(ts, result, dig->hdrsha1ctx);
+ res = verifySHA1Signature(ts, &sigtd, result, dig->hdrsha1ctx);
break;
case RPMSIGTAG_RSA:
- res = verifyRSASignature(ts, result, dig->hdrmd5ctx);
+ res = verifyRSASignature(ts, &sigtd, result, dig->hdrmd5ctx);
break;
case RPMSIGTAG_PGP5: /* XXX legacy */
case RPMSIGTAG_PGP:
- res = verifyRSASignature(ts, result,
+ res = verifyRSASignature(ts, &sigtd, result,
((dig->signature.hash_algo == PGPHASHALGO_MD5)
? dig->md5ctx : dig->sha1ctx));
break;
case RPMSIGTAG_DSA:
- res = verifyDSASignature(ts, result, dig->hdrsha1ctx);
+ res = verifyDSASignature(ts, &sigtd, result, dig->hdrsha1ctx);
break;
case RPMSIGTAG_GPG:
- res = verifyDSASignature(ts, result, dig->sha1ctx);
+ res = verifyDSASignature(ts, &sigtd, result, dig->sha1ctx);
break;
case RPMSIGTAG_LEMD5_1:
case RPMSIGTAG_LEMD5_2:
@@ -1419,7 +1423,7 @@ rpmVerifySignature(const rpmts ts, char ** result)
res = RPMRC_NOTFOUND;
break;
default:
- rasprintf(result, _("Signature: UNKNOWN (%d)\n"), sigtag);
+ rasprintf(result, _("Signature: UNKNOWN (%d)\n"), sigtd.tag);
res = RPMRC_NOTFOUND;
break;
}