summaryrefslogtreecommitdiffabout
path: root/src/gpg.c
Side-by-side diff
Diffstat (limited to 'src/gpg.c') (more/less context) (show whitespace changes)
-rw-r--r--src/gpg.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/gpg.c b/src/gpg.c
index 8979e9c..814be6f 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -147,22 +147,8 @@ create_gpg_homedir ()
}
static int
-gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig,
- struct file_triplet *trp)
+checksig (gpgme_signature_t sig, const char *uid, struct file_triplet *trp)
{
- if (!sig)
- return 0;
-
- for (; sig; sig = sig->next)
- {
- const char *uid;
- gpgme_key_t key;
-
- if (gpgme_get_key (ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR)
- uid = key->uids->uid;
- else
- uid = sig->fpr;
-
switch (gpg_err_code (sig->status))
{
case GPG_ERR_NO_ERROR:
@@ -208,6 +194,30 @@ gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig,
logmsg (LOG_ERR, _("Unknown signature error"));
return 0;
}
+ return -1;
+}
+
+static int
+gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig,
+ struct file_triplet *trp)
+{
+ if (!sig)
+ return 0;
+
+ for (; sig; sig = sig->next)
+ {
+ const char *uid;
+ gpgme_key_t key;
+ int rc;
+
+ if (gpgme_get_key (ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR)
+ uid = key->uids->uid;
+ else
+ uid = sig->fpr;
+ rc = checksig (sig, uid, trp);
+ gpgme_key_unref (key);
+ if (rc != -1)
+ return rc;
}
return 1;
}
@@ -217,7 +227,7 @@ int
verify_directive_signature (struct file_triplet *trp)
{
gpgme_ctx_t ctx;
- gpgme_data_t key_data, directive_data, plain;
+ gpgme_data_t key_data, directive_data, plain = NULL;
gpgme_error_t ec;
int rc;
struct uploader_info *uptr;
@@ -269,6 +279,7 @@ verify_directive_signature (struct file_triplet *trp)
trp->name, gpgme_strerror (ec));
}
+ gpgme_data_release (plain);
gpgme_data_release (directive_data);
gpgme_data_release (key_data);
gpgme_release (ctx);

Return to:

Send suggestions and report system problems to the System administrator.