NeoMutt  2025-12-11-1059-g2f5469
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 4105 of file crypt_gpgme.c.

4106{
4107 return gpgme_send_menu(e, false);
4108}
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 4113 of file crypt_gpgme.c.

4114{
4115 return gpgme_send_menu(e, true);
4116}
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 1933 of file pgp.c.

1934{
1935 struct PgpKeyInfo *p = NULL;
1936 const char *prompt = NULL;
1937 const char *letters = NULL;
1938 const char *choices = NULL;
1939 char promptbuf[1024] = { 0 };
1940 int choice;
1941
1942 if (!(WithCrypto & APPLICATION_PGP))
1943 return e->security;
1944
1945 /* If autoinline and no crypto options set, then set inline. */
1946 const bool c_pgp_auto_inline = cs_subset_bool(NeoMutt->sub, "pgp_auto_inline");
1947 if (c_pgp_auto_inline &&
1948 !((e->security & APPLICATION_PGP) && (e->security & (SEC_SIGN | SEC_ENCRYPT))))
1949 {
1950 e->security |= SEC_INLINE;
1951 }
1952
1954
1955 char *mime_inline = NULL;
1956 if (e->security & SEC_INLINE)
1957 {
1958 /* L10N: The next string MUST have the same highlighted letter
1959 One of them will appear in each of the three strings marked "(inline"), below. */
1960 mime_inline = _("PGP/M(i)ME");
1961 }
1962 else
1963 {
1964 /* L10N: The previous string MUST have the same highlighted letter
1965 One of them will appear in each of the three strings marked "(inline"), below. */
1966 mime_inline = _("(i)nline");
1967 }
1968 /* Opportunistic encrypt is controlling encryption. Allow to toggle
1969 * between inline and mime, but not turn encryption on or off.
1970 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
1971 * letter choices for those. */
1972 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
1973 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
1974 {
1975 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
1976 {
1977 snprintf(promptbuf, sizeof(promptbuf),
1978 /* L10N: PGP options (inline) (opportunistic encryption is on) */
1979 _("PGP (s)ign, sign (a)s, %s format, (c)lear, or (o)ppenc mode off?"),
1980 mime_inline);
1981 prompt = promptbuf;
1982 /* L10N: PGP options (inline) (opportunistic encryption is on)
1983 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
1984 letters = _("saico");
1985 choices = "SaiCo";
1986 }
1987 else
1988 {
1989 /* L10N: PGP options (opportunistic encryption is on) */
1990 prompt = _("PGP (s)ign, sign (a)s, (c)lear, or (o)ppenc mode off?");
1991 /* L10N: PGP options (opportunistic encryption is on) */
1992 letters = _("saco");
1993 choices = "SaCo";
1994 }
1995 }
1996 else if (c_crypt_opportunistic_encrypt)
1997 {
1998 /* Opportunistic encryption option is set, but is toggled off
1999 * for this message. */
2000 /* When the message is not selected for signing or encryption, the toggle
2001 * between PGP/MIME and Traditional doesn't make sense. */
2002 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
2003 {
2004 snprintf(promptbuf, sizeof(promptbuf),
2005 /* L10N: PGP options (inline) (opportunistic encryption is off) */
2006 _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s format, (c)lear, or (o)ppenc mode?"),
2007 mime_inline);
2008 prompt = promptbuf;
2009 /* L10N: PGP options (inline) (opportunistic encryption is off)
2010 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
2011 letters = _("esabico");
2012 choices = "esabicO";
2013 }
2014 else
2015 {
2016 /* L10N: PGP options (opportunistic encryption is off) */
2017 prompt = _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2018 /* L10N: PGP options (opportunistic encryption is off) */
2019 letters = _("esabco");
2020 choices = "esabcO";
2021 }
2022 }
2023 else
2024 {
2025 /* Opportunistic encryption is unset */
2026 if (e->security & (SEC_ENCRYPT | SEC_SIGN))
2027 {
2028 snprintf(promptbuf, sizeof(promptbuf),
2029 /* L10N: PGP options (inline) */
2030 _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s format, or (c)lear?"),
2031 mime_inline);
2032 prompt = promptbuf;
2033 /* L10N: PGP options (inline)
2034 The 'i' is from the "PGP/M(i)ME" or "(i)nline", above. */
2035 letters = _("esabic");
2036 choices = "esabic";
2037 }
2038 else
2039 {
2040 /* L10N: PGP options */
2041 prompt = _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (c)lear?");
2042 /* L10N: PGP options */
2043 letters = _("esabc");
2044 choices = "esabc";
2045 }
2046 }
2047
2048 choice = mw_multi_choice(prompt, letters);
2049 if (choice > 0)
2050 {
2051 switch (choices[choice - 1])
2052 {
2053 case 'a': /* sign (a)s */
2054 OptPgpCheckTrust = false;
2055
2056 p = pgp_ask_for_key(_("Sign as: "), NULL, KEYFLAG_NONE, PGP_SECRING);
2057 if (p)
2058 {
2059 char input_signas[128] = { 0 };
2060 snprintf(input_signas, sizeof(input_signas), "0x%s", pgp_fpr_or_lkeyid(p));
2061 cs_subset_str_string_set(NeoMutt->sub, "pgp_sign_as", input_signas, NULL);
2062 pgp_key_free(&p);
2063
2064 e->security |= SEC_SIGN;
2065
2066 crypt_pgp_void_passphrase(); /* probably need a different passphrase */
2067 }
2068 break;
2069
2070 case 'b': /* (b)oth */
2071 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2072 break;
2073
2074 case 'C':
2075 e->security &= ~SEC_SIGN;
2076 break;
2077
2078 case 'c': /* (c)lear */
2079 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2080 break;
2081
2082 case 'e': /* (e)ncrypt */
2083 e->security |= SEC_ENCRYPT;
2084 e->security &= ~SEC_SIGN;
2085 break;
2086
2087 case 'i': /* toggle (i)nline */
2088 e->security ^= SEC_INLINE;
2089 break;
2090
2091 case 'O': /* oppenc mode on */
2094 break;
2095
2096 case 'o': /* oppenc mode off */
2098 break;
2099
2100 case 'S': /* (s)ign in oppenc mode */
2101 e->security |= SEC_SIGN;
2102 break;
2103
2104 case 's': /* (s)ign */
2105 e->security &= ~SEC_ENCRYPT;
2106 e->security |= SEC_SIGN;
2107 break;
2108
2109 default:
2110 break;
2111 }
2112 }
2113
2114 return e->security;
2115}
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 2063 of file smime.c.

