Skip to content

Commit

Permalink
* crypto: improve signature checking code
Browse files Browse the repository at this point in the history
  • Loading branch information
djcb committed Sep 1, 2012
1 parent 7b39d56 commit 9d6ef76
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 64 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -52,7 +52,7 @@ AC_SYS_LARGEFILE
AC_CHECK_LIB([uuid], [uuid_generate_random],[],AC_MSG_ERROR([libuuid not found]))
AC_CHECK_LIB([z], [inflateEnd], [],AC_MSG_ERROR([zlib not found]))


# check for makeinfo
AC_CHECK_PROG(have_makeinfo,makeinfo,yes,no)
AM_CONDITIONAL(HAVE_MAKEINFO,test "x$have_makeinfo" = "xyes")
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.am
Expand Up @@ -21,7 +21,7 @@ include $(top_srcdir)/gtest.mk
SUBDIRS= . tests

if BUILD_CRYPTO
crypto=mu-msg-crypto.c mu-msg-crypto.h
crypto=mu-msg-crypto.c
else
crypto=
endif
Expand Down
22 changes: 5 additions & 17 deletions lib/mu-msg-crypto.c
Expand Up @@ -26,7 +26,6 @@
#include "mu-msg.h"
#include "mu-msg-priv.h"
#include "mu-msg-part.h"
#include "mu-msg-crypto.h"
#include "mu-date.h"

#include <gmime/gmime.h>
Expand Down Expand Up @@ -206,16 +205,11 @@ get_digestkey_algo_name (GMimeDigestAlgo algo)
static char*
get_cert_data (GMimeCertificate *cert)
{
const char /*issuer_name, *issuer_serial, ,*fprint*/
*email, *name,
*digest_algo, *pubkey_algo,
const char *email, *name, *digest_algo, *pubkey_algo,
*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);
name = g_mime_certificate_get_name (cert);
/* fprint = g_mime_certificate_get_fingerprint (cert); */
keyid = g_mime_certificate_get_key_id (cert);

digest_algo = get_digestkey_algo_name
Expand All @@ -235,10 +229,9 @@ get_cert_data (GMimeCertificate *cert)
}

return g_strdup_printf (
"signed by: %s <%s>; " /*; issued by %s (%s); */
"signed by: %s <%s>; "
"algos: <%s,%s>; key-id: %s; trust: %s",
name ? name : "?", email ? email : "?",
/* issuer_name, issuer_serial */
pubkey_algo, digest_algo, keyid, trust);
}

Expand Down Expand Up @@ -294,8 +287,7 @@ get_status_report (GMimeSignatureList *sigs)
sigstat = g_mime_signature_get_status (msig);

switch (sigstat) {
case GMIME_SIGNATURE_STATUS_GOOD:
break;
case GMIME_SIGNATURE_STATUS_GOOD: break;
case GMIME_SIGNATURE_STATUS_ERROR:
status = MU_MSG_PART_SIG_STATUS_ERROR;
break;
Expand All @@ -306,10 +298,8 @@ get_status_report (GMimeSignatureList *sigs)
}

rep = get_verdict_report (msig);
report = g_strdup_printf ("%s%s[%d] %s",
report ? report : "",
report ? "; " : "",
i, rep);
report = g_strdup_printf ("%s%s[%d] %s", report ? report : "",
report ? "; " : "", i, rep);
g_free (rep);
}

Expand Down Expand Up @@ -364,8 +354,6 @@ mu_msg_crypto_verify_part (GMimeMultipartSigned *sig, MuMsgOptions opts,
}




GMimeObject* /* this is declared in mu-msg-priv.h */
mu_msg_crypto_decrypt_part (GMimeMultipartEncrypted *enc, MuMsgOptions opts,
MuMsgPartPasswordFunc func, gpointer user_data,
Expand Down
31 changes: 0 additions & 31 deletions lib/mu-msg-crypto.h

This file was deleted.

6 changes: 1 addition & 5 deletions lib/mu-msg-file.c
Expand Up @@ -32,11 +32,6 @@
#include "mu-maildir.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,
const char *mdir, GError **err);
static gboolean init_mime_msg (MuMsgFile *msg, const char *path, GError **err);
Expand Down Expand Up @@ -711,6 +706,7 @@ foreach_cb (GMimeObject *parent, GMimeObject *part, ForeachData *fdata)
g_object_unref (dec);
}
#endif /*BUILD_CRYPTO*/

}


Expand Down
13 changes: 4 additions & 9 deletions lib/mu-msg-part.c
Expand Up @@ -30,15 +30,10 @@
#include "mu-msg-priv.h"
#include "mu-msg-part.h"

#ifdef BUILD_CRYPTO
#include "mu-msg-crypto.h"
#endif /*BUILD_CRYPTO*/

static gboolean handle_children (MuMsg *msg,
GMimeMessage *mime_msg, MuMsgOptions opts,
unsigned index, MuMsgPartForeachFunc func,
gpointer user_data);

struct _DoData {
GMimeObject *mime_obj;
unsigned index;
Expand Down Expand Up @@ -303,6 +298,7 @@ get_disposition (GMimeObject *mobj)
static gboolean
check_signature (MuMsg *msg, GMimeMultipartSigned *part, MuMsgOptions opts)
{
#ifdef BUILD_CRYPTO
/* the signature status */
MuMsgPartSigStatusReport *sigrep;
GError *err;
Expand All @@ -319,7 +315,7 @@ check_signature (MuMsg *msg, GMimeMultipartSigned *part, MuMsgOptions opts)
(G_OBJECT(part), SIG_STATUS_REPORT,
sigrep,
(GDestroyNotify)mu_msg_part_sig_status_report_destroy);

#endif /*BUILD_CRYPTO*/
return TRUE;
}

Expand Down Expand Up @@ -361,10 +357,9 @@ handle_part (MuMsg *msg, GMimePart *part, GMimeObject *parent,
msgpart.part_type |= MU_MSG_PART_TYPE_TEXT_HTML;
}

/* get the sig status from the parent, but don't set if for
* the signature part itself */
/* put the verification info in the pgp-signature part */
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 =
(MuMsgPartSigStatusReport*)
g_object_get_data (G_OBJECT(parent), SIG_STATUS_REPORT);
Expand Down
1 change: 1 addition & 0 deletions lib/mu-msg-priv.h
Expand Up @@ -108,6 +108,7 @@ void mu_mime_message_foreach (GMimeMessage *msg, gboolean decrypt,
gpointer user_data);

#ifdef BUILD_CRYPTO

/**
* callback function to retrieve a password from the user
*
Expand Down

0 comments on commit 9d6ef76

Please sign in to comment.