NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
send_menu()

Ask the user whether to sign and/or encrypt the email. More...

Collaboration diagram for send_menu():

Functions

SecurityFlags pgp_gpgme_send_menu (struct Email *e)
 Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.
SecurityFlags smime_gpgme_send_menu (struct Email *e)
 Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.
SecurityFlags pgp_class_send_menu (struct Email *e)
 Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.
SecurityFlags smime_class_send_menu (struct Email *e)
 Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.

Detailed Description

Ask the user whether to sign and/or encrypt the email.

Parameters
eEmail
Return values
numFlags, e.g. APPLICATION_PGP | SEC_ENCRYPT

Function Documentation

◆ pgp_gpgme_send_menu()

SecurityFlags pgp_gpgme_send_menu ( struct Email * e)

Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.

Definition at line 4095 of file crypt_gpgme.c.

4096{
4097 return gpgme_send_menu(e, false);
4098}
static SecurityFlags gpgme_send_menu(struct Email *e, bool is_smime)
Show the user the encryption/signing menu.
Here is the call graph for this function:

◆ smime_gpgme_send_menu()

SecurityFlags smime_gpgme_send_menu ( struct Email * e)

Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.

Definition at line 4103 of file crypt_gpgme.c.

4104{
4105 return gpgme_send_menu(e, true);
4106}
Here is the call graph for this function:

◆ pgp_class_send_menu()

SecurityFlags pgp_class_send_menu ( struct Email * e)

Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.

Definition at line 1929 of file pgp.c.

