diff options
-rw-r--r-- | camel/ChangeLog | 8 | ||||
-rw-r--r-- | camel/camel-cipher-context.c | 45 | ||||
-rw-r--r-- | camel/camel-cipher-context.h | 10 | ||||
-rw-r--r-- | camel/camel-gpg-context.c | 13 | ||||
-rw-r--r-- | camel/camel-pgp-context.c | 175 |
5 files changed, 11 insertions, 240 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index a3d8ed28fc..0153a46643 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,13 @@ 2002-06-26 Jeffrey Stedfast <fejj@ximian.com> + * camel-gpg-context.c (gpg_clearsign): Removed (never did anything + anyway). + + * camel-pgp-context.c (pgp_clearsign): Removed. + + * camel-cipher-context.c (camel_cipher_clearsign): Removed unused + method. + * camel-multipart-encrypted.[c,h]: New class implementing the multipart/encrypted content type. Contains methods for encrypting and decrypting a multipart/encrypted MIME object. diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c index 7771a3a64a..185002831f 100644 --- a/camel/camel-cipher-context.c +++ b/camel/camel-cipher-context.c @@ -49,9 +49,6 @@ struct _CamelCipherContextPrivate { static int cipher_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, CamelStream *istream, CamelStream *ostream, CamelException *ex); -static int cipher_clearsign (CamelCipherContext *context, const char *userid, - CamelCipherHash hash, CamelStream *istream, - CamelStream *ostream, CamelException *ex); static CamelCipherValidity *cipher_verify (CamelCipherContext *context, CamelCipherHash hash, CamelStream *istream, CamelStream *sigstream, CamelException *ex); @@ -95,7 +92,6 @@ camel_cipher_context_class_init (CamelCipherContextClass *camel_cipher_context_c parent_class = camel_type_get_global_classfuncs (camel_object_get_type ()); camel_cipher_context_class->sign = cipher_sign; - camel_cipher_context_class->clearsign = cipher_clearsign; camel_cipher_context_class->verify = cipher_verify; camel_cipher_context_class->encrypt = cipher_encrypt; camel_cipher_context_class->decrypt = cipher_decrypt; @@ -206,46 +202,6 @@ camel_cipher_sign (CamelCipherContext *context, const char *userid, CamelCipherH } -static int -cipher_clearsign (CamelCipherContext *context, const char *userid, CamelCipherHash hash, - CamelStream *istream, CamelStream *ostream, CamelException *ex) -{ - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - _("Clearsigning is not supported by this cipher")); - return -1; -} - -/** - * camel_cipher_clearsign: - * @context: Cipher Context - * @userid: key id or email address of the private key to sign with - * @hash: preferred Message-Integrity-Check hash algorithm - * @istream: input stream - * @ostream: output stream - * @ex: exception - * - * Clearsigns the input stream and writes the resulting clearsign to the output stream. - * - * Return value: 0 for success or -1 for failure. - **/ -int -camel_cipher_clearsign (CamelCipherContext *context, const char *userid, CamelCipherHash hash, - CamelStream *istream, CamelStream *ostream, CamelException *ex) -{ - int retval; - - g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1); - - CIPHER_LOCK(context); - - retval = CCC_CLASS (context)->clearsign (context, userid, hash, istream, ostream, ex); - - CIPHER_UNLOCK(context); - - return retval; -} - - static CamelCipherValidity * cipher_verify (CamelCipherContext *context, CamelCipherHash hash, CamelStream *istream, CamelStream *sigstream, CamelException *ex) @@ -255,6 +211,7 @@ cipher_verify (CamelCipherContext *context, CamelCipherHash hash, CamelStream *i return NULL; } + /** * camel_cipher_verify: * @context: Cipher Context diff --git a/camel/camel-cipher-context.h b/camel/camel-cipher-context.h index 452c093eef..296d7e5b39 100644 --- a/camel/camel-cipher-context.h +++ b/camel/camel-cipher-context.h @@ -65,9 +65,6 @@ typedef struct _CamelCipherContextClass { int (*sign) (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, CamelStream *istream, CamelStream *ostream, CamelException *ex); - int (*clearsign) (CamelCipherContext *context, const char *userid, CamelCipherHash hash, - CamelStream *istream, CamelStream *ostream, CamelException *ex); - CamelCipherValidity * (*verify) (CamelCipherContext *context, CamelCipherHash hash, CamelStream *istream, CamelStream *sigstream, CamelException *ex); @@ -94,9 +91,6 @@ void camel_cipher_context_construct (CamelCipherContext *context int camel_cipher_sign (CamelCipherContext *context, const char *userid, CamelCipherHash hash, CamelStream *istream, CamelStream *ostream, CamelException *ex); -int camel_cipher_clearsign (CamelCipherContext *context, const char *userid, CamelCipherHash hash, - CamelStream *istream, CamelStream *ostream, CamelException *ex); - CamelCipherValidity *camel_cipher_verify (CamelCipherContext *context, CamelCipherHash hash, CamelStream *istream, CamelStream *sigstream, CamelException *ex); @@ -109,8 +103,8 @@ int camel_cipher_decrypt (CamelCipherContext *context, CamelStr CamelException *ex); /* cipher context util routines */ -CamelCipherHash camel_cipher_id_to_hash(CamelCipherContext *context, const char *id); -const char * camel_cipher_hash_to_id(CamelCipherContext *context, CamelCipherHash hash); +CamelCipherHash camel_cipher_id_to_hash (CamelCipherContext *context, const char *id); +const char * camel_cipher_hash_to_id (CamelCipherContext *context, CamelCipherHash hash); /* CamelCipherValidity utility functions */ CamelCipherValidity *camel_cipher_validity_new (void); diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 1c7daaa72b..e4101071b4 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -53,9 +53,6 @@ static void camel_gpg_context_finalise (CamelObject *obj); static int gpg_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, CamelStream *istream, CamelStream *ostream, CamelException *ex); -static int gpg_clearsign (CamelCipherContext *context, const char *userid, - CamelCipherHash hash, CamelStream *istream, - CamelStream *ostream, CamelException *ex); static CamelCipherValidity *gpg_verify (CamelCipherContext *context, CamelCipherHash hash, CamelStream *istream, CamelStream *sigstream, CamelException *ex); @@ -99,7 +96,6 @@ camel_gpg_context_class_init (CamelGpgContextClass *klass) parent_class = CAMEL_CIPHER_CONTEXT_CLASS (camel_type_get_global_classfuncs (camel_cipher_context_get_type ())); cipher_class->sign = gpg_sign; - cipher_class->clearsign = gpg_clearsign; cipher_class->verify = gpg_verify; cipher_class->encrypt = gpg_encrypt; cipher_class->decrypt = gpg_decrypt; @@ -1202,15 +1198,6 @@ gpg_sign (CamelCipherContext *context, const char *userid, CamelCipherHash hash, } -static int -gpg_clearsign (CamelCipherContext *context, const char *userid, - CamelCipherHash hash, CamelStream *istream, - CamelStream *ostream, CamelException *ex) -{ - return -1; -} - - static char * swrite (CamelStream *istream) { diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c index eb315c3a18..47e912a903 100644 --- a/camel/camel-pgp-context.c +++ b/camel/camel-pgp-context.c @@ -68,9 +68,6 @@ struct _CamelPgpContextPrivate { static int pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, CamelStream *istream, CamelStream *ostream, CamelException *ex); -static int pgp_clearsign (CamelCipherContext *context, const char *userid, - CamelCipherHash hash, CamelStream *istream, - CamelStream *ostream, CamelException *ex); static CamelCipherValidity *pgp_verify (CamelCipherContext *context, CamelCipherHash hash, CamelStream *istream, CamelStream *sigstream, CamelException *ex); @@ -115,7 +112,6 @@ camel_pgp_context_class_init (CamelPgpContextClass *camel_pgp_context_class) parent_class = CAMEL_CIPHER_CONTEXT_CLASS (camel_type_get_global_classfuncs (camel_cipher_context_get_type ())); camel_cipher_context_class->sign = pgp_sign; - camel_cipher_context_class->clearsign = pgp_clearsign; camel_cipher_context_class->verify = pgp_verify; camel_cipher_context_class->encrypt = pgp_encrypt; camel_cipher_context_class->decrypt = pgp_decrypt; @@ -774,177 +770,6 @@ pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, } -static int -pgp_clearsign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, - CamelStream *istream, CamelStream *ostream, CamelException *ex) -{ - CamelPgpContext *context = CAMEL_PGP_CONTEXT (ctx); - GByteArray *plaintext; - CamelStream *stream; - char *argv[20]; - char *ciphertext = NULL; - char *diagnostics = NULL; - char *passphrase = NULL; - char *hash_str = NULL; - int passwd_fds[2]; - char passwd_fd[32]; - int retval, i; - - /* check for the now unsupported pgp 2.6.x type */ - if (context->priv->type == CAMEL_PGP_TYPE_PGP2) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - "PGP 2.6.x is no longer supported."); - return -1; - } - - /* get the plaintext in a form we can use */ - plaintext = g_byte_array_new (); - stream = camel_stream_mem_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), plaintext); - camel_stream_write_to_stream (istream, stream); - camel_object_unref (CAMEL_OBJECT (stream)); - - if (!plaintext->len) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - _("Cannot sign this message: no plaintext to clearsign")); - goto exception; - } - - passphrase = pgp_get_passphrase (ctx->session, context->priv->type, (char *) userid); - if (!passphrase) { - camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, - _("Cannot sign this message: no password provided")); - goto exception; - } - - if (pipe (passwd_fds) < 0) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Cannot sign this message: couldn't create pipe to GPG/PGP: %s"), - g_strerror (errno)); - goto exception; - } - - hash_str = hash_string (context, hash); - - i = 0; - switch (context->priv->type) { - case CAMEL_PGP_TYPE_GPG: - argv[i++] = "gpg"; - - argv[i++] = "--clearsign"; - - if (hash_str) { - argv[i++] = "--digest-algo"; - argv[i++] = hash_str; - } - - if (userid) { - argv[i++] = "-u"; - argv[i++] = (char *) userid; - } - - argv[i++] = "--verbose"; - argv[i++] = "--no-secmem-warning"; - argv[i++] = "--no-greeting"; - argv[i++] = "--yes"; - argv[i++] = "--always-trust"; - argv[i++] = "--batch"; - - argv[i++] = "--armor"; - - argv[i++] = "--output"; - argv[i++] = "-"; /* output to stdout */ - - argv[i++] = "--passphrase-fd"; - sprintf (passwd_fd, "%d", passwd_fds[0]); - argv[i++] = passwd_fd; - break; - case CAMEL_PGP_TYPE_PGP5: - argv[i++] = "pgps"; - - if (hash_str) - argv[i++] = hash_str; - - if (userid) { - argv[i++] = "-u"; - argv[i++] = (char *) userid; - } - - argv[i++] = "-f"; /* -f means act as a unix-style filter */ - argv[i++] = "-v"; /* -v means verbose diagnostic messages */ - argv[i++] = "-z"; /* FIXME: do we want this option!? */ - argv[i++] = "-a"; /* -a means ascii armor */ - argv[i++] = "-o"; /* -o specifies an output stream */ - argv[i++] = "-"; /* ...in this case, stdout */ - - sprintf (passwd_fd, "PGPPASSFD=%d", passwd_fds[0]); - putenv (passwd_fd); - break; - case CAMEL_PGP_TYPE_PGP2: - case CAMEL_PGP_TYPE_PGP6: - argv[i++] = "pgp"; - - if (hash_str) - argv[i++] = hash_str; - - if (userid) { - argv[i++] = "-u"; - argv[i++] = (char *) userid; - } - - argv[i++] = "-f"; /* -f means act as a unix-style filter */ - argv[i++] = "-l"; /* -l means show longer more descriptive diagnostic messages */ - argv[i++] = "-a"; /* -a means ascii armor */ - argv[i++] = "-o"; /* -o specifies an output stream */ - argv[i++] = "-"; /* ...in this case, stdout */ - - argv[i++] = "-st"; - sprintf (passwd_fd, "PGPPASSFD=%d", passwd_fds[0]); - putenv (passwd_fd); - break; - default: - g_assert_not_reached (); - break; - } - - argv[i++] = NULL; - - retval = crypto_exec_with_passwd (context->priv->path, argv, - plaintext->data, plaintext->len, - passwd_fds, passphrase, - &ciphertext, NULL, - &diagnostics); - - g_byte_array_free (plaintext, TRUE); - pass_free (passphrase); - - if (retval != 0 || !*ciphertext) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, diagnostics); - g_free (diagnostics); - g_free (ciphertext); - pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid); - } - - g_free (diagnostics); - - camel_stream_write (ostream, ciphertext, strlen (ciphertext)); - g_free (ciphertext); - - return 0; - - exception: - - g_byte_array_free (plaintext, TRUE); - - if (passphrase) { - pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid); - pass_free (passphrase); - } - - return -1; -} - - static char * swrite (CamelStream *istream) { |