summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2013-10-23 13:20:49 +0200
committerMichael Schroeder <mls@suse.de>2013-10-23 13:20:49 +0200
commit35fccc4f9a65ab937ddf7c70926637e1ece3f43a (patch)
tree4dd18b7af35490197ec96a4e1ecea94e200549f9 /ext
parent3ff9c4b9170066b34aadc1e4fbf2c6c2cb3ab3e1 (diff)
downloadlibsolv-35fccc4f9a65ab937ddf7c70926637e1ece3f43a.tar.gz
libsolv-35fccc4f9a65ab937ddf7c70926637e1ece3f43a.tar.bz2
libsolv-35fccc4f9a65ab937ddf7c70926637e1ece3f43a.zip
cosmetic sigpkg -> sigpkt, clone the hash before finishing it
Diffstat (limited to 'ext')
-rw-r--r--ext/repo_pubkey.c29
-rw-r--r--ext/repo_pubkey.h4
2 files changed, 19 insertions, 14 deletions
diff --git a/ext/repo_pubkey.c b/ext/repo_pubkey.c
index 5b778a2..3dffa20 100644
--- a/ext/repo_pubkey.c
+++ b/ext/repo_pubkey.c
@@ -848,17 +848,17 @@ is_sig_packet(unsigned char *sig, int sigl)
}
Id
-solv_parse_sig(FILE *fp, unsigned char **sigpkgp, int *sigpkglp, char *keyidstr)
+solv_parse_sig(FILE *fp, unsigned char **sigpktp, int *sigpktlp, char *keyidstr)
{
unsigned char *sig;
int sigl, hl, tag, pktl;
struct pgpsig pgpsig;
Id htype;
- if (sigpkgp)
+ if (sigpktp)
{
- *sigpkgp = 0;
- *sigpkglp = 0;
+ *sigpktp = 0;
+ *sigpktlp = 0;
}
if ((sig = (unsigned char *)solv_slurp(fp, &sigl)) == 0)
return 0;
@@ -886,16 +886,16 @@ solv_parse_sig(FILE *fp, unsigned char **sigpkgp, int *sigpkglp, char *keyidstr)
memset(&pgpsig, 0, sizeof(pgpsig));
parsesigpacket(&pgpsig, sig + hl, pktl);
htype = pgphashalgo2type(pgpsig.hashalgo);
- if (pgpsig.type != 0 || !htype)
+ if (pgpsig.type != 0 || !htype || !pgpsig.haveissuer)
{
solv_free(sig);
return 0;
}
- if (sigpkgp)
+ if (sigpktp)
{
- *sigpkgp = solv_malloc(pktl);
- memcpy(*sigpkgp, sig + hl, pktl);
- *sigpkglp = pktl;
+ *sigpktp = solv_malloc(pktl);
+ memcpy(*sigpktp, sig + hl, pktl);
+ *sigpktlp = pktl;
}
solv_free(sig);
if (keyidstr)
@@ -904,26 +904,31 @@ solv_parse_sig(FILE *fp, unsigned char **sigpkgp, int *sigpkglp, char *keyidstr)
}
#ifdef ENABLE_PGPVRFY
+
int
-solv_verify_sig(const unsigned char *pubdata, int pubdatal, unsigned char *sigpkg, int sigpkgl, void *chk)
+solv_verify_sig(const unsigned char *pubdata, int pubdatal, unsigned char *sigpkt, int sigpktl, void *chk)
{
struct pgpsig pgpsig;
int res;
Id htype;
+ void *chk2;
memset(&pgpsig, 0, sizeof(pgpsig));
- parsesigpacket(&pgpsig, sigpkg, sigpkgl);
+ parsesigpacket(&pgpsig, sigpkt, sigpktl);
if (pgpsig.type != 0)
return 0;
htype = pgphashalgo2type(pgpsig.hashalgo);
if (htype != solv_chksum_get_type(chk))
return 0; /* wrong hash type? */
- createsigdata(&pgpsig, sigpkg, sigpkgl, 0, 0, 0, 0, chk);
+ chk2 = solv_chksum_create_clone(chk);
+ createsigdata(&pgpsig, sigpkt, sigpktl, 0, 0, 0, 0, chk2);
+ solv_chksum_free(chk2, 0);
if (!pgpsig.sigdata)
return 0;
res = solv_pgpvrfy(pubdata, pubdatal, pgpsig.sigdata, pgpsig.sigdatal);
solv_free(pgpsig.sigdata);
return res;
}
+
#endif
diff --git a/ext/repo_pubkey.h b/ext/repo_pubkey.h
index fcc0a83..193512a 100644
--- a/ext/repo_pubkey.h
+++ b/ext/repo_pubkey.h
@@ -10,6 +10,6 @@
extern int repo_add_rpmdb_pubkeys(Repo *repo, int flags);
extern Id repo_add_pubkey(Repo *repo, const char *key, int flags);
-Id solv_parse_sig(FILE *fp, unsigned char **sigpkgp, int *sigpkglp, char *keyidstr);
-int solv_verify_sig(const unsigned char *pubdata, int pubdatal, unsigned char *sigpkg, int sigpkgl, void *chk);
+Id solv_parse_sig(FILE *fp, unsigned char **sigpktp, int *sigpktlp, char *keyidstr);
+int solv_verify_sig(const unsigned char *pubdata, int pubdatal, unsigned char *sigpkt, int sigpktl, void *chk);