1930{
1931 struct PgpKeyInfo *p = NULL;
1932 const char *prompt = NULL;
1933 const char *letters = NULL;
1934 const char *choices = NULL;
1935 char promptbuf[1024] = { 0 };
1936 int choice;
1937
1938 if (!(WithCrypto & APPLICATION_PGP))
1939 return e->security;
1940
1941 /* If autoinline and no crypto options set, then set inline. */
1942 const bool c_pgp_auto_inline = cs_subset_bool(NeoMutt->sub, "pgp_auto_inline");
1943 if (c_pgp_auto_inline &&
1944 !((e->security & APPLICATION_PGP) && (e->security & (SEC_SIGN | SEC_ENCRYPT))))
1945 {
1946 e->security |= SEC_INLINE;
1947 }
1948
1950
1951 char *mime_inline = NULL;
1952 if (e->security & SEC_INLINE)
1953 {
1954 /* L10N: The next string MUST have the same highlighted letter
1955 One of them will appear in each of the three strings marked "(inline"), below. */
1956 mime_inline = _("PGP/M(i)ME");
1957 }
1958 else
1959 {
1960 /* L10N: The previous string MUST have the same highlighted letter
1961 One of them will appear in each of the three strings marked "(inline"), below. */
1962 mime_inline = _("(i)nline");
1963 }
1964 /* Opportunistic encrypt is controlling encryption. Allow to toggle
1965 * between inline and mime, but not turn encryption on or off.
1966 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
1967 * letter choices for those. */
1968 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
1969 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
1970 {
1971 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
1972 {
1973 snprintf(promptbuf, sizeof(promptbuf),
1974 /* L10N: PGP options (inline) (opportunistic encryption is on) */
1975 _("PGP (s)ign, sign (a)s, %s format, (c)lear, or (o)ppenc mode off?"),
1976 mime_inline);
1977 prompt = promptbuf;
1978 /* L10N: PGP options (inline) (opportunistic encryption is on)
1979 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
1980 letters = _("saico");
1981 choices = "SaiCo";
1982 }
1983 else
1984 {
1985 /* L10N: PGP options (opportunistic encryption is on) */
1986 prompt = _("PGP (s)ign, sign (a)s, (c)lear, or (o)ppenc mode off?");
1987 /* L10N: PGP options (opportunistic encryption is on) */
1988 letters = _("saco");
1989 choices = "SaCo";
1990 }
1991 }
1992 else if (c_crypt_opportunistic_encrypt)
1993 {
1994 /* Opportunistic encryption option is set, but is toggled off
1995 * for this message. */
1996 /* When the message is not selected for signing or encryption, the toggle
1997 * between PGP/MIME and Traditional doesn't make sense. */
1998 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
1999 {
2000 snprintf(promptbuf, sizeof(promptbuf),
2001 /* L10N: PGP options (inline) (opportunistic encryption is off) */
2002 _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s format, (c)lear, or (o)ppenc mode?"),
2003 mime_inline);
2004 prompt = promptbuf;
2005 /* L10N: PGP options (inline) (opportunistic encryption is off)
2006 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
2007 letters = _("esabico");
2008 choices = "esabicO";
2009 }
2010 else
2011 {
2012 /* L10N: PGP options (opportunistic encryption is off) */
2013 prompt = _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2014 /* L10N: PGP options (opportunistic encryption is off) */
2015 letters = _("esabco");
2016 choices = "esabcO";
2017 }
2018 }
2019 else
2020 {
2021 /* Opportunistic encryption is unset */
2022 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
2023 {
2024 snprintf(promptbuf, sizeof(promptbuf),
2025 /* L10N: PGP options (inline) */
2026 _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s format, or (c)lear?"),
2027 mime_inline);
2028 prompt = promptbuf;
2029 /* L10N: PGP options (inline)
2030 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
2031 letters = _("esabic");
2032 choices = "esabic";
2033 }
2034 else
2035 {
2036 /* L10N: PGP options */
2037 prompt = _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (c)lear?");
2038 /* L10N: PGP options */
2039 letters = _("esabc");
2040 choices = "esabc";
2041 }
2042 }
2043
2044 choice = mw_multi_choice(prompt, letters);
2045 if (choice > 0)
2046 {
2047 switch (choices[choice - 1])
2048 {
2049 case 'a': /* sign (a)s */
2050 OptPgpCheckTrust = false;
2051
2052 p = pgp_ask_for_key(_("Sign as: "), NULL, KEYFLAG_NONE, PGP_SECRING);
2053 if (p)
2054 {
2055 char input_signas[128] = { 0 };
2056 snprintf(input_signas, sizeof(input_signas), "0x%s", pgp_fpr_or_lkeyid(p));
2057 cs_subset_str_string_set(NeoMutt->sub, "pgp_sign_as", input_signas, NULL);
2058 pgp_key_free(&p);
2059
2060 e->security |= SEC_SIGN;
2061
2062 crypt_pgp_void_passphrase(); /* probably need a different passphrase */
2063 }
2064 break;
2065
2066 case 'b': /* (b)oth */
2067 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2068 break;
2069
2070 case 'C':
2071 e->security &= ~SEC_SIGN;
2072 break;
2073
2074 case 'c': /* (c)lear */
2075 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2076 break;
2077
2078 case 'e': /* (e)ncrypt */
2079 e->security |= SEC_ENCRYPT;
2080 e->security &= ~SEC_SIGN;
2081 break;
2082
2083 case 'i': /* toggle (i)nline */
2084 e->security ^= SEC_INLINE;
2085 break;
2086
2087 case 'O': /* oppenc mode on */
2090 break;
2091
2092 case 'o': /* oppenc mode off */
2094 break;
2095
2096 case 'S': /* (s)ign in oppenc mode */
2097 e->security |= SEC_SIGN;
2098 break;
2099
2100 case 's': /* (s)ign */
2101 e->security &= ~SEC_ENCRYPT;
2102 e->security |= SEC_SIGN;
2103 break;
2104
2105 default:
2106 break;
2107 }
2108 }
2109
2110 return e->security;
2111}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition crypt.c:1052
void crypt_pgp_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase().
Definition cryptglue.c:211
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
Definition globals.c:55
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition question.c:62
#define _(a)
Definition message.h:28
@ SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition lib.h:100
@ SEC_SIGN
Email is signed.
Definition lib.h:93
@ SEC_INLINE
Email has an inline signature.
Definition lib.h:99
@ SEC_ENCRYPT
Email is encrypted.
Definition lib.h:92
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:106
@ KEYFLAG_NONE
No flags are set.
Definition lib.h:146
#define WithCrypto
Definition lib.h:132
char * pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
Get the fingerprint or long keyid.
Definition pgp.c:231
struct PgpKeyInfo * pgp_ask_for_key(char *tag, const char *whatfor, KeyFlags abilities, enum PgpRing keyring)
Ask the user for a PGP key.
Definition pgpkey.c:202
@ PGP_SECRING
Secret keys.
Definition pgpkey.h:41
void pgp_key_free(struct PgpKeyInfo **kpp)
Free a PGP key info.
Definition pgplib.c:204
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition email.h:43
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Information about a PGP key.
Definition pgplib.h:49
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition subset.c:392
Here is the call graph for this function:

◆ smime_class_send_menu()

SecurityFlags smime_class_send_menu ( struct Email * e)

Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.

Definition at line 2058 of file smime.c.

