diff options
Diffstat (limited to 'camel/camel-multipart-signed.c')
-rw-r--r-- | camel/camel-multipart-signed.c | 33 |
1 files changed, 33 insertions, 0 deletions
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: |