NeoMutt  2024-04-16-36-g75b6fb
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 4005 of file crypt_gpgme.c.

4006{
4007 return gpgme_send_menu(e, false);
4008}
static SecurityFlags gpgme_send_menu(struct Email *e, bool is_smime)
Show the user the encryption/signing menu.
Definition: crypt_gpgme.c:3844
+ 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 4013 of file crypt_gpgme.c.

4014{
4015 return gpgme_send_menu(e, true);
4016}
+ 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 1896 of file pgp.c.

1897{
1898 struct PgpKeyInfo *p = NULL;
1899 const char *prompt = NULL;
1900 const char *letters = NULL;
1901 const char *choices = NULL;
1902 char promptbuf[1024] = { 0 };
1903 int choice;
1904
1905 if (!(WithCrypto & APPLICATION_PGP))
1906 return e->security;
1907
1908 /* If autoinline and no crypto options set, then set inline. */
1909 const bool c_pgp_auto_inline = cs_subset_bool(NeoMutt->sub, "pgp_auto_inline");
1910 if (c_pgp_auto_inline &&
1911 !((e->security & APPLICATION_PGP) && (e->security & (SEC_SIGN | SEC_ENCRYPT))))
1912 {
1913 e->security |= SEC_INLINE;
1914 }
1915
1917
1918 char *mime_inline = NULL;
1919 if (e->security & SEC_INLINE)
1920 {
1921 /* L10N: The next string MUST have the same highlighted letter
1922 One of them will appear in each of the three strings marked "(inline"), below. */
1923 mime_inline = _("PGP/M(i)ME");
1924 }
1925 else
1926 {
1927 /* L10N: The previous string MUST have the same highlighted letter
1928 One of them will appear in each of the three strings marked "(inline"), below. */
1929 mime_inline = _("(i)nline");
1930 }
1931 /* Opportunistic encrypt is controlling encryption. Allow to toggle
1932 * between inline and mime, but not turn encryption on or off.
1933 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
1934 * letter choices for those. */
1935 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
1936 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
1937 {
1938 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
1939 {
1940 snprintf(promptbuf, sizeof(promptbuf),
1941 /* L10N: PGP options (inline) (opportunistic encryption is on) */
1942 _("PGP (s)ign, sign (a)s, %s format, (c)lear, or (o)ppenc mode off?"),
1943 mime_inline);
1944 prompt = promptbuf;
1945 /* L10N: PGP options (inline) (opportunistic encryption is on)
1946 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
1947 letters = _("saico");
1948 choices = "SaiCo";
1949 }
1950 else
1951 {
1952 /* L10N: PGP options (opportunistic encryption is on) */
1953 prompt = _("PGP (s)ign, sign (a)s, (c)lear, or (o)ppenc mode off?");
1954 /* L10N: PGP options (opportunistic encryption is on) */
1955 letters = _("saco");
1956 choices = "SaCo";
1957 }
1958 }
1959 else if (c_crypt_opportunistic_encrypt)
1960 {
1961 /* Opportunistic encryption option is set, but is toggled off
1962 * for this message. */
1963 /* When the message is not selected for signing or encryption, the toggle
1964 * between PGP/MIME and Traditional doesn't make sense. */
1965 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
1966 {
1967 snprintf(promptbuf, sizeof(promptbuf),
1968 /* L10N: PGP options (inline) (opportunistic encryption is off) */
1969 _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s format, (c)lear, or (o)ppenc mode?"),
1970 mime_inline);
1971 prompt = promptbuf;
1972 /* L10N: PGP options (inline) (opportunistic encryption is off)
1973 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
1974 letters = _("esabico");
1975 choices = "esabicO";
1976 }
1977 else
1978 {
1979 /* L10N: PGP options (opportunistic encryption is off) */
1980 prompt = _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
1981 /* L10N: PGP options (opportunistic encryption is off) */
1982 letters = _("esabco");
1983 choices = "esabcO";
1984 }
1985 }
1986 else
1987 {
1988 /* Opportunistic encryption is unset */
1989 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
1990 {
1991 snprintf(promptbuf, sizeof(promptbuf),
1992 /* L10N: PGP options (inline) */
1993 _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s format, or (c)lear?"),
1994 mime_inline);
1995 prompt = promptbuf;
1996 /* L10N: PGP options (inline)
1997 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
1998 letters = _("esabic");
1999 choices = "esabic";
2000 }
2001 else
2002 {
2003 /* L10N: PGP options */
2004 prompt = _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (c)lear?");
2005 /* L10N: PGP options */
2006 letters = _("esabc");
2007 choices = "esabc";
2008 }
2009 }
2010
2011 choice = mw_multi_choice(prompt, letters);
2012 if (choice > 0)
2013 {
2014 switch (choices[choice - 1])
2015 {
2016 case 'a': /* sign (a)s */
2017 OptPgpCheckTrust = false;
2018
2019 p = pgp_ask_for_key(_("Sign as: "), NULL, KEYFLAG_NO_FLAGS, PGP_SECRING);
2020 if (p)
2021 {
2022 char input_signas[128] = { 0 };
2023 snprintf(input_signas, sizeof(input_signas), "0x%s", pgp_fpr_or_lkeyid(p));
2024 cs_subset_str_string_set(NeoMutt->sub, "pgp_sign_as", input_signas, NULL);
2025 pgp_key_free(&p);
2026
2027 e->security |= SEC_SIGN;
2028
2029 crypt_pgp_void_passphrase(); /* probably need a different passphrase */
2030 }
2031 break;
2032
2033 case 'b': /* (b)oth */
2034 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2035 break;
2036
2037 case 'C':
2038 e->security &= ~SEC_SIGN;
2039 break;
2040
2041 case 'c': /* (c)lear */
2042 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2043 break;
2044
2045 case 'e': /* (e)ncrypt */
2046 e->security |= SEC_ENCRYPT;
2047 e->security &= ~SEC_SIGN;
2048 break;
2049
2050 case 'i': /* toggle (i)nline */
2051 e->security ^= SEC_INLINE;
2052 break;
2053
2054 case 'O': /* oppenc mode on */
2057 break;
2058
2059 case 'o': /* oppenc mode off */
2060 e->security &= ~SEC_OPPENCRYPT;
2061 break;
2062
2063 case 'S': /* (s)ign in oppenc mode */
2064 e->security |= SEC_SIGN;
2065 break;
2066
2067 case 's': /* (s)ign */
2068 e->security &= ~SEC_ENCRYPT;
2069 e->security |= SEC_SIGN;
2070 break;
2071 }
2072 }
2073
2074 return e->security;
2075}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1031
void crypt_pgp_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:190
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
Definition: globals.c:73
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition: question.c:64
#define _(a)
Definition: message.h:28
#define SEC_INLINE
Email has an inline signature.
Definition: lib.h:85
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: lib.h:86
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define KEYFLAG_NO_FLAGS
No flags are set.
Definition: lib.h:126
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:78
#define WithCrypto
Definition: lib.h:116
#define SEC_SIGN
Email is signed.
Definition: lib.h:79
char * pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
Get the fingerprint or long keyid.
Definition: pgp.c:234
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:198
@ PGP_SECRING
Secret keys.
Definition: pgpkey.h:40
void pgp_key_free(struct PgpKeyInfo **kpp)
Free a PGP key info.
Definition: pgplib.c:201
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:45
Information about a PGP key.
Definition: pgplib.h:47
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:386
+ 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 2139 of file smime.c.

