diff options
author | Not Zed <NotZed@Ximian.com> | 2003-10-30 12:58:33 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-10-30 12:58:33 +0800 |
commit | 52759f2d4018b8ff0ce173aa1237b08783f1424c (patch) | |
tree | c6b392bea311df4d965b3e234cb769d6bf78e7e0 /camel/camel-multipart-encrypted.c | |
parent | 4c9e3c871c301e92711b91f0df0aca2521567db1 (diff) | |
download | gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.tar gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.tar.gz gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.tar.bz2 gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.tar.lz gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.tar.xz gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.tar.zst gsoc2013-evolution-52759f2d4018b8ff0ce173aa1237b08783f1424c.zip |
Added a note about api inconsistencies.
2003-10-30 Not Zed <NotZed@Ximian.com>
* camel-cipher-context.h: Added a note about api inconsistencies.
2003-10-30 Not Zed <NotZed@Ximian.com>
* camel-multipart-encrypted.c (camel_multipart_encrypted_decrypt):
fix for cipher_decrypt changes.
* camel-gpg-context.c, camel-cipher-context.c: moved all the init
code to the end to save having to keep forward declarations
around.
(camel_cipher_decrypt): changed to take mimepart input and return
a mimepart.
(gpg_decrypt): fix for changed args.
2003-10-29 Not Zed <NotZed@Ximian.com>
* camel-smime-context.[ch]: replaced entirely with a new
implementation which inherits from camel-cipher-context, and add
to build.
* camel-multipart-encrypted.c (camel_multipart_encrypted_encrypt):
fix for cipher_encrypt api changes.
(camel_multipart_encrypted_decrypt): use g_ascii_strcasecmp.
* camel-gpg-context.c (gpg_encrypt): Fix to handle input/output as
parts not streams
* camel-cipher-context.c (camel_cipher_encrypt): change to take
mimeparts rather than streams as input/output. And remove the
'sign' argument, it is implied if userid is supplied.
2003-10-28 Not Zed <NotZed@Ximian.com>
* tests/smime/pgp.c (main): fix for ciphercontext api changes.
* camel-multipart-signed.c (camel_multipart_signed_verify): pass
in the part to cipher_verify directly.
(camel_multipart_signed_sign): let the cipher context setup the
part details.
* camel-gpg-context.c (gpg_sign): put the signature stream into a
mimepart, with appropriate headers/encoding.
(swrite): write out a mimepart rather than a stream.
(gpg_verify): handle changed args.
* camel-cipher-context.c (camel_cipher_sign): write the signature
to a mimepart rather than a simple stream.
(camel_cipher_verify): take the signature as a mimepart not a
stream.
2003-10-22 Not Zed <NotZed@Ximian.com>
* camel-utf8.c (camel_ucs2_utf8, camel_utf8_ucs2): helpers for
ucs2 stuff. ucs2 is 16 bit truncated unicode.
svn path=/trunk/; revision=23127
Diffstat (limited to 'camel/camel-multipart-encrypted.c')
-rw-r--r-- | camel/camel-multipart-encrypted.c | 86 |
1 files changed, 9 insertions, 77 deletions
diff --git a/camel/camel-multipart-encrypted.c b/camel/camel-multipart-encrypted.c index 90866a9a20..d906ae80fc 100644 --- a/camel/camel-multipart-encrypted.c +++ b/camel/camel-multipart-encrypted.c @@ -145,42 +145,20 @@ camel_multipart_encrypted_encrypt (CamelMultipartEncrypted *mpe, CamelMimePart * CamelMimePart *version_part, *encrypted_part; CamelContentType *mime_type; CamelDataWrapper *wrapper; - CamelStream *filtered_stream; - CamelStream *stream, *ciphertext; - CamelMimeFilter *crlf_filter; + CamelStream *stream; g_return_val_if_fail (CAMEL_IS_MULTIPART_ENCRYPTED (mpe), -1); g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (cipher), -1); g_return_val_if_fail (cipher->encrypt_protocol != NULL, -1); g_return_val_if_fail (CAMEL_IS_MIME_PART (content), -1); - /* get the cleartext */ - stream = camel_stream_mem_new (); - filtered_stream = (CamelStream *) camel_stream_filter_new_with_stream (stream); - - crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, - CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); - camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), crlf_filter); - camel_object_unref (crlf_filter); - - camel_data_wrapper_write_to_stream ((CamelDataWrapper *) content, filtered_stream); - camel_stream_flush (filtered_stream); - camel_object_unref (filtered_stream); - - /* reset the content stream */ - camel_stream_reset (stream); - /* encrypt the content stream */ - ciphertext = camel_stream_mem_new (); - if (camel_cipher_encrypt (cipher, FALSE, userid, recipients, stream, ciphertext, ex) == -1) { - camel_object_unref (ciphertext); - camel_object_unref (stream); + encrypted_part = camel_mime_part_new(); + if (camel_cipher_encrypt (cipher, userid, recipients, content, encrypted_part, ex) == -1) { + camel_object_unref(encrypted_part); return -1; } - camel_object_unref (stream); - camel_stream_reset (ciphertext); - /* construct the version part */ stream = camel_stream_mem_new (); camel_stream_write_string (stream, "Version: 1\n"); @@ -193,16 +171,7 @@ camel_multipart_encrypted_encrypt (CamelMultipartEncrypted *mpe, CamelMimePart * camel_object_unref (stream); camel_medium_set_content_object ((CamelMedium *) version_part, wrapper); camel_object_unref (wrapper); - - /* construct the encrypted mime part */ - encrypted_part = camel_mime_part_new (); - wrapper = camel_data_wrapper_new (); - camel_data_wrapper_set_mime_type (wrapper, "application/octet-stream; name=encrypted.asc"); - camel_data_wrapper_construct_from_stream (wrapper, ciphertext); - camel_object_unref (ciphertext); - camel_medium_set_content_object ((CamelMedium *) encrypted_part, wrapper); - camel_object_unref (wrapper); - + /* save the version and encrypted parts */ /* FIXME: make sure there aren't any other parts?? */ camel_multipart_add_part (CAMEL_MULTIPART (mpe), version_part); @@ -233,10 +202,6 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe, CamelMimePart *version_part, *encrypted_part, *decrypted_part; CamelContentType *mime_type; CamelDataWrapper *wrapper; - CamelStream *filtered_stream; - CamelMimeFilter *crlf_filter; - CamelStream *ciphertext; - CamelStream *stream; const char *protocol; char *content_type; @@ -254,7 +219,7 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe, if (protocol) { /* make sure the protocol matches the cipher encrypt protocol */ - if (strcasecmp (cipher->encrypt_protocol, protocol) != 0) { + if (g_ascii_strcasecmp (cipher->encrypt_protocol, protocol) != 0) { camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to decrypt MIME part: protocol error")); @@ -269,7 +234,7 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe, version_part = camel_multipart_get_part (CAMEL_MULTIPART (mpe), CAMEL_MULTIPART_ENCRYPTED_VERSION); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (version_part)); content_type = camel_data_wrapper_get_mime_type (wrapper); - if (strcasecmp (content_type, protocol) != 0) { + if (g_ascii_strcasecmp (content_type, protocol) != 0) { camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to decrypt MIME part: protocol error")); @@ -288,44 +253,11 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe, return NULL; } - /* get the ciphertext stream */ - ciphertext = camel_stream_mem_new (); - wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (encrypted_part)); - camel_data_wrapper_write_to_stream (wrapper, ciphertext); - camel_stream_reset (ciphertext); - - stream = camel_stream_mem_new (); - filtered_stream = (CamelStream *) camel_stream_filter_new_with_stream (stream); - crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, - CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); - camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), crlf_filter); - camel_object_unref (crlf_filter); - - /* get the cleartext */ - if (camel_cipher_decrypt (cipher, ciphertext, filtered_stream, ex) == -1) { - camel_object_unref (filtered_stream); - camel_object_unref (ciphertext); - camel_object_unref (stream); - - return NULL; - } - - camel_stream_flush (filtered_stream); - camel_object_unref (filtered_stream); - camel_object_unref (ciphertext); - camel_stream_reset (stream); - - decrypted_part = camel_mime_part_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (decrypted_part), stream); - + decrypted_part = camel_cipher_decrypt(cipher, encrypted_part, ex); if (decrypted_part) { - /* cache the decrypted part */ camel_object_ref (decrypted_part); mpe->decrypted = decrypted_part; - } else { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - _("Failed to decrypt MIME part: parse error")); } - + return decrypted_part; } |