* 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.
return 'd';
else if (flags & KEYFLAG_CRITICAL)
return 'c';
- else
+ else
return ' ';
}
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;
}
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));
FILE *fptmp;
int err = 0;
gpgme_data_t data;
-
+
mutt_mktemp (tempfile, sizeof (tempfile));
fptmp = safe_fopen (tempfile, "w+");
if (!fptmp)
{
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 */
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;
{
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;
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;
/* NULL terminate. */
safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
rset[rset_n++] = NULL;
-
+
if (context)
gpgme_release (context);
char *outfile;
ctx = create_gpgme_context (use_smime);
- if (!use_smime)
+ if (!use_smime)
gpgme_set_armor (ctx, 1);
ciphertext = create_gpgme_data ();
state_puts (p, s);
}
-/*
+/*
* Implementation of `sign_message'.
*/
{
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");
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);
free_recipient_set (&rset);
return NULL;
}
-
+
outfile = encrypt_gpgme_object (plaintext, rset, 0, sign);
gpgme_data_release (plaintext);
free_recipient_set (&rset);
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");
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 ();
t->unlink = 1; /*delete after sending the message */
t->parts=0;
t->next=0;
-
+
return t;
}
-/*
+/*
* Implementation of `verify_one'.
*/
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);
/* 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. */
gpgme_key_unref (signature_key);
signature_key = NULL;
}
-
+
fpr = sig->fpr;
sum = sig->summary;
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));
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);
}
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;
}
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);
{
int res, idx;
int anybad = 0;
-
+
if (maybe_signed)
a->is_signed_data = 1;
if(r_is_signed)
}
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);
*/
fstat (fileno (fpout), &info);
tattach->length = info.st_size - tattach->offset;
-
+
tattach->warnsig = anywarn;
/* See if we need to recurse on this MIME part. */
size_t saved_length;
FILE *decoded_fp = NULL;
int rv = 0;
-
+
first_part->goodsig = 0;
first_part->warnsig = 0;
}
else
return -1;
-
+
memset (&s, 0, sizeof (s));
s.fpin = fpin;
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
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+")))
{
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+")))
{
bb->length = ftello (s.fpout);
bb->offset = 0;
rewind (tmpfp);
- safe_fclose (fpout);
+ safe_fclose (fpout);
memset (&s, 0, sizeof (s));
s.fpin = tmpfp;
dprint (1, (debugfile, "Error creating GPGME context\n"));
return rc;
}
-
+
if (dryrun)
{
snprintf (tmpdir, sizeof(tmpdir), "%s/mutt-gpgme-XXXXXX", Tempdir);
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;
}
#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'.
*/
char tempfile[_POSIX_PATH_MAX];
char buf[HUGE_STRING];
FILE *tfp;
-
+
short sgn = 0;
short enc = 0;
-
+
if (b->type != TYPETEXT)
return 0;
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))
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;
}
}
-/*
+/*
* 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.) */
* 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)
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);
}
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))
{
needpass = 0;
pgp_keyblock = 1;
- }
+ }
else
{
/* XXX - we may wish to recode here */
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 */
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);
}
if (!anybad && idx)
maybe_goodsig = 1;
-
+
state_attach_puts (_("[-- End signature "
"information --]\n\n"), 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)
state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"),
s);
}
-
+
if (clearsign)
{
copy_clearsigned (armored_data, s, body_charset);
}
fgetconv_close (&fc);
}
-
+
if (s->flags & MUTT_DISPLAY)
{
state_putc ('\n', s);
else
state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
}
-
+
gpgme_data_release (armored_data);
if (pgpout)
{
}
m->goodsig = (maybe_goodsig && have_any_sigs);
-
+
if (needpass == -1)
{
state_attach_puts (_("[-- Error: could not find beginning"
return err;
}
-/*
+/*
* Implementation of `encrypted_handler'.
*/
BODY *tattach;
int is_signed;
int rc = 0;
-
+
dprint (2, (debugfile, "Entering pgp_encrypted handler\n"));
mutt_mktemp (tempfile, sizeof (tempfile));
_("[-- 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;
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);
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+")))
_("[-- 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;
s->fpin = savefp;
}
- /*
+ /*
* if a multipart/signed is the _only_ sub-part of a
* multipart/encrypted, cache signature verification
* status.
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
kflags = (key->flags /*| (pkey->flags & KEYFLAG_RESTRICTIONS)
| uid->flags*/);
-
+
switch (ascii_tolower (op))
{
case '[':
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);
}
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)
{ /* 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))
return NULL; /* invalid encoding */
else if (*s == ',' || *s == '=' || *s == '+'
|| *s == '<' || *s == '>' || *s == '#' || *s == ';' )
- break;
+ break;
else
n++;
}
for (s=string; n; s++, n--)
{
if (*s == '\\')
- {
+ {
s++;
if (hexdigitp (s))
{
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);
/* Show detailed information about the selected key */
-static void
+static void
verify_key (crypt_key_t *key)
{
FILE *fp;
goto leave;
}
gpgme_op_keylist_end (listctx);
-
+
print_key_info (k, fp);
if (!--maxdepth)
{
mutt_do_pager (cmd, tempfile, 0, NULL);
}
-/*
+/*
* Implementation of `findkeys'.
*/
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);
db = NULL;
kend = &db;
-
+
if ((app & APPLICATION_PGP))
{
/* Its all a mess. That old GPGME expects different things
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));
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))
/* 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));
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);
if (strlen (t) > 3)
hints = mutt_add_list (hints, t);
}
-
+
FREE (&scratch);
return hints;
}
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;
unusable = 1;
continue;
}
-
+
if (i == keymax)
{
keymax += 20;
safe_realloc (&key_table, sizeof (crypt_key_t*)*keymax);
}
-
+
key_table[i++] = k;
}
/* 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 ();
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 */
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;
}
}
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;
}
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)
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));
{
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",
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;
}
}
rfc822_free_address (&r);
-
+
if (match)
{
crypt_key_t *tmp;
a_valid_addrmatch_key = tmp;
}
}
-
+
crypt_free_key (&keys);
-
+
if (matches)
{
if (oppenc_mode)
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);
crypt_free_key (&matches);
}
- else
+ else
k = NULL;
-
+
return k;
}
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;
}
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)
resp[0] = 0;
if (whatfor)
{
-
+
for (l = id_defaults; l; l = l->next)
if (!mutt_strcasecmp (whatfor, l->what))
{
resp[0] = 0;
if (mutt_get_field (tag, resp, sizeof (resp), MUTT_CLEAR) != 0)
return NULL;
-
+
if (whatfor)
{
if (l)
l->dflt = safe_strdup (resp);
}
}
-
+
if ((key = crypt_getkeybystr (resp, abilities, app, forced_valid)))
return key;
-
+
BEEP ();
}
/* not reached */
}
/* 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)
}
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
}
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
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);
* 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.
return (-1);
}
- /* destroy temporary signature envelope when doing retainable
+ /* destroy temporary signature envelope when doing retainable
* signatures.
*/
}
-
-
+
+
int mutt_is_multipart_signed (BODY *b)
{
char *p;
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;
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;
}
{
int t = 0;
char *p;
-
+
if (m->type == TYPEAPPLICATION)
{
if (!ascii_strcasecmp (m->subtype, "pgp") || !ascii_strcasecmp (m->subtype, "x-pgp-message"))
&& (!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;
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;
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
*/
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."));
#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
if (!WithCrypto)
return 0;
-
+
if (!m)
return 0;
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;
}
{
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;
}
mutt_perror (tempfile);
return -1;
}
-
+
fseeko (s->fpin, a->hdr_offset, 0);
bytes = a->length + a->offset - a->hdr_offset;
hadcr = 0;
{
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);
}
else if ((WithCrypto & APPLICATION_PGP) && option (OPTPGPSTRICTENC))
convert_to_7bit (a->parts);
- }
+ }
else if (a->type == TYPEMESSAGE &&
ascii_strcasecmp(a->subtype, "delivery-status"))
{
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;
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);
}
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 ? */
{
}
}
}
-
+
safe_fclose (&fpout);
if (isendwin())
mutt_any_key_to_continue (NULL);
}
rfc822_free_address (&adrlist);
-
+
return (0);
}
char tempfile[_POSIX_PATH_MAX];
int signed_type;
int inconsistent = 0;
-
+
BODY *b = a;
BODY **signatures = NULL;
int sigcnt = 0;
if (s->flags & MUTT_DISPLAY)
{
-
+
crypt_fetch_signatures (&signatures, a->next, &sigcnt);
-
+
if (sigcnt)
{
mutt_mktemp (tempfile, sizeof (tempfile));
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;
}
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);
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;
}