NeoMutt  2024-11-14-34-g5aaf0d
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:48
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 2142 of file smime.c.

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