diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-08-26 01:09:39 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-08-26 01:09:39 +0800 |
commit | 0a45b2998b757513847fd35aa88396a88d3aac8a (patch) | |
tree | 1b2d3a8a4da6017b343ce113ad972196aba4ca55 /mail/mail-crypto.c | |
parent | 07e48b1c42e824f094d87e64017d466d9886c570 (diff) | |
download | gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.tar gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.tar.gz gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.tar.bz2 gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.tar.lz gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.tar.xz gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.tar.zst gsoc2013-evolution-0a45b2998b757513847fd35aa88396a88d3aac8a.zip |
Implemented PGP 2.x encryption. We only need to get the passphrase if we
2000-08-25 Jeffrey Stedfast <fejj@helixcode.com>
* mail-crypto.c (mail_crypto_openpgp_encrypt): Implemented PGP 2.x
encryption. We only need to get the passphrase if we plan to sign
the text, otherwise we don't need to worry about getting the
passphrase.
svn path=/trunk/; revision=5035
Diffstat (limited to 'mail/mail-crypto.c')
-rw-r--r-- | mail/mail-crypto.c | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c index 71a2573eeb..506a4a256d 100644 --- a/mail/mail-crypto.c +++ b/mail/mail-crypto.c @@ -402,6 +402,20 @@ mail_crypto_openpgp_decrypt (const char *ciphertext, CamelException *ex) return plaintext; } +/** + * mail_crypto_openpgp_encrypt: pgp encrypt plaintext + * @plaintext: text to encrypt + * @recipients: an array of recipients to encrypt to (preferably each + * element should be a pgp keyring ID however sometimes email + * addresses will work assuming that your pgp keyring has an + * entry for that address) + * @sign: TRUE if you wish to sign the encrypted text as well, FALSE otherwise + * @ex: a CamelException + * + * Initalizes the folder by setting the parent store, parent folder, + * and name. + **/ + char * mail_crypto_openpgp_encrypt (const char *plaintext, const GPtrArray *recipients, @@ -414,20 +428,23 @@ mail_crypto_openpgp_encrypt (const char *plaintext, int passwd_fds[2]; char passwd_fd[32]; - passphrase = mail_request_dialog ( - _("Please enter your PGP/GPG passphrase."), - TRUE, "pgp", FALSE); - if (!passphrase) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - _("No password provided.")); - return NULL; - } - - if (pipe (passwd_fds) < 0) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Couldn't create pipe to GPG/PGP: %s"), - g_strerror (errno)); - return NULL; + if (sign) { + /* we only need the passphrase if we plan to sign */ + passphrase = mail_request_dialog ( + _("Please enter your PGP/GPG passphrase."), + TRUE, "pgp", FALSE); + if (!passphrase) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("No password provided.")); + return NULL; + } + + if (pipe (passwd_fds) < 0) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Couldn't create pipe to GPG/PGP: %s"), + g_strerror (errno)); + return NULL; + } } i = 0; @@ -494,14 +511,34 @@ mail_crypto_openpgp_encrypt (const char *plaintext, sprintf (passwd_fd, "PGPPASSFD=%d", passwd_fds[0]); putenv (passwd_fd); } -#else /* We still gotta get pgp 2.6.3 workin here ;-) */ +#else path = PGP_PATH; + recipient_list = g_ptr_array_new (); + for (r = 0; r < recipients->len; r++) { + char *buf, *recipient; + + recipient = recipients->pdata[i]; + buf = g_strdup_printf ("-r %s", recipient); + g_ptr_array_add (recipient_list, buf); + } + argv[i++] = "pgp"; argv[i++] = "-f"; + argv[i++] = "-e"; + argv[i++] = "-a"; + argv[i++] = "-o"; + argv[i++] = "-"; - sprintf (passwd_fd, "PGPPASSFD=%d", passwd_fds[0]); - putenv (passwd_fd); + for (r = 0; r < recipient_list->len; r++) + argv[i++] = recipient_list->pdata[r]; + + if (sign) { + argv[i++] = "-s"; + + sprintf (passwd_fd, "PGPPASSFD=%d", passwd_fds[0]); + putenv (passwd_fd); + } #endif argv[i++] = NULL; @@ -523,7 +560,11 @@ mail_crypto_openpgp_encrypt (const char *plaintext, } g_free (diagnostics); + return ciphertext; } #endif /* PGP_PROGRAM */ + + + |