NeoMutt  2025-12-11-769-g906513
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 4063 of file crypt_gpgme.c.

4064{
4065 return gpgme_send_menu(e, false);
4066}
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 4071 of file crypt_gpgme.c.

4072{
4073 return gpgme_send_menu(e, true);
4074}
+ 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 1902 of file pgp.c.

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

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