NeoMutt  2024-12-12-19-ge4b57e
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 4047 of file crypt_gpgme.c.

4048{
4049 return gpgme_send_menu(e, false);
4050}
static SecurityFlags gpgme_send_menu(struct Email *e, bool is_smime)
Show the user the encryption/signing menu.
Definition: crypt_gpgme.c:3886
+ 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 4055 of file crypt_gpgme.c.

4056{
4057 return gpgme_send_menu(e, true);
4058}
+ 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 */
2057 e->security &= ~SEC_OPPENCRYPT;
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: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:70
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition: question.c:63
#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:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
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:386
+ 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 1999 of file smime.c.

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