aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-pgp-mime.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-02-28 07:45:28 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-02-28 07:45:28 +0800
commite83a759e4ea8eec0615f8306cacacd620702dc2f (patch)
treebe33277fa2fe2c1369dc385b3ab23c73dd0ebc2e /camel/camel-pgp-mime.c
parent9cf2e390356256917fe31ae544e39dfc35a879ce (diff)
downloadgsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.tar
gsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.tar.gz
gsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.tar.bz2
gsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.tar.lz
gsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.tar.xz
gsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.tar.zst
gsoc2013-evolution-e83a759e4ea8eec0615f8306cacacd620702dc2f.zip
New stream filter that chomps excess trailing whitespace from the end of
2002-02-27 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-filter-chomp.c (camel_mime_filter_chomp_new): New stream filter that chomps excess trailing whitespace from the end of the stream. This is needed to update the PGP/MIME code to comply with rfc3156. * camel-pgp-mime.c (camel_pgp_mime_part_verify): Don't attach a from filter, if it ain't from-filtered already, then we'll just be breaking stuff. To become rfc3156 compliant, add a chomp filter here. (camel_pgp_mime_part_sign): Add a chomp filter here too. svn path=/trunk/; revision=15863
Diffstat (limited to 'camel/camel-pgp-mime.c')
-rw-r--r--camel/camel-pgp-mime.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/camel/camel-pgp-mime.c b/camel/camel-pgp-mime.c
index f65f0f78a1..4e3eee7cba 100644
--- a/camel/camel-pgp-mime.c
+++ b/camel/camel-pgp-mime.c
@@ -30,6 +30,7 @@
#include "camel-mime-filter-from.h"
#include "camel-mime-filter-crlf.h"
#include "camel-mime-filter-charset.h"
+#include "camel-mime-filter-chomp.h"
#include "camel-stream-filter.h"
#include "camel-stream-mem.h"
#include "camel-stream-fs.h"
@@ -42,7 +43,7 @@
#define d(x) x
-/** rfc2015 stuff (aka PGP/MIME) *******************************/
+/** rfc2015/rfc3156 stuff (aka PGP/MIME) *******************************/
gboolean
camel_pgp_mime_is_rfc2015_signed (CamelMimePart *mime_part)
@@ -235,10 +236,10 @@ camel_pgp_mime_part_sign (CamelPgpContext *context, CamelMimePart **mime_part, c
CamelMultipart *multipart;
CamelContentType *mime_type;
CamelStreamFilter *filtered_stream;
- CamelMimeFilter *crlf_filter, *from_filter;
+ CamelMimeFilter *crlf_filter, *from_filter, *chomp_filter;
CamelStream *stream, *sigstream;
- gchar *hash_type = NULL;
GSList *encodings = NULL;
+ char *hash_type = NULL;
g_return_if_fail (*mime_part != NULL);
g_return_if_fail (CAMEL_IS_MIME_PART (*mime_part));
@@ -251,24 +252,42 @@ camel_pgp_mime_part_sign (CamelPgpContext *context, CamelMimePart **mime_part, c
/* get the cleartext */
stream = camel_stream_mem_new ();
+ filtered_stream = camel_stream_filter_new_with_stream (stream);
+
+ /* Note: see rfc3156, section 3 - second note */
+ from_filter = CAMEL_MIME_FILTER (camel_mime_filter_from_new ());
+ camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (from_filter));
+ camel_object_unref (CAMEL_OBJECT (from_filter));
+
+ /* Note: see rfc3156, section 5.4 (this is the big thing that changed between rfc2015 and rfc3156) */
+ chomp_filter = camel_mime_filter_chomp_new ();
+ camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (chomp_filter));
+ camel_object_unref (CAMEL_OBJECT (chomp_filter));
+
+ /* Note: see rfc2015 or rfc3156, section 5.1 */
crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE,
CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
- from_filter = CAMEL_MIME_FILTER (camel_mime_filter_from_new ());
- filtered_stream = camel_stream_filter_new_with_stream (stream);
camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlf_filter));
camel_object_unref (CAMEL_OBJECT (crlf_filter));
- camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (from_filter));
- camel_object_unref (CAMEL_OBJECT (from_filter));
+
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (part), CAMEL_STREAM (filtered_stream));
+ camel_stream_flush (CAMEL_STREAM (filtered_stream));
camel_object_unref (CAMEL_OBJECT (filtered_stream));
/* reset the stream */
camel_stream_reset (stream);
+ printf ("attempting to sign data:\n----- BEGIN SIGNED PART -----\n%.*s----- END SIGNED PART -----\n",
+ CAMEL_STREAM_MEM (stream)->buffer->len, CAMEL_STREAM_MEM (stream)->buffer->data);
+
/* construct the signature stream */
sigstream = camel_stream_mem_new ();
switch (hash) {
+ case CAMEL_CIPHER_HASH_MD2:
+ /* this is a new addition with rfc3156 */
+ hash_type = "pgp-md2";
+ break;
case CAMEL_CIPHER_HASH_MD5:
hash_type = "pgp-md5";
break;
@@ -350,7 +369,7 @@ camel_pgp_mime_part_verify (CamelPgpContext *context, CamelMimePart *mime_part,
CamelMultipart *multipart;
CamelMimePart *part, *sigpart;
CamelStreamFilter *filtered_stream;
- CamelMimeFilter *crlf_filter, *from_filter;
+ CamelMimeFilter *crlf_filter, *chomp_filter;
CamelStream *stream, *sigstream;
CamelCipherValidity *valid;
@@ -366,17 +385,22 @@ camel_pgp_mime_part_verify (CamelPgpContext *context, CamelMimePart *mime_part,
/* get the plain part */
part = camel_multipart_get_part (multipart, 0);
stream = camel_stream_mem_new ();
+ filtered_stream = camel_stream_filter_new_with_stream (stream);
+
+ /* Note: see rfc3156, section 5.4 (this is the big thing that changed between rfc2015 and rfc3156) */
+ chomp_filter = camel_mime_filter_chomp_new ();
+ camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (chomp_filter));
+ camel_object_unref (CAMEL_OBJECT (chomp_filter));
+
+ /* Note: see rfc2015 or rfc3156, section 5.1 */
crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE,
CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
- from_filter = CAMEL_MIME_FILTER (camel_mime_filter_from_new ());
- filtered_stream = camel_stream_filter_new_with_stream (stream);
camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlf_filter));
camel_object_unref (CAMEL_OBJECT (crlf_filter));
- camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (from_filter));
- camel_object_unref (CAMEL_OBJECT (from_filter));
wrapper = CAMEL_DATA_WRAPPER (part);
camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream));
+ camel_stream_flush (CAMEL_STREAM (filtered_stream));
camel_object_unref (CAMEL_OBJECT (filtered_stream));
camel_stream_reset (stream);
@@ -390,6 +414,9 @@ camel_pgp_mime_part_verify (CamelPgpContext *context, CamelMimePart *mime_part,
/* verify */
valid = camel_pgp_verify (context, stream, sigstream, ex);
+ printf ("attempted to verify data:\n----- BEGIN SIGNED PART -----\n%.*s----- END SIGNED PART -----\n",
+ CAMEL_STREAM_MEM (stream)->buffer->len, CAMEL_STREAM_MEM (stream)->buffer->data);
+
camel_object_unref (CAMEL_OBJECT (sigstream));
camel_object_unref (CAMEL_OBJECT (stream));