2059{
2060 struct SmimeKey *key = NULL;
2061 const char *prompt = NULL;
2062 const char *letters = NULL;
2063 const char *choices = NULL;
2064 int choice;
2065
2067 return e->security;
2068
2070
2071 /* Opportunistic encrypt is controlling encryption.
2072 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
2073 * letter choices for those. */
2074 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
2075 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
2076 {
2077 /* L10N: S/MIME options (opportunistic encryption is on) */
2078 prompt = _("S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2079 /* L10N: S/MIME options (opportunistic encryption is on) */
2080 letters = _("swaco");
2081 choices = "SwaCo";
2082 }
2083 else if (c_crypt_opportunistic_encrypt)
2084 {
2085 /* Opportunistic encryption option is set, but is toggled off
2086 * for this message. */
2087 /* L10N: S/MIME options (opportunistic encryption is off) */
2088 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2089 /* L10N: S/MIME options (opportunistic encryption is off) */
2090 letters = _("eswabco");
2091 choices = "eswabcO";
2092 }
2093 else
2094 {
2095 /* Opportunistic encryption is unset */
2096 /* L10N: S/MIME options */
2097 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2098 /* L10N: S/MIME options */
2099 letters = _("eswabc");
2100 choices = "eswabc";
2101 }
2102
2103 choice = mw_multi_choice(prompt, letters);
2104 if (choice > 0)
2105 {
2106 switch (choices[choice - 1])
2107 {
2108 case 'a': /* sign (a)s */
2109 key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, false);
2110 if (key)
2111 {
2112 cs_subset_str_string_set(NeoMutt->sub, "smime_sign_as", key->hash, NULL);
2113 smime_key_free(&key);
2114
2115 e->security |= SEC_SIGN;
2116
2117 /* probably need a different passphrase */
2119 }
2120
2121 break;
2122
2123 case 'b': /* (b)oth */
2124 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2125 break;
2126
2127 case 'c': /* (c)lear */
2128 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2129 break;
2130
2131 case 'C':
2132 e->security &= ~SEC_SIGN;
2133 break;
2134
2135 case 'e': /* (e)ncrypt */
2136 e->security |= SEC_ENCRYPT;
2137 e->security &= ~SEC_SIGN;
2138 break;
2139
2140 case 'O': /* oppenc mode on */
2143 break;
2144
2145 case 'o': /* oppenc mode off */
2147 break;
2148
2149 case 'S': /* (s)ign in oppenc mode */
2150 e->security |= SEC_SIGN;
2151 break;
2152
2153 case 's': /* (s)ign */
2154 e->security &= ~SEC_ENCRYPT;
2155 e->security |= SEC_SIGN;
2156 break;
2157
2158 case 'w': /* encrypt (w)ith */
2159 {
2160 e->security |= SEC_ENCRYPT;
2161 do
2162 {
2163 struct Buffer *errmsg = buf_pool_get();
2164 int rc = CSR_SUCCESS;
2165 switch (mw_multi_choice(_("Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2166 // L10N: Options for: Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?
2167 _("123c")))
2168 {
2169 case 1:
2170 switch (choice = mw_multi_choice(_("(1) DES, (2) Triple-DES?"),
2171 // L10N: Options for: (1) DES, (2) Triple-DES
2172 _("12")))
2173 {
2174 case 1:
2175 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2176 "des", errmsg);
2177 break;
2178 case 2:
2179 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2180 "des3", errmsg);
2181 break;
2182 default:
2183 break;
2184 }
2185 break;
2186
2187 case 2:
2188 switch (choice = mw_multi_choice(_("(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2189 // L10N: Options for: (1) RC2-40, (2) RC2-64, (3) RC2-128
2190 _("123")))
2191 {
2192 case 1:
2193 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2194 "rc2-40", errmsg);
2195 break;
2196 case 2:
2197 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2198 "rc2-64", errmsg);
2199 break;
2200 case 3:
2201 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2202 "rc2-128", errmsg);
2203 break;
2204 default:
2205 break;
2206 }
2207 break;
2208
2209 case 3:
2210 switch (choice = mw_multi_choice(_("(1) AES128, (2) AES192, (3) AES256?"),
2211 // L10N: Options for: (1) AES128, (2) AES192, (3) AES256
2212 _("123")))
2213 {
2214 case 1:
2215 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2216 "aes128", errmsg);
2217 break;
2218 case 2:
2219 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2220 "aes192", errmsg);
2221 break;
2222 case 3:
2223 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2224 "aes256", errmsg);
2225 break;
2226 default:
2227 break;
2228 }
2229 break;
2230
2231 case 4:
2232 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with", NULL, errmsg);
2233 /* (c)lear */
2235
2236 case -1: /* Ctrl-G or Enter */
2237 choice = 0;
2238 break;
2239
2240 default:
2241 break;
2242 }
2243
2244 if ((CSR_RESULT(rc) != CSR_SUCCESS) && !buf_is_empty(errmsg))
2245 mutt_error("%s", buf_string(errmsg));
2246
2247 buf_pool_release(&errmsg);
2248 } while (choice == -1);
2249 break;
2250 }
2251
2252 default:
2253 break;
2254 }
2255 }
2256
2257 return e->security;
2258}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:298
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
#define CSR_RESULT(x)
Extract the result code from CSR_* flags.
Definition set.h:53
#define CSR_SUCCESS
Action completed successfully.
Definition set.h:33
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase().
Definition cryptglue.c:484
#define mutt_error(...)
Definition logging2.h:94
#define FALLTHROUGH
Definition lib.h:117
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition lib.h:107
@ KEYFLAG_CANSIGN
Key is suitable for signing.
Definition lib.h:147
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
static void smime_key_free(struct SmimeKey **keylist)
Free a list of SMIME keys.
Definition smime.c:91
static struct SmimeKey * smime_ask_for_key(const char *prompt, KeyFlags abilities, bool only_public_key)
Ask the user to select a key.
Definition smime.c:543
String manipulation buffer.
Definition buffer.h:36
An SIME key.
Definition smime.h:43
char * hash
Key hash.
Definition smime.h:45
Here is the call graph for this function: