NeoMutt  2024-10-02-34-g9dd811
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 4047 of file crypt_gpgme.c.

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

4056{
4057 return gpgme_send_menu(e, true);
4058}
+ 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 1893 of file pgp.c.

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

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