2064{
2065 struct SmimeKey *key = NULL;
2066 const char *prompt = NULL;
2067 const char *letters = NULL;
2068 const char *choices = NULL;
2069 int choice;
2070
2072 return e->security;
2073
2075
2076 /* Opportunistic encrypt is controlling encryption.
2077 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
2078 * letter choices for those. */
2079 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
2080 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
2081 {
2082 /* L10N: S/MIME options (opportunistic encryption is on) */
2083 prompt = _("S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2084 /* L10N: S/MIME options (opportunistic encryption is on) */
2085 letters = _("swaco");
2086 choices = "SwaCo";
2087 }
2088 else if (c_crypt_opportunistic_encrypt)
2089 {
2090 /* Opportunistic encryption option is set, but is toggled off
2091 * for this message. */
2092 /* L10N: S/MIME options (opportunistic encryption is off) */
2093 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2094 /* L10N: S/MIME options (opportunistic encryption is off) */
2095 letters = _("eswabco");
2096 choices = "eswabcO";
2097 }
2098 else
2099 {
2100 /* Opportunistic encryption is unset */
2101 /* L10N: S/MIME options */
2102 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2103 /* L10N: S/MIME options */
2104 letters = _("eswabc");
2105 choices = "eswabc";
2106 }
2107
2108 choice = mw_multi_choice(prompt, letters);
2109 if (choice > 0)
2110 {
2111 switch (choices[choice - 1])
2112 {
2113 case 'a': /* sign (a)s */
2114 key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, false);
2115 if (key)
2116 {
2117 cs_subset_str_string_set(NeoMutt->sub, "smime_sign_as", key->hash, NULL);
2118 smime_key_free(&key);
2119
2120 e->security |= SEC_SIGN;
2121
2122 /* probably need a different passphrase */
2124 }
2125
2126 break;
2127
2128 case 'b': /* (b)oth */
2129 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2130 break;
2131
2132 case 'c': /* (c)lear */
2133 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2134 break;
2135
2136 case 'C':
2137 e->security &= ~SEC_SIGN;
2138 break;
2139
2140 case 'e': /* (e)ncrypt */
2141 e->security |= SEC_ENCRYPT;
2142 e->security &= ~SEC_SIGN;
2143 break;
2144
2145 case 'O': /* oppenc mode on */
2148 break;
2149
2150 case 'o': /* oppenc mode off */
2152 break;
2153
2154 case 'S': /* (s)ign in oppenc mode */
2155 e->security |= SEC_SIGN;
2156 break;
2157
2158 case 's': /* (s)ign */
2159 e->security &= ~SEC_ENCRYPT;
2160 e->security |= SEC_SIGN;
2161 break;
2162
2163 case 'w': /* encrypt (w)ith */
2164 {
2165 e->security |= SEC_ENCRYPT;
2166 do
2167 {
2168 struct Buffer *errmsg = buf_pool_get();
2169 int rc = CSR_SUCCESS;
2170 switch (mw_multi_choice(_("Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2171 // L10N: Options for: Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?
2172 _("123c")))
2173 {
2174 case 1:
2175 switch (choice = mw_multi_choice(_("(1) DES, (2) Triple-DES?"),
2176 // L10N: Options for: (1) DES, (2) Triple-DES
2177 _("12")))
2178 {
2179 case 1:
2180 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2181 "des", errmsg);
2182 break;
2183 case 2:
2184 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2185 "des3", errmsg);
2186 break;
2187 default:
2188 break;
2189 }
2190 break;
2191
2192 case 2:
2193 switch (choice = mw_multi_choice(_("(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2194 // L10N: Options for: (1) RC2-40, (2) RC2-64, (3) RC2-128
2195 _("123")))
2196 {
2197 case 1:
2198 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2199 "rc2-40", errmsg);
2200 break;
2201 case 2:
2202 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2203 "rc2-64", errmsg);
2204 break;
2205 case 3:
2206 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2207 "rc2-128", errmsg);
2208 break;
2209 default:
2210 break;
2211 }
2212 break;
2213
2214 case 3:
2215 switch (choice = mw_multi_choice(_("(1) AES128, (2) AES192, (3) AES256?"),
2216 // L10N: Options for: (1) AES128, (2) AES192, (3) AES256
2217 _("123")))
2218 {
2219 case 1:
2220 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2221 "aes128", errmsg);
2222 break;
2223 case 2:
2224 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2225 "aes192", errmsg);
2226 break;
2227 case 3:
2228 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2229 "aes256", errmsg);
2230 break;
2231 default:
2232 break;
2233 }
2234 break;
2235
2236 case 4:
2237 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with", NULL, errmsg);
2238 /* (c)lear */
2240
2241 case -1: /* Ctrl-G or Enter */
2242 choice = 0;
2243 break;
2244
2245 default:
2246 break;
2247 }
2248
2249 if ((CSR_RESULT(rc) != CSR_SUCCESS) && !buf_is_empty(errmsg))
2250 mutt_error("%s", buf_string(errmsg));
2251
2252 buf_pool_release(&errmsg);
2253 } while (choice == -1);
2254 break;
2255 }
2256
2257 default:
2258 break;
2259 }
2260 }
2261
2262 return e->security;
2263}
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:99
#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:37
An SIME key.
Definition smime.h:43
char * hash
Key hash.
Definition smime.h:45
Here is the call graph for this function: