aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-03-07 14:37:18 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-03-07 14:37:18 +0800
commitae05d707ad0185f657c466181b0320ad04ed0ee8 (patch)
tree5693ed08a22bf6b7658855fb097812c5673a8ecd /mail
parent53af5692dfd501eb6ba728abb934931f6d5c8ab8 (diff)
downloadgsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.tar
gsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.tar.gz
gsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.tar.bz2
gsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.tar.lz
gsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.tar.xz
gsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.tar.zst
gsoc2013-evolution-ae05d707ad0185f657c466181b0320ad04ed0ee8.zip
New function to decide if a mime part is an S/MIME v3 signed part.
2001-03-07 Jeffrey Stedfast <fejj@ximian.com> * mail-crypto.c (mail_crypto_is_smime_v3_signed): New function to decide if a mime part is an S/MIME v3 signed part. (mail_crypto_is_pkcs7_mime): New function to decide if a mime part is an application/pkcs7-mime part (or an application/octet-stream part with application/pkcs7-mime data). svn path=/trunk/; revision=8578
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog6
-rw-r--r--mail/mail-crypto.c118
-rw-r--r--mail/mail-crypto.h4
3 files changed, 107 insertions, 21 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 757cf4fa44..0434931791 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,11 @@
2001-03-07 Jeffrey Stedfast <fejj@ximian.com>
+ * mail-crypto.c (mail_crypto_is_smime_v3_signed): New function to
+ decide if a mime part is an S/MIME v3 signed part.
+ (mail_crypto_is_pkcs7_mime): New function to decide if a mime part
+ is an application/pkcs7-mime part (or an application/octet-stream
+ part with application/pkcs7-mime data).
+
* mail-account-editor.c (source_auth_init): Move the signal
emittion to after the set_menu call so that it actually works.
(transport_type_changed): Updated to manipulate the user/passwd
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c
index fcba02c0a4..0ae5083c33 100644
--- a/mail/mail-crypto.c
+++ b/mail/mail-crypto.c
@@ -29,25 +29,9 @@
#include "mail-crypto.h"
#include "mail-session.h"
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <signal.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <termios.h>
-#include <unistd.h>
-#include <signal.h>
-
#include <camel/camel-mime-filter-from.h>
-/** rfc2015 stuff *******************************/
+/** rfc2015 stuff (aka PGP/MIME) *******************************/
gboolean
mail_crypto_is_rfc2015_signed (CamelMimePart *mime_part)
@@ -56,7 +40,7 @@ mail_crypto_is_rfc2015_signed (CamelMimePart *mime_part)
CamelMultipart *mp;
CamelMimePart *part;
CamelContentType *type;
- const gchar *param;
+ const gchar *param, *micalg;
int nparts;
/* check that we have a multipart/signed */
@@ -69,6 +53,11 @@ mail_crypto_is_rfc2015_signed (CamelMimePart *mime_part)
if (!param || g_strcasecmp (param, "application/pgp-signature"))
return FALSE;
+ /* check that we have a micalg parameter */
+ micalg = header_content_type_param (type, "micalg");
+ if (!micalg)
+ return FALSE;
+
/* check that we have exactly 2 subparts */
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
mp = CAMEL_MULTIPART (wrapper);
@@ -89,8 +78,6 @@ mail_crypto_is_rfc2015_signed (CamelMimePart *mime_part)
if (!header_content_type_is (type, "application", "pgp-signature"))
return FALSE;
- /* FIXME: Implement multisig stuff */
-
return TRUE;
}
@@ -137,6 +124,97 @@ mail_crypto_is_rfc2015_encrypted (CamelMimePart *mime_part)
return TRUE;
}
+
+/** rfc2633 stuff (aka S/MIME v3) ********************************/
+
+gboolean
+mail_crypto_is_smime_v3_signed (CamelMimePart *mime_part)
+{
+ CamelDataWrapper *wrapper;
+ CamelMultipart *mp;
+ CamelMimePart *part;
+ CamelContentType *type;
+ const gchar *param, *micalg;
+ int nparts;
+
+ /* check that we have a multipart/signed */
+ type = camel_mime_part_get_content_type (mime_part);
+ if (!header_content_type_is (type, "multipart", "signed"))
+ return FALSE;
+
+ /* check that we have a protocol param with the value: "application/pgp-signed" */
+ param = header_content_type_param (type, "protocol");
+ if (!param || g_strcasecmp (param, "application/pkcs7-signature"))
+ return FALSE;
+
+ /* check that we have a micalg parameter */
+ micalg = header_content_type_param (type, "micalg");
+ if (!micalg)
+ return FALSE;
+
+ /* check that we have exactly 2 subparts */
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+ mp = CAMEL_MULTIPART (wrapper);
+ nparts = camel_multipart_get_number (mp);
+ if (nparts != 2)
+ return FALSE;
+
+ /* The first part may be of any type except for
+ * application/pkcs7-signature - check it. */
+ part = camel_multipart_get_part (mp, 0);
+ type = camel_mime_part_get_content_type (part);
+ if (header_content_type_is (type, "application", "pkcs7-signature"))
+ return FALSE;
+
+ /* The second part should be application/pkcs7-signature. */
+ part = camel_multipart_get_part (mp, 1);
+ type = camel_mime_part_get_content_type (part);
+ if (!header_content_type_is (type, "application", "pkcs7-signature"))
+ return FALSE;
+
+ return TRUE;
+}
+
+gboolean
+mail_crypto_is_pkcs7_mime (CamelMimePart *mime_part)
+{
+ char *types[] = { "p7m", "p7c", "p7s", NULL };
+ const gchar *param, *filename;
+ CamelContentType *type;
+ int i;
+
+ /* check that we have a application/pkcs7-mime part */
+ type = camel_mime_part_get_content_type (mime_part);
+ if (header_content_type_is (type, "application", "pkcs7-mime"))
+ return TRUE;
+
+ if (header_content_type_is (type, "application", "octent-stream")) {
+ /* check to see if we have a paremeter called "smime-type" */
+ param = header_content_type_param (type, "smime-type");
+ if (param)
+ return TRUE;
+
+ /* check to see if there is a name param and if it has a smime extension */
+ param = header_content_type_param (type, "smime-type");
+ if (param && *param && strlen (param) > 4) {
+ for (i = 0; types[i]; i++)
+ if (!g_strcasecmp (param + strlen (param)-4, types[i]))
+ return TRUE;
+ }
+
+ /* check to see if there is a name param and if it has a smime extension */
+ filename = camel_mime_part_get_filename (mime_part);
+ if (filename && *filename && strlen (filename) > 4) {
+ for (i = 0; types[i]; i++)
+ if (!g_strcasecmp (filename + strlen (filename)-4, types[i]))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
/**
* pgp_mime_part_sign:
* @mime_part: a MIME part that will be replaced by a pgp signed part
diff --git a/mail/mail-crypto.h b/mail/mail-crypto.h
index 8a5c328c9c..746320082e 100644
--- a/mail/mail-crypto.h
+++ b/mail/mail-crypto.h
@@ -33,9 +33,11 @@ extern "C" {
#endif /* __cplusplus }*/
gboolean mail_crypto_is_rfc2015_signed (CamelMimePart *part);
-
gboolean mail_crypto_is_rfc2015_encrypted (CamelMimePart *part);
+gboolean mail_crypto_is_smime_v3_signed (CamelMimePart *mime_part);
+gboolean mail_crypto_is_pkcs7_mime (CamelMimePart *mime_part);
+
void pgp_mime_part_sign (CamelMimePart **mime_part,
const gchar *userid,
PgpHashType hash,