--- crypt-gpgme.c | 334 +++++++++++++++++++++++----------------------- crypt-gpgme.h | 6 +- crypt-mod-pgp-classic.c | 8 +- crypt-mod-pgp-gpgme.c | 8 +- crypt-mod-smime-classic.c | 10 +- crypt-mod-smime-gpgme.c | 10 +- crypt-mod.c | 4 +- crypt-mod.h | 14 +- crypt.c | 96 ++++++------- cryptglue.c | 18 +-- 10 files changed, 254 insertions(+), 254 deletions(-)
diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 47be23bb..83293ec6 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -10,12 +10,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -272,7 +272,7 @@ static char crypt_flags (int flags) return 'd'; else if (flags & KEYFLAG_CRITICAL) return 'c'; - else + else return ' '; } @@ -357,21 +357,21 @@ static int crypt_id_matches_addr (ADDRESS *addr, ADDRESS *u_addr, crypt_key_t *key) { int rv = 0; - + if (crypt_id_is_valid (key)) rv |= CRYPT_KV_VALID; if (crypt_id_is_strong (key)) rv |= CRYPT_KV_STRONGID; - + if (addr->mailbox && u_addr->mailbox && mutt_strcasecmp (addr->mailbox, u_addr->mailbox) == 0) rv |= CRYPT_KV_ADDR; - + if (addr->personal && u_addr->personal && mutt_strcasecmp (addr->personal, u_addr->personal) == 0) rv |= CRYPT_KV_STRING; - + return rv; } @@ -418,7 +418,7 @@ static gpgme_data_t create_gpgme_data (void) gpgme_data_t data; err = gpgme_data_new (&data); - if (err) + if (err) { mutt_error (_("error creating gpgme data object: %s\n"), gpgme_strerror (err)); @@ -437,7 +437,7 @@ static gpgme_data_t body_to_data_object (BODY *a, int convert) FILE *fptmp; int err = 0; gpgme_data_t data; - + mutt_mktemp (tempfile, sizeof (tempfile)); fptmp = safe_fopen (tempfile, "w+"); if (!fptmp) @@ -461,14 +461,14 @@ static gpgme_data_t body_to_data_object (BODY *a, int convert) { if (c == '\r') hadcr = 1; - else + else { if (c == '\n' && !hadcr) { buf[0] = '\r'; gpgme_data_write (data, buf, 1); } - + hadcr = 0; } /* FIXME: This is quite suboptimal */ @@ -484,7 +484,7 @@ static gpgme_data_t body_to_data_object (BODY *a, int convert) err = gpgme_data_new_from_file (&data, tempfile, 1); } unlink (tempfile); - if (err) + if (err) { mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err)); return NULL; @@ -500,9 +500,9 @@ static gpgme_data_t file_to_data_object (FILE *fp, long offset, long length) { int err = 0; gpgme_data_t data; - + err = gpgme_data_new_from_filepart (&data, NULL, fp, offset, length); - if (err) + if (err) { mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err)); return NULL; @@ -659,12 +659,12 @@ static gpgme_key_t *create_recipient_set (const char *keylist, buf[i] = 0; if (*buf) { - if (i>1 && buf[i-1] == '!') + if (i>1 && buf[i-1] == '!') { /* The user selected to override the validity of that key. */ buf[i-1] = 0; - + err = gpgme_get_key (context, buf, &key, 0); if (! err) key->uids->validity = GPGME_VALIDITY_FULL; @@ -692,7 +692,7 @@ static gpgme_key_t *create_recipient_set (const char *keylist, /* NULL terminate. */ safe_realloc (&rset, sizeof (*rset) * (rset_n + 1)); rset[rset_n++] = NULL; - + if (context) gpgme_release (context); @@ -784,7 +784,7 @@ static char *encrypt_gpgme_object (gpgme_data_t plaintext, gpgme_key_t *rset, char *outfile; ctx = create_gpgme_context (use_smime); - if (!use_smime) + if (!use_smime) gpgme_set_armor (ctx, 1); ciphertext = create_gpgme_data (); @@ -880,7 +880,7 @@ static void print_time(time_t t, STATE *s) state_puts (p, s); } -/* +/* * Implementation of `sign_message'. */ @@ -988,7 +988,7 @@ static BODY *sign_message (BODY *a, int use_smime) { t->subtype = safe_strdup ("pkcs7-signature"); mutt_set_parameter ("name", "smime.p7s", &t->parameter); - t->encoding = ENCBASE64; + t->encoding = ENCBASE64; t->use_disp = 1; t->disposition = DISPATTACH; t->d_filename = safe_strdup ("smime.p7s"); @@ -1030,11 +1030,11 @@ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign) BODY *t; gpgme_key_t *rset = NULL; gpgme_data_t plaintext; - + rset = create_recipient_set (keylist, GPGME_PROTOCOL_OpenPGP); if (!rset) return NULL; - + if (sign) convert_to_7bit (a); plaintext = body_to_data_object (a, 0); @@ -1043,7 +1043,7 @@ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign) free_recipient_set (&rset); return NULL; } - + outfile = encrypt_gpgme_object (plaintext, rset, 0, sign); gpgme_data_release (plaintext); free_recipient_set (&rset); @@ -1059,7 +1059,7 @@ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign) mutt_generate_boundary(&t->parameter); mutt_set_parameter("protocol", "application/pgp-encrypted", &t->parameter); - + t->parts = mutt_new_body (); t->parts->type = TYPEAPPLICATION; t->parts->subtype = safe_strdup ("pgp-encrypted"); @@ -1110,7 +1110,7 @@ BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist) outfile = encrypt_gpgme_object (plaintext, rset, 1, 0); gpgme_data_release (plaintext); free_recipient_set (&rset); - if (!outfile) + if (!outfile) return NULL; t = mutt_new_body (); @@ -1126,12 +1126,12 @@ BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist) t->unlink = 1; /*delete after sending the message */ t->parts=0; t->next=0; - + return t; } -/* +/* * Implementation of `verify_one'. */ @@ -1170,13 +1170,13 @@ static int show_sig_summary (unsigned long sum, gpgme_verify_result_t result; gpgme_signature_t sig; unsigned int i; - + result = gpgme_op_verify_result (ctx); for (sig = result->signatures, i = 0; sig && (i < idx); sig = sig->next, i++) ; - + state_puts (_("Warning: The signature expired at: "), s); print_time (sig ? sig->exp_timestamp : 0, s); state_puts ("\n", s); @@ -1412,7 +1412,7 @@ static void print_smime_keyinfo (const char* msg, gpgme_signature_t sig, /* Show information about one signature. This function is called with the context CTX of a successful verification operation and the enumerator IDX which should start at 0 and increment for each - call/signature. + call/signature. Return values are: 0 for normal procession, 1 for a bad signature, 2 for a signature with a warning or -1 for no more signature. */ @@ -1445,7 +1445,7 @@ static int show_one_sig_status (gpgme_ctx_t ctx, int idx, STATE *s) gpgme_key_unref (signature_key); signature_key = NULL; } - + fpr = sig->fpr; sum = sig->summary; @@ -1549,7 +1549,7 @@ static int verify_one (BODY *sigbdy, STATE *s, gpgme_data_set_encoding (signature, GPGME_DATA_ENCODING_BASE64); err = gpgme_data_new_from_file (&message, tempfile, 1); - if (err) + if (err) { gpgme_data_release (signature); mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err)); @@ -1570,8 +1570,8 @@ static int verify_one (BODY *sigbdy, STATE *s, if (err) { char buf[200]; - - snprintf (buf, sizeof(buf)-1, + + snprintf (buf, sizeof(buf)-1, _("Error: verification failed: %s\n"), gpgme_strerror (err)); state_puts (buf, s); @@ -1655,10 +1655,10 @@ static int verify_one (BODY *sigbdy, STATE *s, } gpgme_release (ctx); - + state_attach_puts (_("[-- End signature information --]\n\n"), s); dprint (1, (debugfile, "verify_one: returning %d.\n", badsig)); - + return badsig? 1: anywarn? 2 : 0; } @@ -1752,8 +1752,8 @@ restart: if ((s->flags & MUTT_DISPLAY)) { char buf[200]; - - snprintf (buf, sizeof(buf)-1, + + snprintf (buf, sizeof(buf)-1, _("[-- Error: decryption failed: %s --]\n\n"), gpgme_strerror (err)); state_attach_puts (buf, s); @@ -1779,7 +1779,7 @@ restart: { int res, idx; int anybad = 0; - + if (maybe_signed) a->is_signed_data = 1; if(r_is_signed) @@ -1797,7 +1797,7 @@ restart: } if (!anybad && idx && r_is_signed && *r_is_signed) *r_is_signed = anywarn? 2:1; /* Good signature. */ - + if ((s->flags & MUTT_DISPLAY)) state_attach_puts (_("[-- End signature " "information --]\n\n"), s); @@ -1814,7 +1814,7 @@ restart: */ fstat (fileno (fpout), &info); tattach->length = info.st_size - tattach->offset; - + tattach->warnsig = anywarn; /* See if we need to recurse on this MIME part. */ @@ -1838,7 +1838,7 @@ int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) size_t saved_length; FILE *decoded_fp = NULL; int rv = 0; - + first_part->goodsig = 0; first_part->warnsig = 0; @@ -1851,7 +1851,7 @@ int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) } else return -1; - + memset (&s, 0, sizeof (s)); s.fpin = fpin; @@ -1927,7 +1927,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) if (b->parts) return -1; - + /* Decode the body - we need to pass binary CMS to the backend. The backend allows for Base64 encoded data but it does not allow for QP which I have seen in some messages. So better @@ -1937,7 +1937,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) saved_b_length = b->length; memset (&s, 0, sizeof (s)); s.fpin = fpin; - fseeko (s.fpin, b->offset, 0); + fseeko (s.fpin, b->offset, 0); mutt_mktemp (tempfile, sizeof (tempfile)); if (!(tmpfp = safe_fopen (tempfile, "w+"))) { @@ -1991,7 +1991,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) saved_b_length = bb->length; memset (&s, 0, sizeof (s)); s.fpin = *fpout; - fseeko (s.fpin, bb->offset, 0); + fseeko (s.fpin, bb->offset, 0); mutt_mktemp (tempfile, sizeof (tempfile)); if (!(tmpfp = safe_fopen (tempfile, "w+"))) { @@ -2006,7 +2006,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) bb->length = ftello (s.fpout); bb->offset = 0; rewind (tmpfp); - safe_fclose (fpout); + safe_fclose (fpout); memset (&s, 0, sizeof (s)); s.fpin = tmpfp; @@ -2057,7 +2057,7 @@ static int pgp_gpgme_extract_keys (gpgme_data_t keydata, FILE** fp, int dryrun) dprint (1, (debugfile, "Error creating GPGME context\n")); return rc; } - + if (dryrun) { snprintf (tmpdir, sizeof(tmpdir), "%s/mutt-gpgme-XXXXXX", Tempdir); @@ -2124,7 +2124,7 @@ static int pgp_gpgme_extract_keys (gpgme_data_t keydata, FILE** fp, int dryrun) else fprintf (*fp, "%s %5.5s %d/%8s %s\n", more ? "sub" : "pub", gpgme_pubkey_algo_name (subkey->pubkey_algo), subkey->length, - shortid, date); + shortid, date); subkey = subkey->next; more = 1; } @@ -2173,7 +2173,7 @@ static int line_compare(const char *a, size_t n, const char *b) #define PUBLIC_KEY_BLOCK(_y) _LINE_COMPARE("PUBLIC KEY BLOCK-----", _y) #define BEGIN_PGP_SIGNATURE(_y) _LINE_COMPARE("-----BEGIN PGP SIGNATURE-----", _y) -/* +/* * Implementation of `pgp_check_traditional'. */ @@ -2182,10 +2182,10 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b) char tempfile[_POSIX_PATH_MAX]; char buf[HUGE_STRING]; FILE *tfp; - + short sgn = 0; short enc = 0; - + if (b->type != TYPETEXT) return 0; @@ -2195,13 +2195,13 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b) unlink (tempfile); return 0; } - + if ((tfp = fopen (tempfile, "r")) == NULL) { unlink (tempfile); return 0; } - + while (fgets (buf, sizeof (buf), tfp)) { if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15)) @@ -2225,11 +2225,11 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b) return 0; /* fix the content type */ - + mutt_set_parameter ("format", "fixed", &b->parameter); mutt_set_parameter ("x-action", enc ? "pgp-encrypted" : "pgp-signed", &b->parameter); - + return 1; } @@ -2286,18 +2286,18 @@ void pgp_gpgme_invoke_import (const char *fname) } -/* +/* * Implementation of `application_handler'. */ -/* +/* Copy a clearsigned message, and strip the signature and PGP's dash-escaping. - + XXX - charset handling: We assume that it is safe to do character set decoding first, dash decoding second here, while we do it the other way around in the main handler. - + (Note that we aren't worse than Outlook & Cie in this, and also note that we can successfully handle anything produced by any existing versions of mutt.) */ @@ -2321,7 +2321,7 @@ static void copy_clearsigned (gpgme_data_t data, STATE *s, char *charset) * charset-hooks. Therefore we set flags to MUTT_ICONV_HOOK_FROM. */ fc = fgetconv_open (fp, charset, Charset, MUTT_ICONV_HOOK_FROM); - + for (complete = 1, armor_header = 1; fgetconvs (buf, sizeof (buf), fc) != NULL; complete = strchr (buf, '\n') != NULL) @@ -2335,23 +2335,23 @@ static void copy_clearsigned (gpgme_data_t data, STATE *s, char *charset) if (BEGIN_PGP_SIGNATURE(buf)) break; - + if (armor_header) { - if (buf[0] == '\n') + if (buf[0] == '\n') armor_header = 0; continue; } - - if (s->prefix) + + if (s->prefix) state_puts (s->prefix, s); - + if (buf[0] == '-' && buf[1] == ' ') state_puts (buf + 2, s); else state_puts (buf, s); } - + fgetconv_close (&fc); safe_fclose (&fp); } @@ -2384,20 +2384,20 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) fseeko (s->fpin, m->offset, 0); last_pos = m->offset; - + for (bytes = m->length; bytes > 0;) { if (fgets (buf, sizeof (buf), s->fpin) == NULL) break; - + offset = ftello (s->fpin); bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */ last_pos = offset; - + if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15)) { clearsign = 0; - + if (MESSAGE(buf + 15)) needpass = 1; else if (SIGNED_MESSAGE(buf + 15)) @@ -2409,7 +2409,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) { needpass = 0; pgp_keyblock = 1; - } + } else { /* XXX - we may wish to recode here */ @@ -2418,10 +2418,10 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) state_puts (buf, s); continue; } - + have_any_sigs = (have_any_sigs || (clearsign && (s->flags & MUTT_VERIFY))); - + /* Copy PGP material to an data container */ armored_data = file_to_data_object (s->fpin, m->offset, m->length); /* Invoke PGP if needed */ @@ -2461,8 +2461,8 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) if (err) { char errbuf[200]; - - snprintf (errbuf, sizeof(errbuf)-1, + + snprintf (errbuf, sizeof(errbuf)-1, _("Error: decryption/verification failed: %s\n"), gpgme_strerror (err)); state_puts (errbuf, s); @@ -2499,7 +2499,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) } if (!anybad && idx) maybe_goodsig = 1; - + state_attach_puts (_("[-- End signature " "information --]\n\n"), s); } @@ -2519,13 +2519,13 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) gpgme_data_release (plaintext); gpgme_release (ctx); } - + /* * Now, copy cleartext to the screen. NOTE - we expect that PGP - * outputs utf-8 cleartext. This may not always be true, but it + * outputs utf-8 cleartext. This may not always be true, but it * seems to be a reasonable guess. */ - + if(s->flags & MUTT_DISPLAY) { if (needpass) @@ -2537,7 +2537,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s); } - + if (clearsign) { copy_clearsigned (armored_data, s, body_charset); @@ -2556,7 +2556,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) } fgetconv_close (&fc); } - + if (s->flags & MUTT_DISPLAY) { state_putc ('\n', s); @@ -2567,7 +2567,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) else state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s); } - + gpgme_data_release (armored_data); if (pgpout) { @@ -2585,7 +2585,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) } m->goodsig = (maybe_goodsig && have_any_sigs); - + if (needpass == -1) { state_attach_puts (_("[-- Error: could not find beginning" @@ -2597,7 +2597,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) return err; } -/* +/* * Implementation of `encrypted_handler'. */ @@ -2612,7 +2612,7 @@ int pgp_gpgme_encrypted_handler (BODY *a, STATE *s) BODY *tattach; int is_signed; int rc = 0; - + dprint (2, (debugfile, "Entering pgp_encrypted handler\n")); mutt_mktemp (tempfile, sizeof (tempfile)); @@ -2634,7 +2634,7 @@ int pgp_gpgme_encrypted_handler (BODY *a, STATE *s) _("[-- The following data is PGP/MIME signed and encrypted --]\n\n"): _("[-- The following data is PGP/MIME encrypted --]\n\n"), s); - + { FILE *savefp = s->fpin; s->fpin = fpout; @@ -2642,14 +2642,14 @@ int pgp_gpgme_encrypted_handler (BODY *a, STATE *s) s->fpin = savefp; } - /* + /* * if a multipart/signed is the _only_ sub-part of a * multipart/encrypted, cache signature verification * status. */ if (mutt_is_multipart_signed (tattach) && !tattach->next) a->goodsig |= tattach->goodsig; - + if (s->flags & MUTT_DISPLAY) { state_puts ("\n", s); @@ -2686,7 +2686,7 @@ int smime_gpgme_application_handler (BODY *a, STATE *s) int rc = 0; dprint (2, (debugfile, "Entering smime_encrypted handler\n")); - + a->warnsig = 0; mutt_mktemp (tempfile, sizeof (tempfile)); if (!(fpout = safe_fopen (tempfile, "w+"))) @@ -2707,7 +2707,7 @@ int smime_gpgme_application_handler (BODY *a, STATE *s) _("[-- The following data is S/MIME signed --]\n\n"): _("[-- The following data is S/MIME encrypted --]\n\n"), s); - + { FILE *savefp = s->fpin; s->fpin = fpout; @@ -2715,7 +2715,7 @@ int smime_gpgme_application_handler (BODY *a, STATE *s) s->fpin = savefp; } - /* + /* * if a multipart/signed is the _only_ sub-part of a * multipart/encrypted, cache signature verification * status. @@ -2742,18 +2742,18 @@ int smime_gpgme_application_handler (BODY *a, STATE *s) mutt_free_body (&tattach); } - + safe_fclose (&fpout); mutt_unlink(tempfile); dprint (2, (debugfile, "Leaving smime_encrypted handler\n")); - + return rc; } /* * Format an entry on the CRYPT key selection menu. - * + * * %n number * %k key id %K key id of the principal key * %u user id @@ -2794,7 +2794,7 @@ static const char *crypt_entry_fmt (char *dest, kflags = (key->flags /*| (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags*/); - + switch (ascii_tolower (op)) { case '[': @@ -2971,17 +2971,17 @@ static const char *crypt_entry_fmt (char *dest, mutt_FormatString (dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0); return (src); } - + /* Used by the display function to format a line. */ static void crypt_entry (char *s, size_t l, MUTTMENU * menu, int num) { crypt_key_t **key_table = (crypt_key_t **) menu->data; crypt_entry_t entry; - + entry.key = key_table[num]; entry.num = num + 1; - mutt_FormatString (s, l, 0, MuttIndexWindow->cols, NONULL (PgpEntryFormat), crypt_entry_fmt, + mutt_FormatString (s, l, 0, MuttIndexWindow->cols, NONULL (PgpEntryFormat), crypt_entry_fmt, (unsigned long) &entry, MUTT_FORMAT_ARROWCURSOR); } @@ -3120,10 +3120,10 @@ static void print_dn_parts (FILE *fp, struct dn_array_s *dn) { static const char * const stdpart[] = { - "CN", "OU", "O", "STREET", "L", "ST", "C", NULL + "CN", "OU", "O", "STREET", "L", "ST", "C", NULL }; int any=0, any2=0, i; - + for (i=0; stdpart[i]; i++) { if (any) @@ -3198,7 +3198,7 @@ parse_dn_part (struct dn_array_s *array, const unsigned char *string) { /* pair */ s++; if (*s == ',' || *s == '=' || *s == '+' - || *s == '<' || *s == '>' || *s == '#' || *s == ';' + || *s == '<' || *s == '>' || *s == '#' || *s == ';' || *s == '\\' || *s == '\"' || *s == ' ') n++; else if (hexdigitp (s) && hexdigitp (s+1)) @@ -3213,7 +3213,7 @@ parse_dn_part (struct dn_array_s *array, const unsigned char *string) return NULL; /* invalid encoding */ else if (*s == ',' || *s == '=' || *s == '+' || *s == '<' || *s == '>' || *s == '#' || *s == ';' ) - break; + break; else n++; } @@ -3223,7 +3223,7 @@ parse_dn_part (struct dn_array_s *array, const unsigned char *string) for (s=string; n; s++, n--) { if (*s == '\\') - { + { s++; if (hexdigitp (s)) { @@ -3328,9 +3328,9 @@ parse_and_print_user_id (FILE *fp, const char *userid) struct dn_array_s *dn = parse_dn ((const unsigned char *)userid); if (!dn) fputs (_("[Can't display this user ID (invalid DN)]"), fp); - else + else { - print_dn_parts (fp, dn); + print_dn_parts (fp, dn); for (i=0; dn[i].key; i++) { FREE (&dn[i].key); @@ -3700,7 +3700,7 @@ static void print_key_info (gpgme_key_t key, FILE *fp) /* Show detailed information about the selected key */ -static void +static void verify_key (crypt_key_t *key) { FILE *fp; @@ -3748,7 +3748,7 @@ verify_key (crypt_key_t *key) goto leave; } gpgme_op_keylist_end (listctx); - + print_key_info (k, fp); if (!--maxdepth) { @@ -3768,7 +3768,7 @@ verify_key (crypt_key_t *key) mutt_do_pager (cmd, tempfile, 0, NULL); } -/* +/* * Implementation of `findkeys'. */ @@ -3843,9 +3843,9 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) pattern = list_to_pattern (hints); if (!pattern) return NULL; - + err = gpgme_new (&ctx); - if (err) + if (err) { mutt_error (_("gpgme_new failed: %s"), gpgme_strerror (err)); FREE (&pattern); @@ -3854,7 +3854,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) db = NULL; kend = &db; - + if ((app & APPLICATION_PGP)) { /* Its all a mess. That old GPGME expects different things @@ -3884,7 +3884,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) for (n=0; patarr[n]; n++) FREE (&patarr[n]); FREE (&patarr); - if (err) + if (err) { mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err)); @@ -3896,7 +3896,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) while (!(err = gpgme_op_keylist_next (ctx, &key)) ) { unsigned int flags = 0; - + if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT)) flags |= KEYFLAG_CANENCRYPT; if (key_check_cap (key, KEY_CAP_CAN_SIGN)) @@ -3959,7 +3959,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) /* and now look for x509 certificates */ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); err = gpgme_op_keylist_start (ctx, pattern, 0); - if (err) + if (err) { mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err)); @@ -3976,7 +3976,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) flags |= KEYFLAG_CANENCRYPT; if (key_check_cap (key, KEY_CAP_CAN_SIGN)) flags |= KEYFLAG_CANSIGN; - + for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) { k = safe_calloc (1, sizeof *k); @@ -4017,7 +4017,7 @@ static LIST *crypt_add_string_to_hints (LIST *hints, const char *str) if (strlen (t) > 3) hints = mutt_add_list (hints, t); } - + FREE (&scratch); return hints; } @@ -4026,7 +4026,7 @@ static LIST *crypt_add_string_to_hints (LIST *hints, const char *str) will be set to true on return if the user did override the the key's validity. */ static crypt_key_t *crypt_select_key (crypt_key_t *keys, - ADDRESS * p, const char *s, + ADDRESS * p, const char *s, unsigned int app, int *forced_valid) { int keymax; @@ -4051,13 +4051,13 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, unusable = 1; continue; } - + if (i == keymax) { keymax += 20; safe_realloc (&key_table, sizeof (crypt_key_t*)*keymax); } - + key_table[i++] = k; } @@ -4132,7 +4132,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, /* L10N: e.g. 'S/MIME keys matching "Michael Elkins".' */ snprintf (buf, sizeof (buf), _("%s \"%s\"."), ts, s); - menu->title = buf; + menu->title = buf; } mutt_clear_error (); @@ -4146,11 +4146,11 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, verify_key (key_table[menu->current]); menu->redraw = REDRAW_FULL; break; - + case OP_VIEW_ID: mutt_message ("%s", key_table[menu->current]->uid); break; - + case OP_GENERIC_SELECT_ENTRY: /* FIXME make error reporting more verbose - this should be easy because gpgme provides more information */ @@ -4163,33 +4163,33 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, break; } } - + if (option (OPTPGPCHECKTRUST) && (!crypt_id_is_valid (key_table[menu->current]) || !crypt_id_is_strong (key_table[menu->current]))) { const char *warn_s; char buff[LONG_STRING]; - + if (key_table[menu->current]->flags & KEYFLAG_CANTUSE) warn_s = N_("ID is expired/disabled/revoked."); - else + else { warn_s = "??"; switch (key_table[menu->current]->validity) { - case GPGME_VALIDITY_UNKNOWN: - case GPGME_VALIDITY_UNDEFINED: + case GPGME_VALIDITY_UNKNOWN: + case GPGME_VALIDITY_UNDEFINED: warn_s = N_("ID has undefined validity."); break; - case GPGME_VALIDITY_NEVER: + case GPGME_VALIDITY_NEVER: warn_s = N_("ID is not valid."); break; - case GPGME_VALIDITY_MARGINAL: + case GPGME_VALIDITY_MARGINAL: warn_s = N_("ID is only marginally valid."); break; - case GPGME_VALIDITY_FULL: - case GPGME_VALIDITY_ULTIMATE: + case GPGME_VALIDITY_FULL: + case GPGME_VALIDITY_ULTIMATE: break; } } @@ -4197,30 +4197,30 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, snprintf (buff, sizeof (buff), _("%s Do you really want to use the key?"), _(warn_s)); - + if (mutt_yesorno (buff, 0) != 1) { mutt_clear_error (); break; } *forced_valid = 1; - } + } k = crypt_copy_key (key_table[menu->current]); done = 1; break; - + case OP_EXIT: k = NULL; done = 1; break; } } - + mutt_pop_current_menu (menu); mutt_menuDestroy (&menu); FREE (&key_table); - + return k; } @@ -4241,7 +4241,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, crypt_key_t *a_valid_addrmatch_key = NULL; crypt_key_t *matches = NULL; crypt_key_t **matches_endp = &matches; - + *forced_valid = 0; if (a && a->mailbox) @@ -4254,10 +4254,10 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, keys = get_candidates (hints, app, (abilities & KEYFLAG_CANSIGN) ); mutt_free_list (&hints); - + if (!keys) return NULL; - + dprint (5, (debugfile, "crypt_getkeybyaddr: looking for %s <%s>.", a->personal, a->mailbox)); @@ -4265,7 +4265,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, { dprint (5, (debugfile, " looking at key: %s `%.15s'\n", crypt_keyid (k), k->uid)); - + if (abilities && !(k->flags & abilities)) { dprint (5, (debugfile, " insufficient abilities: Has %x, want %x\n", @@ -4281,7 +4281,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, for (p = r; p; p = p->next) { int validity = crypt_id_matches_addr (a, p, k); - + if (validity & CRYPT_KV_MATCH) /* something matches */ { match = 1; @@ -4302,7 +4302,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, } } rfc822_free_address (&r); - + if (match) { crypt_key_t *tmp; @@ -4316,9 +4316,9 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, a_valid_addrmatch_key = tmp; } } - + crypt_free_key (&keys); - + if (matches) { if (oppenc_mode) @@ -4331,17 +4331,17 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, k = NULL; } else if (the_strong_valid_key && !multi) - { - /* + { + /* * There was precisely one strong match on a valid ID. - * + * * Proceed without asking the user. */ k = crypt_copy_key (the_strong_valid_key); } - else + else { - /* + /* * Else: Ask the user. */ k = crypt_select_key (matches, a, NULL, app, forced_valid); @@ -4349,9 +4349,9 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, crypt_free_key (&matches); } - else + else k = NULL; - + return k; } @@ -4403,17 +4403,17 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities, matches_endp = &tmp->next; } } - + FREE (&pfcopy); crypt_free_key (&keys); - + if (matches) { k = crypt_select_key (matches, NULL, p, app, forced_valid); crypt_free_key (&matches); return k; } - + return NULL; } @@ -4422,8 +4422,8 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities, default. ABILITIES describe the required key abilities (sign, encrypt) and APP the type of the requested key; ether S/MIME or PGP. Return a copy of the key or NULL if not found. */ -static crypt_key_t *crypt_ask_for_key (char *tag, - char *whatfor, +static crypt_key_t *crypt_ask_for_key (char *tag, + char *whatfor, short abilities, unsigned int app, int *forced_valid) @@ -4442,7 +4442,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag, resp[0] = 0; if (whatfor) { - + for (l = id_defaults; l; l = l->next) if (!mutt_strcasecmp (whatfor, l->what)) { @@ -4457,7 +4457,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag, resp[0] = 0; if (mutt_get_field (tag, resp, sizeof (resp), MUTT_CLEAR) != 0) return NULL; - + if (whatfor) { if (l) @@ -4471,10 +4471,10 @@ static crypt_key_t *crypt_ask_for_key (char *tag, l->dflt = safe_strdup (resp); } } - + if ((key = crypt_getkeybystr (resp, abilities, app, forced_valid))) return key; - + BEEP (); } /* not reached */ @@ -4536,7 +4536,7 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) } /* check for e-mail address */ - if ((t = strchr (crypt_hook_val, '@')) && + if ((t = strchr (crypt_hook_val, '@')) && (addr = rfc822_parse_adrlist (NULL, crypt_hook_val))) { if (fqdn) @@ -4545,11 +4545,11 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) } else if (! oppenc_mode) { -#if 0 - k_info = crypt_getkeybystr (crypt_hook_val, KEYFLAG_CANENCRYPT, +#if 0 + k_info = crypt_getkeybystr (crypt_hook_val, KEYFLAG_CANENCRYPT, *r_application, &forced_valid); #else - k_info = crypt_getkeybystr (crypt_hook_val, KEYFLAG_CANENCRYPT, + k_info = crypt_getkeybystr (crypt_hook_val, KEYFLAG_CANENCRYPT, app, &forced_valid); #endif } @@ -4580,7 +4580,7 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) if ((k_info == NULL) && (! oppenc_mode)) { snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox); - + k_info = crypt_ask_for_key (buf, q->mailbox, KEYFLAG_CANENCRYPT, #if 0 @@ -4608,7 +4608,7 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) if (!(k_info->flags & KEYFLAG_ISX509)) *r_application &= ~APPLICATION_SMIME; #endif - + bypass_selection: keylist_size += mutt_strlen (keyID) + 4 + 1; safe_realloc (&keylist, keylist_size); diff --git a/crypt-gpgme.h b/crypt-gpgme.h index bb283a50..a2e06b86 100644 --- a/crypt-gpgme.h +++ b/crypt-gpgme.h @@ -1,16 +1,16 @@ -/* +/* * Copyright (C) 2004 g10 Code GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/crypt-mod-pgp-classic.c b/crypt-mod-pgp-classic.c index 37dd1771..b0534afe 100644 --- a/crypt-mod-pgp-classic.c +++ b/crypt-mod-pgp-classic.c @@ -1,22 +1,22 @@ -/* +/* * Copyright (C) 2004 g10 Code GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* +/* This is a crytpo module wrapping the classic pgp code. */ diff --git a/crypt-mod-pgp-gpgme.c b/crypt-mod-pgp-gpgme.c index b56fcdba..5521db97 100644 --- a/crypt-mod-pgp-gpgme.c +++ b/crypt-mod-pgp-gpgme.c @@ -1,22 +1,22 @@ -/* +/* * Copyright (C) 2004 g10 Code GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* +/* This is a crytpo module wrapping the gpgme based pgp code. */ diff --git a/crypt-mod-smime-classic.c b/crypt-mod-smime-classic.c index b671b926..99952d40 100644 --- a/crypt-mod-smime-classic.c +++ b/crypt-mod-smime-classic.c @@ -1,22 +1,22 @@ -/* +/* * Copyright (C) 2004 g10 Code GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* +/* This is a crytpo module wrapping the classic smime code. */ @@ -109,7 +109,7 @@ struct crypt_module_specs crypt_mod_smime_classic = NULL, /* pgp_invoke_getkeys */ NULL, /* pgp_invoke_import */ NULL, /* pgp_extract_keys_from_attachment_list */ - + crypt_mod_smime_getkeys, crypt_mod_smime_verify_sender, crypt_mod_smime_build_smime_entity, diff --git a/crypt-mod-smime-gpgme.c b/crypt-mod-smime-gpgme.c index a3063632..e8fda3e7 100644 --- a/crypt-mod-smime-gpgme.c +++ b/crypt-mod-smime-gpgme.c @@ -1,22 +1,22 @@ -/* +/* * Copyright (C) 2004 g10 Code GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* +/* This is a crytpo module wrapping the gpgme based smime code. */ @@ -107,7 +107,7 @@ struct crypt_module_specs crypt_mod_smime_gpgme = NULL, /* pgp_invoke_getkeys */ NULL, /* pgp_invoke_import */ NULL, /* pgp_extract_keys_from_attachment_list */ - + NULL, /* smime_getkeys */ crypt_mod_smime_verify_sender, crypt_mod_smime_build_smime_entity, diff --git a/crypt-mod.c b/crypt-mod.c index 0000356c..644cd3df 100644 --- a/crypt-mod.c +++ b/crypt-mod.c @@ -5,12 +5,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/crypt-mod.h b/crypt-mod.h index 2b8ba4b8..08934a63 100644 --- a/crypt-mod.h +++ b/crypt-mod.h @@ -5,12 +5,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -25,7 +25,7 @@ #define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_ ## identifier) -/* +/* Type definitions for crypto module functions. */ typedef void (*crypt_func_void_passphrase_t) (void); @@ -50,7 +50,7 @@ typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist, typedef void (*crypt_func_pgp_invoke_import_t) (const char *fname); typedef int (*crypt_func_verify_one_t) (BODY *sigbdy, STATE *s, const char *tempf); -typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t) +typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t) (FILE *fp, int tag, BODY *top); typedef int (*crypt_func_send_menu_t) (HEADER *msg); @@ -106,7 +106,7 @@ typedef struct crypt_module_functions /* - A structure to describe a crypto module. + A structure to describe a crypto module. */ typedef struct crypt_module_specs { @@ -116,8 +116,8 @@ typedef struct crypt_module_specs -/* - High Level crypto module interface. +/* + High Level crypto module interface. */ void crypto_module_register (crypt_module_specs_t specs); diff --git a/crypt.c b/crypt.c index 11a668b4..d5899075 100644 --- a/crypt.c +++ b/crypt.c @@ -10,12 +10,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -276,7 +276,7 @@ int mutt_protect (HEADER *msg, char *keylist) return (-1); } - /* destroy temporary signature envelope when doing retainable + /* destroy temporary signature envelope when doing retainable * signatures. */ @@ -295,8 +295,8 @@ int mutt_protect (HEADER *msg, char *keylist) } - - + + int mutt_is_multipart_signed (BODY *b) { char *p; @@ -314,7 +314,7 @@ int mutt_is_multipart_signed (BODY *b) if ((WithCrypto & APPLICATION_PGP) && !(ascii_strcasecmp (p, "application/pgp-signature"))) return PGPSIGN; - + if ((WithCrypto & APPLICATION_SMIME) && !(ascii_strcasecmp (p, "application/x-pkcs7-signature"))) return SMIMESIGN; @@ -324,20 +324,20 @@ int mutt_is_multipart_signed (BODY *b) return 0; } - - + + int mutt_is_multipart_encrypted (BODY *b) { if ((WithCrypto & APPLICATION_PGP)) { char *p; - + if (!b || b->type != TYPEMULTIPART || !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") || !(p = mutt_get_parameter ("protocol", b->parameter)) || ascii_strcasecmp (p, "application/pgp-encrypted")) return 0; - + return PGPENCRYPT; } @@ -410,7 +410,7 @@ int mutt_is_application_pgp (BODY *m) { int t = 0; char *p; - + if (m->type == TYPEAPPLICATION) { if (!ascii_strcasecmp (m->subtype, "pgp") || !ascii_strcasecmp (m->subtype, "x-pgp-message")) @@ -419,7 +419,7 @@ int mutt_is_application_pgp (BODY *m) && (!ascii_strcasecmp (p, "sign") || !ascii_strcasecmp (p, "signclear"))) t |= PGPSIGN; - if ((p = mutt_get_parameter ("format", m->parameter)) && + if ((p = mutt_get_parameter ("format", m->parameter)) && !ascii_strcasecmp (p, "keys-only")) t |= PGPKEY; @@ -435,7 +435,7 @@ int mutt_is_application_pgp (BODY *m) else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0) { if (((p = mutt_get_parameter ("x-mutt-action", m->parameter)) - || (p = mutt_get_parameter ("x-action", m->parameter)) + || (p = mutt_get_parameter ("x-action", m->parameter)) || (p = mutt_get_parameter ("action", m->parameter))) && !ascii_strncasecmp ("pgp-sign", p, 8)) t |= PGPSIGN; @@ -472,7 +472,7 @@ int mutt_is_application_smime (BODY *m) return (SMIMESIGN|SMIMEOPAQUE); else return 0; } - /* Netscape 4.7 uses + /* Netscape 4.7 uses * Content-Description: S/MIME Encrypted Message * instead of Content-Type parameter */ @@ -487,7 +487,7 @@ int mutt_is_application_smime (BODY *m) if (!t) t = m->d_filename; if (!t) t = m->filename; - if (!t) + if (!t) { if (complain) mutt_message (_("S/MIME messages with no hints on content are unsupported.")); @@ -504,7 +504,7 @@ int mutt_is_application_smime (BODY *m) #if 0 return SMIMEENCRYPT; #else - /* Not sure if this is the correct thing to do, but + /* Not sure if this is the correct thing to do, but it's required for compatibility with Outlook */ return (SMIMESIGN|SMIMEOPAQUE); #endif @@ -527,7 +527,7 @@ int crypt_query (BODY *m) if (!WithCrypto) return 0; - + if (!m) return 0; @@ -549,14 +549,14 @@ int crypt_query (BODY *m) if (t && m->goodsig) t |= GOODSIGN; } - + if (m->type == TYPEMULTIPART) { t |= mutt_is_multipart_encrypted(m); t |= mutt_is_multipart_signed (m); t |= mutt_is_malformed_multipart_pgp_encrypted (m); - if (t && m->goodsig) + if (t && m->goodsig) t |= GOODSIGN; } @@ -564,17 +564,17 @@ int crypt_query (BODY *m) { BODY *p; int u, v, w; - + u = m->parts ? 0xffffffff : 0; /* Bits set in all parts */ w = 0; /* Bits set in any part */ - + for (p = m->parts; p; p = p->next) { v = crypt_query (p); u &= v; w |= v; } t |= u | (w & ~GOODSIGN); - + if ((w & GOODSIGN) && !(u & GOODSIGN)) t |= PARTSIGN; } @@ -600,7 +600,7 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempfile) mutt_perror (tempfile); return -1; } - + fseeko (s->fpin, a->hdr_offset, 0); bytes = a->length + a->offset - a->hdr_offset; hadcr = 0; @@ -608,21 +608,21 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempfile) { if ((c = fgetc (s->fpin)) == EOF) break; - + bytes--; - + if (c == '\r') hadcr = 1; - else + else { if (c == '\n' && !hadcr) fputc ('\r', fp); - + hadcr = 0; } - + fputc (c, fp); - + } safe_fclose (&fp); @@ -647,7 +647,7 @@ void convert_to_7bit (BODY *a) } else if ((WithCrypto & APPLICATION_PGP) && option (OPTPGPSTRICTENC)) convert_to_7bit (a->parts); - } + } else if (a->type == TYPEMESSAGE && ascii_strcasecmp(a->subtype, "delivery-status")) { @@ -659,7 +659,7 @@ void convert_to_7bit (BODY *a) else if (a->encoding == ENCBINARY) a->encoding = ENCBASE64; else if (a->content && a->encoding != ENCBASE64 && - (a->content->from || (a->content->space && + (a->content->from || (a->content->space && option (OPTPGPSTRICTENC)))) a->encoding = ENCQUOTEDPRINTABLE; a = a->next; @@ -706,10 +706,10 @@ void crypt_extract_keys_from_messages (HEADER * h) if ((WithCrypto & APPLICATION_PGP) && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP)) { - mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], + mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], MUTT_CM_DECODE|MUTT_CM_CHARCONV, 0); fflush(fpout); - + mutt_endwin (_("Trying to extract PGP keys...\n")); crypt_pgp_invoke_import (tempfname); } @@ -770,7 +770,7 @@ void crypt_extract_keys_from_messages (HEADER * h) fflush(fpout); if (h->env->from) tmp = mutt_expand_aliases (h->env->from); - else if (h->env->sender) tmp = mutt_expand_aliases (h->env->sender); + else if (h->env->sender) tmp = mutt_expand_aliases (h->env->sender); mbox = tmp ? tmp->mailbox : NULL; if (mbox) /* else ? */ { @@ -780,7 +780,7 @@ void crypt_extract_keys_from_messages (HEADER * h) } } } - + safe_fclose (&fpout); if (isendwin()) mutt_any_key_to_continue (NULL); @@ -855,7 +855,7 @@ int crypt_get_keys (HEADER *msg, char **keylist, int oppenc_mode) } rfc822_free_address (&adrlist); - + return (0); } @@ -918,7 +918,7 @@ int mutt_signed_handler (BODY *a, STATE *s) char tempfile[_POSIX_PATH_MAX]; int signed_type; int inconsistent = 0; - + BODY *b = a; BODY **signatures = NULL; int sigcnt = 0; @@ -977,9 +977,9 @@ int mutt_signed_handler (BODY *a, STATE *s) if (s->flags & MUTT_DISPLAY) { - + crypt_fetch_signatures (&signatures, a->next, &sigcnt); - + if (sigcnt) { mutt_mktemp (tempfile, sizeof (tempfile)); @@ -988,23 +988,23 @@ int mutt_signed_handler (BODY *a, STATE *s) for (i = 0; i < sigcnt; i++) { if ((WithCrypto & APPLICATION_PGP) - && signatures[i]->type == TYPEAPPLICATION + && signatures[i]->type == TYPEAPPLICATION && !ascii_strcasecmp (signatures[i]->subtype, "pgp-signature")) { if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; - + continue; } if ((WithCrypto & APPLICATION_SMIME) - && signatures[i]->type == TYPEAPPLICATION + && signatures[i]->type == TYPEAPPLICATION && (!ascii_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature") || !ascii_strcasecmp(signatures[i]->subtype, "pkcs7-signature"))) { if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; - + continue; } @@ -1013,12 +1013,12 @@ int mutt_signed_handler (BODY *a, STATE *s) TYPE(signatures[i]), signatures[i]->subtype); } } - + mutt_unlink (tempfile); b->goodsig = goodsig; b->badsig = !goodsig; - + /* Now display the signed body */ state_attach_puts (_("[-- The following data is signed --]\n\n"), s); @@ -1028,12 +1028,12 @@ int mutt_signed_handler (BODY *a, STATE *s) else state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s); } - + rc = mutt_body_handler (a, s); - + if (s->flags & MUTT_DISPLAY && sigcnt) state_attach_puts (_("\n[-- End of signed data --]\n"), s); - + return rc; } diff --git a/cryptglue.c b/cryptglue.c index 2379fe33..6d549f9f 100644 --- a/cryptglue.c +++ b/cryptglue.c @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -38,7 +38,7 @@ #include "crypt-mod.h" /* - + Generic */ @@ -130,7 +130,7 @@ int crypt_has_module_backend (int type) -/* +/* PGP @@ -167,7 +167,7 @@ int crypt_pgp_application_pgp_handler (BODY *m, STATE *s) { if (CRYPT_MOD_CALL_CHECK (PGP, application_handler)) return (CRYPT_MOD_CALL (PGP, application_handler)) (m, s); - + return -1; } @@ -176,7 +176,7 @@ int crypt_pgp_encrypted_handler (BODY *a, STATE *s) { if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler)) return (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s); - + return -1; } @@ -287,9 +287,9 @@ void crypt_pgp_set_sender (const char *sender) -/* +/* - S/MIME + S/MIME */ @@ -323,7 +323,7 @@ int crypt_smime_application_smime_handler (BODY *m, STATE *s) { if (CRYPT_MOD_CALL_CHECK (SMIME, application_handler)) return (CRYPT_MOD_CALL (SMIME, application_handler)) (m, s); - + return -1; } -- 2.11.0