NeoMutt  2024-03-23-142-g2b2e76
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 4002 of file crypt_gpgme.c.

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

4011{
4012 return gpgme_send_menu(e, true);
4013}
+ 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 2138 of file smime.c.

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