NeoMutt  2025-09-05-43-g177ed6
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 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 */
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:1046
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:66
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:91
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition lib.h:92
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:96
#define KEYFLAG_NO_FLAGS
No flags are set.
Definition lib.h:132
#define SEC_ENCRYPT
Email is encrypted.
Definition lib.h:84
#define WithCrypto
Definition lib.h:122
#define SEC_SIGN
Email is signed.
Definition lib.h:85
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:43
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
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 2002 of file smime.c.

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