if (!WithCrypto)
return;
- /* crypt_autoencrypt should override crypt_opportunistic_encrypt */
- if (option (OPTCRYPTAUTOENCRYPT))
+ if (! (option (OPTCRYPTOPPORTUNISTICENCRYPT) && (msg->security & OPPENCRYPT)) )
return;
crypt_get_keys (msg, &pgpkeylist, 1);
typedef struct header
{
- unsigned int security : 11; /* bit 0-6: flags, bit 7,8: application.
- see: crypt.h pgplib.h, smime.h */
+ unsigned int security : 12; /* bit 0-8: flags, bit 9,10: application.
+ see: mutt_crypt.h pgplib.h, smime.h */
unsigned int mime : 1; /* has a MIME-Version header? */
unsigned int flagged : 1; /* marked important? */
#define SIGNOPAQUE (1 << 5)
#define KEYBLOCK (1 << 6) /* KEY too generic? */
#define INLINE (1 << 7)
+#define OPPENCRYPT (1 << 8) /* Opportunistic encrypt mode */
-#define APPLICATION_PGP (1 << 8)
-#define APPLICATION_SMIME (1 << 9)
+#define APPLICATION_PGP (1 << 9)
+#define APPLICATION_SMIME (1 << 10)
-#define PGP_TRADITIONAL_CHECKED (1 << 10)
+#define PGP_TRADITIONAL_CHECKED (1 << 11)
#define PGPENCRYPT (APPLICATION_PGP | ENCRYPT)
#define PGPSIGN (APPLICATION_PGP | SIGN)
tmp = tmp->next;
}
}
+
+ if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
+ crypt_opportunistic_encrypt (hdr);
+
return (code);
}
flags |= ENCRYPT;
break;
+ case 'o':
+ case 'O':
+ flags |= OPPENCRYPT;
+ break;
+
case 's':
case 'S':
flags |= SIGN;
if (mutt_prepare_template (fp, ctx, msg, cur, 1) < 0)
return -1;
-
+
+ if (WithCrypto)
+ {
+ /* mutt_prepare_template doesn't always flip on an application bit.
+ * so fix that here */
+ if (!(msg->security & (APPLICATION_SMIME | APPLICATION_PGP)))
+ {
+ if ((WithCrypto & APPLICATION_SMIME) && option (OPTSMIMEISDEFAULT))
+ msg->security |= APPLICATION_SMIME;
+ else if (WithCrypto & APPLICATION_PGP)
+ msg->security |= APPLICATION_PGP;
+ else
+ msg->security |= APPLICATION_SMIME;
+ }
+
+ if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
+ {
+ msg->security |= OPPENCRYPT;
+ crypt_opportunistic_encrypt(msg);
+ }
+ }
+
return ci_send_message (SENDRESEND, msg, NULL, ctx, cur);
}
/* opportunistic encrypt relys on SMIME or PGP already being selected */
if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
{
- crypt_opportunistic_encrypt(msg);
+ /* If something has already enabled encryption, e.g. OPTCRYPTAUTOENCRYPT
+ * or OPTCRYPTREPLYENCRYPT, then don't enable opportunistic encrypt for
+ * the message.
+ */
+ if (! (msg->security & ENCRYPT))
+ {
+ msg->security |= OPPENCRYPT;
+ crypt_opportunistic_encrypt(msg);
+ }
}
/* No permissible mechanisms found. Don't sign or encrypt. */
fputs ("X-Mutt-PGP: ", msg->fp);
if (hdr->security & ENCRYPT)
fputc ('E', msg->fp);
+ if (hdr->security & OPPENCRYPT)
+ fputc ('O', msg->fp);
if (hdr->security & SIGN)
{
fputc ('S', msg->fp);
if (SmimeCryptAlg && *SmimeCryptAlg)
fprintf (msg->fp, "C<%s>", SmimeCryptAlg);
}
+ if (hdr->security & OPPENCRYPT)
+ fputc ('O', msg->fp);
if (hdr->security & SIGN) {
fputc ('S', msg->fp);
if (SmimeDefaultKey && *SmimeDefaultKey)