NeoMutt  2025-12-11-1009-ga75d9e
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 4078 of file crypt_gpgme.c.

4079{
4080 return gpgme_send_menu(e, false);
4081}
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 4086 of file crypt_gpgme.c.

4087{
4088 return gpgme_send_menu(e, true);
4089}
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 1912 of file pgp.c.

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

2026{
2027 struct SmimeKey *key = NULL;
2028 const char *prompt = NULL;
2029 const char *letters = NULL;
2030 const char *choices = NULL;
2031 int choice;
2032
2034 return e->security;
2035
2037
2038 /* Opportunistic encrypt is controlling encryption.
2039 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
2040 * letter choices for those. */
2041 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
2042 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
2043 {
2044 /* L10N: S/MIME options (opportunistic encryption is on) */
2045 prompt = _("S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2046 /* L10N: S/MIME options (opportunistic encryption is on) */
2047 letters = _("swaco");
2048 choices = "SwaCo";
2049 }
2050 else if (c_crypt_opportunistic_encrypt)
2051 {
2052 /* Opportunistic encryption option is set, but is toggled off
2053 * for this message. */
2054 /* L10N: S/MIME options (opportunistic encryption is off) */
2055 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2056 /* L10N: S/MIME options (opportunistic encryption is off) */
2057 letters = _("eswabco");
2058 choices = "eswabcO";
2059 }
2060 else
2061 {
2062 /* Opportunistic encryption is unset */
2063 /* L10N: S/MIME options */
2064 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2065 /* L10N: S/MIME options */
2066 letters = _("eswabc");
2067 choices = "eswabc";
2068 }
2069
2070 choice = mw_multi_choice(prompt, letters);
2071 if (choice > 0)
2072 {
2073 switch (choices[choice - 1])
2074 {
2075 case 'a': /* sign (a)s */
2076 key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, false);
2077 if (key)
2078 {
2079 cs_subset_str_string_set(NeoMutt->sub, "smime_sign_as", key->hash, NULL);
2080 smime_key_free(&key);
2081
2082 e->security |= SEC_SIGN;
2083
2084 /* probably need a different passphrase */
2086 }
2087
2088 break;
2089
2090 case 'b': /* (b)oth */
2091 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2092 break;
2093
2094 case 'c': /* (c)lear */
2095 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2096 break;
2097
2098 case 'C':
2099 e->security &= ~SEC_SIGN;
2100 break;
2101
2102 case 'e': /* (e)ncrypt */
2103 e->security |= SEC_ENCRYPT;
2104 e->security &= ~SEC_SIGN;
2105 break;
2106
2107 case 'O': /* oppenc mode on */
2110 break;
2111
2112 case 'o': /* oppenc mode off */
2114 break;
2115
2116 case 'S': /* (s)ign in oppenc mode */
2117 e->security |= SEC_SIGN;
2118 break;
2119
2120 case 's': /* (s)ign */
2121 e->security &= ~SEC_ENCRYPT;
2122 e->security |= SEC_SIGN;
2123 break;
2124
2125 case 'w': /* encrypt (w)ith */
2126 {
2127 e->security |= SEC_ENCRYPT;
2128 do
2129 {
2130 struct Buffer *errmsg = buf_pool_get();
2131 int rc = CSR_SUCCESS;
2132 switch (mw_multi_choice(_("Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2133 // L10N: Options for: Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?
2134 _("123c")))
2135 {
2136 case 1:
2137 switch (choice = mw_multi_choice(_("(1) DES, (2) Triple-DES?"),
2138 // L10N: Options for: (1) DES, (2) Triple-DES
2139 _("12")))
2140 {
2141 case 1:
2142 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2143 "des", errmsg);
2144 break;
2145 case 2:
2146 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2147 "des3", errmsg);
2148 break;
2149 }
2150 break;
2151
2152 case 2:
2153 switch (choice = mw_multi_choice(_("(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2154 // L10N: Options for: (1) RC2-40, (2) RC2-64, (3) RC2-128
2155 _("123")))
2156 {
2157 case 1:
2158 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2159 "rc2-40", errmsg);
2160 break;
2161 case 2:
2162 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2163 "rc2-64", errmsg);
2164 break;
2165 case 3:
2166 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2167 "rc2-128", errmsg);
2168 break;
2169 }
2170 break;
2171
2172 case 3:
2173 switch (choice = mw_multi_choice(_("(1) AES128, (2) AES192, (3) AES256?"),
2174 // L10N: Options for: (1) AES128, (2) AES192, (3) AES256
2175 _("123")))
2176 {
2177 case 1:
2178 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2179 "aes128", errmsg);
2180 break;
2181 case 2:
2182 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2183 "aes192", errmsg);
2184 break;
2185 case 3:
2186 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2187 "aes256", errmsg);
2188 break;
2189 }
2190 break;
2191
2192 case 4:
2193 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with", NULL, errmsg);
2194 /* (c)lear */
2196
2197 case -1: /* Ctrl-G or Enter */
2198 choice = 0;
2199 break;
2200 }
2201
2202 if ((CSR_RESULT(rc) != CSR_SUCCESS) && !buf_is_empty(errmsg))
2203 mutt_error("%s", buf_string(errmsg));
2204
2205 buf_pool_release(&errmsg);
2206 } while (choice == -1);
2207 break;
2208 }
2209 }
2210 }
2211
2212 return e->security;
2213}
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:96
#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:537
String manipulation buffer.
Definition buffer.h:36
An SIME key.
Definition smime.h:43
char * hash
Key hash.
Definition smime.h:45
Here is the call graph for this function: