aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-12-01 09:30:45 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-12-01 09:30:45 +0800
commitd98f355957a9d1186f4f6506fbf06d010434d648 (patch)
tree657595e71d87641aa7e5395a06fca1b319a8db96 /camel
parentbef182255624468737832990a344cd31a82dc9d9 (diff)
downloadgsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.tar
gsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.tar.gz
gsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.tar.bz2
gsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.tar.lz
gsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.tar.xz
gsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.tar.zst
gsoc2013-evolution-d98f355957a9d1186f4f6506fbf06d010434d648.zip
Added list-unsubscribe header match.
2003-11-28 Not Zed <NotZed@Ximian.com> * camel-mime-utils.c (mail_list_magic[]): Added list-unsubscribe header match. 2003-11-26 Not Zed <NotZed@Ximian.com> * camel-smime-context.c (sm_verify_cmsg): take a stream rather than a part for the content. (sm_verify): get the content directly as a stream. * camel-multipart-signed.c (camel_multipart_signed_get_content_stream): new api to get the content stream which will match the signed version. svn path=/trunk/; revision=23507
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog15
-rw-r--r--camel/camel-mime-utils.c2
-rw-r--r--camel/camel-multipart-signed.c33
-rw-r--r--camel/camel-multipart-signed.h2
-rw-r--r--camel/camel-smime-context.c51
5 files changed, 83 insertions, 20 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index fe6fbfa594..7cf23c5ce0 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-28 Not Zed <NotZed@Ximian.com>
+
+ * camel-mime-utils.c (mail_list_magic[]): Added list-unsubscribe
+ header match.
+
+2003-11-26 Not Zed <NotZed@Ximian.com>
+
+ * camel-smime-context.c (sm_verify_cmsg): take a stream rather
+ than a part for the content.
+ (sm_verify): get the content directly as a stream.
+
+ * camel-multipart-signed.c
+ (camel_multipart_signed_get_content_stream): new api to get the
+ content stream which will match the signed version.
+
2003-11-26 JP Rosevear <jpr@ximian.com>
* Makefile.am: make sure we always dist the smime stuff
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 524021c054..21ca860d40 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -3900,6 +3900,8 @@ static struct {
/* X-BeenThere: gnome-hackers@gnome.org */
/* X-BeenThere: gnome-hackers */
{ "X-BeenThere", "[ \t]*([^@]+)@?([^ \n\t\r>]*)" },
+ /* List-Unsubscribe: <mailto:gnome-hackers-unsubscribe@gnome.org> */
+ { "List-Unsubscribe", "<mailto:(.+)-unsubscribe@([^ \n\t\r>]*)" },
};
char *
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index 47d749ab73..5dca448a7f 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -655,6 +655,39 @@ camel_multipart_signed_sign(CamelMultipartSigned *mps, CamelCipherContext *conte
return 0;
}
+CamelStream *
+camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex)
+{
+ CamelStream *constream;
+
+ /* we need to be able to verify stuff we just signed as well as stuff we loaded from a stream/parser */
+
+ if (mps->contentraw) {
+ constream = mps->contentraw;
+ camel_object_ref((CamelObject *)constream);
+ } else {
+ CamelStream *sub;
+ CamelMimeFilter *canon_filter;
+
+ if (mps->start1 == -1 && parse_content(mps) == -1) {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("parse error"));
+ return NULL;
+ }
+
+ /* first, prepare our parts */
+ sub = camel_seekable_substream_new((CamelSeekableStream *)((CamelDataWrapper *)mps)->stream, mps->start1, mps->end1);
+ constream = (CamelStream *)camel_stream_filter_new_with_stream(sub);
+ camel_object_unref((CamelObject *)sub);
+
+ /* Note: see rfc2015 or rfc3156, section 5 */
+ canon_filter = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF);
+ camel_stream_filter_add((CamelStreamFilter *)constream, (CamelMimeFilter *)canon_filter);
+ camel_object_unref((CamelObject *)canon_filter);
+ }
+
+ return constream;
+}
+
/**
* camel_multipart_signed_verify:
* @mps:
diff --git a/camel/camel-multipart-signed.h b/camel/camel-multipart-signed.h
index be0a8b4d9d..2b0df64189 100644
--- a/camel/camel-multipart-signed.h
+++ b/camel/camel-multipart-signed.h
@@ -91,6 +91,8 @@ CamelType camel_multipart_signed_get_type (void);
/* public methods */
CamelMultipartSigned *camel_multipart_signed_new (void);
+CamelStream *camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex);
+
int camel_multipart_signed_sign (CamelMultipartSigned *mps, CamelCipherContext *context,
CamelMimePart *content, const char *uiserid,
CamelCipherHash hash, CamelException *ex);
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index c3beab2c54..dd7ed68b3f 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -521,7 +521,7 @@ sm_status_description(NSSCMSVerificationStatus status)
}
static CamelCipherValidity *
-sm_verify_cmsg(CamelCipherContext *context, NSSCMSMessage *cmsg, CamelMimePart *extpart, CamelException *ex)
+sm_verify_cmsg(CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *extstream, CamelException *ex)
{
struct _CamelSMIMEContextPrivate *p = ((CamelSMIMEContext *)context)->priv;
NSSCMSSignedData *sigd = NULL;
@@ -559,7 +559,7 @@ sm_verify_cmsg(CamelCipherContext *context, NSSCMSMessage *cmsg, CamelMimePart *
/* need to build digests of the content */
if (!NSS_CMSSignedData_HasDigests(sigd)) {
- if (extpart == NULL) {
+ if (extstream == NULL) {
camel_exception_setv(ex, 1, "Digests missing from enveloped data");
goto fail;
}
@@ -578,7 +578,7 @@ sm_verify_cmsg(CamelCipherContext *context, NSSCMSMessage *cmsg, CamelMimePart *
}
mem = (CamelStreamMem *)camel_stream_mem_new();
- camel_cipher_canonical_to_stream(extpart, CAMEL_MIME_FILTER_CANON_CRLF, (CamelStream *)mem);
+ camel_stream_write_to_stream(extstream, (CamelStream *)mem);
NSS_CMSDigestContext_Update(digcx, mem->buffer->data, mem->buffer->len);
camel_object_unref(mem);
@@ -677,37 +677,47 @@ sm_verify(CamelCipherContext *context, CamelMimePart *ipart, CamelException *ex)
NSSCMSDecoderContext *dec;
NSSCMSMessage *cmsg;
CamelStreamMem *mem;
- CamelCipherValidity *valid;
+ CamelStream *constream;
+ CamelCipherValidity *valid = NULL;
CamelContentType *ct;
const char *tmp;
- CamelMimePart *extpart, *sigpart;
+ CamelMimePart *sigpart;
CamelDataWrapper *dw;
dw = camel_medium_get_content_object((CamelMedium *)ipart);
ct = dw->mime_type;
+ /* FIXME: we should stream this to the decoder */
+ mem = (CamelStreamMem *)camel_stream_mem_new();
+
if (camel_content_type_is(ct, "multipart", "signed")) {
CamelMultipart *mps = (CamelMultipart *)dw;
tmp = camel_content_type_param(ct, "protocol");
- extpart = camel_multipart_get_part(mps, CAMEL_MULTIPART_SIGNED_CONTENT);
- sigpart = camel_multipart_get_part(mps, CAMEL_MULTIPART_SIGNED_SIGNATURE);
if (!CAMEL_IS_MULTIPART_SIGNED(mps)
|| tmp == NULL
- || g_ascii_strcasecmp(tmp, context->sign_protocol) != 0
- || extpart == NULL
- || sigpart == NULL) {
+ || g_ascii_strcasecmp(tmp, context->sign_protocol) != 0) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot verify message signature: Incorrect message format"));
+ goto fail;
+ }
+
+ constream = camel_multipart_signed_get_content_stream((CamelMultipartSigned *)mps, ex);
+ if (constream == NULL)
+ goto fail;
+
+ sigpart = camel_multipart_get_part(mps, CAMEL_MULTIPART_SIGNED_SIGNATURE);
+ if (sigpart == NULL) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot verify message signature: Incorrect message format"));
- return NULL;
+ goto fail;
}
} else if (camel_content_type_is(ct, "application", "x-pkcs7-mime")) {
- extpart = NULL;
sigpart = ipart;
} else {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot verify message signature: Incorrect message format"));
- return NULL;
+ goto fail;
}
dec = NSS_CMSDecoder_Start(NULL,
@@ -715,20 +725,21 @@ sm_verify(CamelCipherContext *context, CamelMimePart *ipart, CamelException *ex)
sm_get_passwd, context, /* password callback */
NULL, NULL); /* decrypt key callback */
- /* FIXME: we should stream this to the decoder */
- mem = (CamelStreamMem *)camel_stream_mem_new();
camel_data_wrapper_decode_to_stream(camel_medium_get_content_object((CamelMedium *)sigpart), (CamelStream *)mem);
(void)NSS_CMSDecoder_Update(dec, mem->buffer->data, mem->buffer->len);
- camel_object_unref(mem);
cmsg = NSS_CMSDecoder_Finish(dec);
if (cmsg == NULL) {
camel_exception_setv(ex, 1, "Decoder failed");
- return NULL;
+ goto fail;
}
-
- valid = sm_verify_cmsg(context, cmsg, extpart, ex);
-
+
+ valid = sm_verify_cmsg(context, cmsg, constream, ex);
+
NSS_CMSMessage_Destroy(cmsg);
+fail:
+ camel_object_unref(mem);
+ if (constream)
+ camel_object_unref(constream);
return valid;
}