* crypto: improve signature checking code
This commit is contained in:
@ -21,7 +21,7 @@ include $(top_srcdir)/gtest.mk
|
|||||||
SUBDIRS= . tests
|
SUBDIRS= . tests
|
||||||
|
|
||||||
if BUILD_CRYPTO
|
if BUILD_CRYPTO
|
||||||
crypto=mu-msg-crypto.c mu-msg-crypto.h
|
crypto=mu-msg-crypto.c
|
||||||
else
|
else
|
||||||
crypto=
|
crypto=
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
#include "mu-msg.h"
|
#include "mu-msg.h"
|
||||||
#include "mu-msg-priv.h"
|
#include "mu-msg-priv.h"
|
||||||
#include "mu-msg-part.h"
|
#include "mu-msg-part.h"
|
||||||
#include "mu-msg-crypto.h"
|
|
||||||
#include "mu-date.h"
|
#include "mu-date.h"
|
||||||
|
|
||||||
#include <gmime/gmime.h>
|
#include <gmime/gmime.h>
|
||||||
@ -206,16 +205,11 @@ get_digestkey_algo_name (GMimeDigestAlgo algo)
|
|||||||
static char*
|
static char*
|
||||||
get_cert_data (GMimeCertificate *cert)
|
get_cert_data (GMimeCertificate *cert)
|
||||||
{
|
{
|
||||||
const char /*issuer_name, *issuer_serial, ,*fprint*/
|
const char *email, *name, *digest_algo, *pubkey_algo,
|
||||||
*email, *name,
|
|
||||||
*digest_algo, *pubkey_algo,
|
|
||||||
*keyid, *trust;
|
*keyid, *trust;
|
||||||
|
|
||||||
/* issuer_name = g_mime_certificate_get_issuer_name (cert); */
|
|
||||||
/* issuer_serial = g_mime_certificate_get_issuer_serial (cert); */
|
|
||||||
email = g_mime_certificate_get_email (cert);
|
email = g_mime_certificate_get_email (cert);
|
||||||
name = g_mime_certificate_get_name (cert);
|
name = g_mime_certificate_get_name (cert);
|
||||||
/* fprint = g_mime_certificate_get_fingerprint (cert); */
|
|
||||||
keyid = g_mime_certificate_get_key_id (cert);
|
keyid = g_mime_certificate_get_key_id (cert);
|
||||||
|
|
||||||
digest_algo = get_digestkey_algo_name
|
digest_algo = get_digestkey_algo_name
|
||||||
@ -235,10 +229,9 @@ get_cert_data (GMimeCertificate *cert)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return g_strdup_printf (
|
return g_strdup_printf (
|
||||||
"signed by: %s <%s>; " /*; issued by %s (%s); */
|
"signed by: %s <%s>; "
|
||||||
"algos: <%s,%s>; key-id: %s; trust: %s",
|
"algos: <%s,%s>; key-id: %s; trust: %s",
|
||||||
name ? name : "?", email ? email : "?",
|
name ? name : "?", email ? email : "?",
|
||||||
/* issuer_name, issuer_serial */
|
|
||||||
pubkey_algo, digest_algo, keyid, trust);
|
pubkey_algo, digest_algo, keyid, trust);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,8 +287,7 @@ get_status_report (GMimeSignatureList *sigs)
|
|||||||
sigstat = g_mime_signature_get_status (msig);
|
sigstat = g_mime_signature_get_status (msig);
|
||||||
|
|
||||||
switch (sigstat) {
|
switch (sigstat) {
|
||||||
case GMIME_SIGNATURE_STATUS_GOOD:
|
case GMIME_SIGNATURE_STATUS_GOOD: break;
|
||||||
break;
|
|
||||||
case GMIME_SIGNATURE_STATUS_ERROR:
|
case GMIME_SIGNATURE_STATUS_ERROR:
|
||||||
status = MU_MSG_PART_SIG_STATUS_ERROR;
|
status = MU_MSG_PART_SIG_STATUS_ERROR;
|
||||||
break;
|
break;
|
||||||
@ -306,10 +298,8 @@ get_status_report (GMimeSignatureList *sigs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rep = get_verdict_report (msig);
|
rep = get_verdict_report (msig);
|
||||||
report = g_strdup_printf ("%s%s[%d] %s",
|
report = g_strdup_printf ("%s%s[%d] %s", report ? report : "",
|
||||||
report ? report : "",
|
report ? "; " : "", i, rep);
|
||||||
report ? "; " : "",
|
|
||||||
i, rep);
|
|
||||||
g_free (rep);
|
g_free (rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,8 +354,6 @@ mu_msg_crypto_verify_part (GMimeMultipartSigned *sig, MuMsgOptions opts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GMimeObject* /* this is declared in mu-msg-priv.h */
|
GMimeObject* /* this is declared in mu-msg-priv.h */
|
||||||
mu_msg_crypto_decrypt_part (GMimeMultipartEncrypted *enc, MuMsgOptions opts,
|
mu_msg_crypto_decrypt_part (GMimeMultipartEncrypted *enc, MuMsgOptions opts,
|
||||||
MuMsgPartPasswordFunc func, gpointer user_data,
|
MuMsgPartPasswordFunc func, gpointer user_data,
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
** Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|
||||||
**
|
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
|
||||||
** under the terms of the GNU General Public License as published by the
|
|
||||||
** Free Software Foundation; either version 3, or (at your option) any
|
|
||||||
** later version.
|
|
||||||
**
|
|
||||||
** This program is distributed in the hope that it will be useful,
|
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
** GNU General Public License for more details.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with this program; if not, write to the Free Software Foundation,
|
|
||||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* functions for verifying signatures, decrypting messages */
|
|
||||||
|
|
||||||
#ifndef __MU_MSG_CRYPTO_H__
|
|
||||||
#define __MU_MSG_CRYPTO_H__
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <mu-msg.h>
|
|
||||||
|
|
||||||
struct _MuMsgDecryptedPart;
|
|
||||||
typedef struct _MuMsgDecryptedPart MuMsgDecryptedPart;
|
|
||||||
|
|
||||||
#endif /*__MU_MSG_CRYPTO_H__*/
|
|
||||||
@ -32,11 +32,6 @@
|
|||||||
#include "mu-maildir.h"
|
#include "mu-maildir.h"
|
||||||
#include "mu-msg-priv.h"
|
#include "mu-msg-priv.h"
|
||||||
|
|
||||||
#ifdef BUILD_CRYPTO
|
|
||||||
#include "mu-msg-crypto.h"
|
|
||||||
#endif /*BUILD_CRYPTO*/
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean init_file_metadata (MuMsgFile *self, const char* path,
|
static gboolean init_file_metadata (MuMsgFile *self, const char* path,
|
||||||
const char *mdir, GError **err);
|
const char *mdir, GError **err);
|
||||||
static gboolean init_mime_msg (MuMsgFile *msg, const char *path, GError **err);
|
static gboolean init_mime_msg (MuMsgFile *msg, const char *path, GError **err);
|
||||||
@ -711,6 +706,7 @@ foreach_cb (GMimeObject *parent, GMimeObject *part, ForeachData *fdata)
|
|||||||
g_object_unref (dec);
|
g_object_unref (dec);
|
||||||
}
|
}
|
||||||
#endif /*BUILD_CRYPTO*/
|
#endif /*BUILD_CRYPTO*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -30,15 +30,10 @@
|
|||||||
#include "mu-msg-priv.h"
|
#include "mu-msg-priv.h"
|
||||||
#include "mu-msg-part.h"
|
#include "mu-msg-part.h"
|
||||||
|
|
||||||
#ifdef BUILD_CRYPTO
|
|
||||||
#include "mu-msg-crypto.h"
|
|
||||||
#endif /*BUILD_CRYPTO*/
|
|
||||||
|
|
||||||
static gboolean handle_children (MuMsg *msg,
|
static gboolean handle_children (MuMsg *msg,
|
||||||
GMimeMessage *mime_msg, MuMsgOptions opts,
|
GMimeMessage *mime_msg, MuMsgOptions opts,
|
||||||
unsigned index, MuMsgPartForeachFunc func,
|
unsigned index, MuMsgPartForeachFunc func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
struct _DoData {
|
struct _DoData {
|
||||||
GMimeObject *mime_obj;
|
GMimeObject *mime_obj;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
@ -303,6 +298,7 @@ get_disposition (GMimeObject *mobj)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_signature (MuMsg *msg, GMimeMultipartSigned *part, MuMsgOptions opts)
|
check_signature (MuMsg *msg, GMimeMultipartSigned *part, MuMsgOptions opts)
|
||||||
{
|
{
|
||||||
|
#ifdef BUILD_CRYPTO
|
||||||
/* the signature status */
|
/* the signature status */
|
||||||
MuMsgPartSigStatusReport *sigrep;
|
MuMsgPartSigStatusReport *sigrep;
|
||||||
GError *err;
|
GError *err;
|
||||||
@ -319,7 +315,7 @@ check_signature (MuMsg *msg, GMimeMultipartSigned *part, MuMsgOptions opts)
|
|||||||
(G_OBJECT(part), SIG_STATUS_REPORT,
|
(G_OBJECT(part), SIG_STATUS_REPORT,
|
||||||
sigrep,
|
sigrep,
|
||||||
(GDestroyNotify)mu_msg_part_sig_status_report_destroy);
|
(GDestroyNotify)mu_msg_part_sig_status_report_destroy);
|
||||||
|
#endif /*BUILD_CRYPTO*/
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,10 +357,9 @@ handle_part (MuMsg *msg, GMimePart *part, GMimeObject *parent,
|
|||||||
msgpart.part_type |= MU_MSG_PART_TYPE_TEXT_HTML;
|
msgpart.part_type |= MU_MSG_PART_TYPE_TEXT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the sig status from the parent, but don't set if for
|
/* put the verification info in the pgp-signature part */
|
||||||
* the signature part itself */
|
|
||||||
msgpart.sig_status_report = NULL;
|
msgpart.sig_status_report = NULL;
|
||||||
if (g_ascii_strcasecmp (msgpart.subtype, "pgp-signature") != 0)
|
if (g_ascii_strcasecmp (msgpart.subtype, "pgp-signature") == 0)
|
||||||
msgpart.sig_status_report =
|
msgpart.sig_status_report =
|
||||||
(MuMsgPartSigStatusReport*)
|
(MuMsgPartSigStatusReport*)
|
||||||
g_object_get_data (G_OBJECT(parent), SIG_STATUS_REPORT);
|
g_object_get_data (G_OBJECT(parent), SIG_STATUS_REPORT);
|
||||||
|
|||||||
@ -108,6 +108,7 @@ void mu_mime_message_foreach (GMimeMessage *msg, gboolean decrypt,
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
#ifdef BUILD_CRYPTO
|
#ifdef BUILD_CRYPTO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* callback function to retrieve a password from the user
|
* callback function to retrieve a password from the user
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user