2140{
2141 struct SmimeKey *key = NULL;
2142 const char *prompt = NULL;
2143 const char *letters = NULL;
2144 const char *choices = NULL;
2145 int choice;
2146
2148 return e->security;
2149
2151
2152 /* Opportunistic encrypt is controlling encryption.
2153 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
2154 * letter choices for those. */
2155 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
2156 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
2157 {
2158 /* L10N: S/MIME options (opportunistic encryption is on) */
2159 prompt = _("S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2160 /* L10N: S/MIME options (opportunistic encryption is on) */
2161 letters = _("swaco");
2162 choices = "SwaCo";
2163 }
2164 else if (c_crypt_opportunistic_encrypt)
2165 {
2166 /* Opportunistic encryption option is set, but is toggled off
2167 * for this message. */
2168 /* L10N: S/MIME options (opportunistic encryption is off) */
2169 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2170 /* L10N: S/MIME options (opportunistic encryption is off) */
2171 letters = _("eswabco");
2172 choices = "eswabcO";
2173 }
2174 else
2175 {
2176 /* Opportunistic encryption is unset */
2177 /* L10N: S/MIME options */
2178 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2179 /* L10N: S/MIME options */
2180 letters = _("eswabc");
2181 choices = "eswabc";
2182 }
2183
2184 choice = mw_multi_choice(prompt, letters);
2185 if (choice > 0)
2186 {
2187 switch (choices[choice - 1])
2188 {
2189 case 'a': /* sign (a)s */
2190 key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, false);
2191 if (key)
2192 {
2193 cs_subset_str_string_set(NeoMutt->sub, "smime_sign_as", key->hash, NULL);
2194 smime_key_free(&key);
2195
2196 e->security |= SEC_SIGN;
2197
2198 /* probably need a different passphrase */
2200 }
2201
2202 break;
2203
2204 case 'b': /* (b)oth */
2205 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2206 break;
2207
2208 case 'c': /* (c)lear */
2209 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2210 break;
2211
2212 case 'C':
2213 e->security &= ~SEC_SIGN;
2214 break;
2215
2216 case 'e': /* (e)ncrypt */
2217 e->security |= SEC_ENCRYPT;
2218 e->security &= ~SEC_SIGN;
2219 break;
2220
2221 case 'O': /* oppenc mode on */
2224 break;
2225
2226 case 'o': /* oppenc mode off */
2227 e->security &= ~SEC_OPPENCRYPT;
2228 break;
2229
2230 case 'S': /* (s)ign in oppenc mode */
2231 e->security |= SEC_SIGN;
2232 break;
2233
2234 case 's': /* (s)ign */
2235 e->security &= ~SEC_ENCRYPT;
2236 e->security |= SEC_SIGN;
2237 break;
2238
2239 case 'w': /* encrypt (w)ith */
2240 {
2241 e->security |= SEC_ENCRYPT;
2242 do
2243 {
2244 struct Buffer *errmsg = buf_pool_get();
2245 int rc = CSR_SUCCESS;
2246 switch (mw_multi_choice(_("Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2247 // L10N: Options for: Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?
2248 _("123c")))
2249 {
2250 case 1:
2251 switch (choice = mw_multi_choice(_("(1) DES, (2) Triple-DES?"),
2252 // L10N: Options for: (1) DES, (2) Triple-DES
2253 _("12")))
2254 {
2255 case 1:
2256 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2257 "des", errmsg);
2258 break;
2259 case 2:
2260 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2261 "des3", errmsg);
2262 break;
2263 }
2264 break;
2265
2266 case 2:
2267 switch (choice = mw_multi_choice(_("(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2268 // L10N: Options for: (1) RC2-40, (2) RC2-64, (3) RC2-128
2269 _("123")))
2270 {
2271 case 1:
2272 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2273 "rc2-40", errmsg);
2274 break;
2275 case 2:
2276 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2277 "rc2-64", errmsg);
2278 break;
2279 case 3:
2280 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2281 "rc2-128", errmsg);
2282 break;
2283 }
2284 break;
2285
2286 case 3:
2287 switch (choice = mw_multi_choice(_("(1) AES128, (2) AES192, (3) AES256?"),
2288 // L10N: Options for: (1) AES128, (2) AES192, (3) AES256
2289 _("123")))
2290 {
2291 case 1:
2292 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2293 "aes128", errmsg);
2294 break;
2295 case 2:
2296 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2297 "aes192", errmsg);
2298 break;
2299 case 3:
2300 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2301 "aes256", errmsg);
2302 break;
2303 }
2304 break;
2305
2306 case 4:
2307 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with", NULL, errmsg);
2308 /* (c)lear */
2310
2311 case -1: /* Ctrl-G or Enter */
2312 choice = 0;
2313 break;
2314 }
2315
2316 if ((CSR_RESULT(rc) != CSR_SUCCESS) && !buf_is_empty(errmsg))
2317 mutt_error("%s", buf_string(errmsg));
2318
2319 buf_pool_release(&errmsg);
2320 } while (choice == -1);
2321 break;
2322 }
2323 }
2324 }
2325
2326 return e->security;
2327}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:290
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)
Definition: set.h:52
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:412
#define mutt_error(...)
Definition: logging2.h:92
#define FALLTHROUGH
Definition: lib.h:111
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#define KEYFLAG_CANSIGN
Key is suitable for signing.
Definition: lib.h:127
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
static struct SmimeKey * smime_ask_for_key(char *prompt, KeyFlags abilities, bool only_public_key)
Ask the user to select a key.
Definition: smime.c:685
static void smime_key_free(struct SmimeKey **keylist)
Free a list of SMIME keys.
Definition: smime.c:105
String manipulation buffer.
Definition: buffer.h:36
An SIME key.
Definition: smime.h:43
char * hash
Definition: smime.h:45
+ Here is the call graph for this function: