NeoMutt  2025-12-11-276-g10b23b
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 4045 of file crypt_gpgme.c.

4046{
4047 return gpgme_send_menu(e, false);
4048}
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 4053 of file crypt_gpgme.c.

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

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

2001{
2002 struct SmimeKey *key = NULL;
2003 const char *prompt = NULL;
2004 const char *letters = NULL;
2005 const char *choices = NULL;
2006 int choice;
2007
2009 return e->security;
2010
2012
2013 /* Opportunistic encrypt is controlling encryption.
2014 * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
2015 * letter choices for those. */
2016 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
2017 if (c_crypt_opportunistic_encrypt && (e->security & SEC_OPPENCRYPT))
2018 {
2019 /* L10N: S/MIME options (opportunistic encryption is on) */
2020 prompt = _("S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2021 /* L10N: S/MIME options (opportunistic encryption is on) */
2022 letters = _("swaco");
2023 choices = "SwaCo";
2024 }
2025 else if (c_crypt_opportunistic_encrypt)
2026 {
2027 /* Opportunistic encryption option is set, but is toggled off
2028 * for this message. */
2029 /* L10N: S/MIME options (opportunistic encryption is off) */
2030 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2031 /* L10N: S/MIME options (opportunistic encryption is off) */
2032 letters = _("eswabco");
2033 choices = "eswabcO";
2034 }
2035 else
2036 {
2037 /* Opportunistic encryption is unset */
2038 /* L10N: S/MIME options */
2039 prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2040 /* L10N: S/MIME options */
2041 letters = _("eswabc");
2042 choices = "eswabc";
2043 }
2044
2045 choice = mw_multi_choice(prompt, letters);
2046 if (choice > 0)
2047 {
2048 switch (choices[choice - 1])
2049 {
2050 case 'a': /* sign (a)s */
2051 key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, false);
2052 if (key)
2053 {
2054 cs_subset_str_string_set(NeoMutt->sub, "smime_sign_as", key->hash, NULL);
2055 smime_key_free(&key);
2056
2057 e->security |= SEC_SIGN;
2058
2059 /* probably need a different passphrase */
2061 }
2062
2063 break;
2064
2065 case 'b': /* (b)oth */
2066 e->security |= (SEC_ENCRYPT | SEC_SIGN);
2067 break;
2068
2069 case 'c': /* (c)lear */
2070 e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2071 break;
2072
2073 case 'C':
2074 e->security &= ~SEC_SIGN;
2075 break;
2076
2077 case 'e': /* (e)ncrypt */
2078 e->security |= SEC_ENCRYPT;
2079 e->security &= ~SEC_SIGN;
2080 break;
2081
2082 case 'O': /* oppenc mode on */
2085 break;
2086
2087 case 'o': /* oppenc mode off */
2089 break;
2090
2091 case 'S': /* (s)ign in oppenc mode */
2092 e->security |= SEC_SIGN;
2093 break;
2094
2095 case 's': /* (s)ign */
2096 e->security &= ~SEC_ENCRYPT;
2097 e->security |= SEC_SIGN;
2098 break;
2099
2100 case 'w': /* encrypt (w)ith */
2101 {
2102 e->security |= SEC_ENCRYPT;
2103 do
2104 {
2105 struct Buffer *errmsg = buf_pool_get();
2106 int rc = CSR_SUCCESS;
2107 switch (mw_multi_choice(_("Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2108 // L10N: Options for: Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?
2109 _("123c")))
2110 {
2111 case 1:
2112 switch (choice = mw_multi_choice(_("(1) DES, (2) Triple-DES?"),
2113 // L10N: Options for: (1) DES, (2) Triple-DES
2114 _("12")))
2115 {
2116 case 1:
2117 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2118 "des", errmsg);
2119 break;
2120 case 2:
2121 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2122 "des3", errmsg);
2123 break;
2124 }
2125 break;
2126
2127 case 2:
2128 switch (choice = mw_multi_choice(_("(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2129 // L10N: Options for: (1) RC2-40, (2) RC2-64, (3) RC2-128
2130 _("123")))
2131 {
2132 case 1:
2133 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2134 "rc2-40", errmsg);
2135 break;
2136 case 2:
2137 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2138 "rc2-64", errmsg);
2139 break;
2140 case 3:
2141 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2142 "rc2-128", errmsg);
2143 break;
2144 }
2145 break;
2146
2147 case 3:
2148 switch (choice = mw_multi_choice(_("(1) AES128, (2) AES192, (3) AES256?"),
2149 // L10N: Options for: (1) AES128, (2) AES192, (3) AES256
2150 _("123")))
2151 {
2152 case 1:
2153 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2154 "aes128", errmsg);
2155 break;
2156 case 2:
2157 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2158 "aes192", errmsg);
2159 break;
2160 case 3:
2161 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2162 "aes256", errmsg);
2163 break;
2164 }
2165 break;
2166
2167 case 4:
2168 rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with", NULL, errmsg);
2169 /* (c)lear */
2171
2172 case -1: /* Ctrl-G or Enter */
2173 choice = 0;
2174 break;
2175 }
2176
2177 if ((CSR_RESULT(rc) != CSR_SUCCESS) && !buf_is_empty(errmsg))
2178 mutt_error("%s", buf_string(errmsg));
2179
2180 buf_pool_release(&errmsg);
2181 } while (choice == -1);
2182 break;
2183 }
2184 }
2185 }
2186
2187 return e->security;
2188}
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)
Extract the result code from CSR_* flags.
Definition set.h:52
#define CSR_SUCCESS
Action completed successfully.
Definition set.h:33
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition cryptglue.c:412
#define mutt_error(...)
Definition logging2.h:94
#define FALLTHROUGH
Definition lib.h:117
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition lib.h:99
#define KEYFLAG_CANSIGN
Key is suitable for signing.
Definition lib.h:135
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:100
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:541
String manipulation buffer.
Definition buffer.h:36
An SIME key.
Definition smime.h:42
char * hash
Key hash.
Definition smime.h:44
+ Here is the call graph for this function: