NeoMutt  2025-12-11-949-g4870ee
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 4062 of file crypt_gpgme.c.

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

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

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