NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
DOXYGEN
ncrypt.h File Reference

API for encryption/signing of emails. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
+ Include dependency graph for ncrypt.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SEC_NO_FLAGS   0
 No flags are set. More...
 
#define SEC_ENCRYPT   (1 << 0)
 Email is encrypted. More...
 
#define SEC_SIGN   (1 << 1)
 Email is signed. More...
 
#define SEC_GOODSIGN   (1 << 2)
 Email has a valid signature. More...
 
#define SEC_BADSIGN   (1 << 3)
 Email has a bad signature. More...
 
#define SEC_PARTSIGN   (1 << 4)
 Not all parts of the email is signed. More...
 
#define SEC_SIGNOPAQUE   (1 << 5)
 Email has an opaque signature (encrypted) More...
 
#define SEC_KEYBLOCK   (1 << 6)
 Email has a key attached. More...
 
#define SEC_INLINE   (1 << 7)
 Email has an inline signature. More...
 
#define SEC_OPPENCRYPT   (1 << 8)
 Opportunistic encrypt mode. More...
 
#define SEC_AUTOCRYPT   (1 << 9)
 Message will be, or was Autocrypt encrypt+signed. More...
 
#define SEC_AUTOCRYPT_OVERRIDE   (1 << 10)
 Indicates manual set/unset of encryption. More...
 
#define APPLICATION_PGP   (1 << 11)
 Use PGP to encrypt/sign. More...
 
#define APPLICATION_SMIME   (1 << 12)
 Use SMIME to encrypt/sign. More...
 
#define PGP_TRADITIONAL_CHECKED   (1 << 13)
 Email has a traditional (inline) signature. More...
 
#define SEC_ALL_FLAGS   ((1 << 14) - 1)
 
#define PGP_ENCRYPT   (APPLICATION_PGP | SEC_ENCRYPT)
 
#define PGP_SIGN   (APPLICATION_PGP | SEC_SIGN)
 
#define PGP_GOODSIGN   (APPLICATION_PGP | SEC_GOODSIGN)
 
#define PGP_KEY   (APPLICATION_PGP | SEC_KEYBLOCK)
 
#define PGP_INLINE   (APPLICATION_PGP | SEC_INLINE)
 
#define SMIME_ENCRYPT   (APPLICATION_SMIME | SEC_ENCRYPT)
 
#define SMIME_SIGN   (APPLICATION_SMIME | SEC_SIGN)
 
#define SMIME_GOODSIGN   (APPLICATION_SMIME | SEC_GOODSIGN)
 
#define SMIME_BADSIGN   (APPLICATION_SMIME | SEC_BADSIGN)
 
#define SMIME_OPAQUE   (APPLICATION_SMIME | SEC_SIGNOPAQUE)
 
#define WithCrypto   (APPLICATION_PGP | APPLICATION_SMIME)
 
#define KEYFLAG_NO_FLAGS   0
 No flags are set. More...
 
#define KEYFLAG_CANSIGN   (1 << 0)
 Key is suitable for signing. More...
 
#define KEYFLAG_CANENCRYPT   (1 << 1)
 Key is suitable for encryption. More...
 
#define KEYFLAG_ISX509   (1 << 2)
 Key is an X.509 key. More...
 
#define KEYFLAG_SECRET   (1 << 7)
 Key is a secret key. More...
 
#define KEYFLAG_EXPIRED   (1 << 8)
 Key is expired. More...
 
#define KEYFLAG_REVOKED   (1 << 9)
 Key is revoked. More...
 
#define KEYFLAG_DISABLED   (1 << 10)
 Key is marked disabled. More...
 
#define KEYFLAG_SUBKEY   (1 << 11)
 Key is a subkey. More...
 
#define KEYFLAG_CRITICAL   (1 << 12)
 Key is marked critical. More...
 
#define KEYFLAG_PREFER_ENCRYPTION   (1 << 13)
 Key's owner prefers encryption. More...
 
#define KEYFLAG_PREFER_SIGNING   (1 << 14)
 Key's owner prefers signing. More...
 
#define KEYFLAG_CANTUSE   (KEYFLAG_DISABLED | KEYFLAG_REVOKED | KEYFLAG_EXPIRED)
 
#define KEYFLAG_RESTRICTIONS   (KEYFLAG_CANTUSE | KEYFLAG_CRITICAL)
 
#define KEYFLAG_ABILITIES   (KEYFLAG_CANSIGN | KEYFLAG_CANENCRYPT | KEYFLAG_PREFER_ENCRYPTION | KEYFLAG_PREFER_SIGNING)
 

Typedefs

typedef uint16_t SecurityFlags
 Flags, e.g. SEC_ENCRYPT. More...
 
typedef uint16_t KeyFlags
 Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN. More...
 

Functions

void crypt_extract_keys_from_messages (struct Mailbox *m, struct EmailList *el)
 Extract keys from a message. More...
 
void crypt_forget_passphrase (void)
 Forget a passphrase and display a message. More...
 
int crypt_get_keys (struct Email *e, char **keylist, bool oppenc_mode)
 Check we have all the keys we need. More...
 
void crypt_opportunistic_encrypt (struct Email *e)
 Can all recipients be determined. More...
 
SecurityFlags crypt_query (struct Body *m)
 Check out the type of encryption used. More...
 
bool crypt_valid_passphrase (SecurityFlags flags)
 Check that we have a usable passphrase, ask if not. More...
 
SecurityFlags mutt_is_application_pgp (struct Body *m)
 Does the message use PGP? More...
 
SecurityFlags mutt_is_application_smime (struct Body *m)
 Does the message use S/MIME? More...
 
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted (struct Body *b)
 Check for malformed layout. More...
 
SecurityFlags mutt_is_multipart_encrypted (struct Body *b)
 Does the message have encrypted parts? More...
 
SecurityFlags mutt_is_multipart_signed (struct Body *b)
 Is a message signed? More...
 
int mutt_is_valid_multipart_pgp_encrypted (struct Body *b)
 Is this a valid multi-part encrypted message? More...
 
int mutt_protect (struct Email *e, char *keylist, bool postpone)
 Encrypt and/or sign a message. More...
 
int mutt_protected_headers_handler (struct Body *m, struct State *s)
 Process a protected header - Implements handler_t. More...
 
bool mutt_should_hide_protected_subject (struct Email *e)
 Should NeoMutt hide the protected subject? More...
 
int mutt_signed_handler (struct Body *a, struct State *s)
 Verify a "multipart/signed" body - Implements handler_t. More...
 
bool crypt_has_module_backend (SecurityFlags type)
 Is there a crypto backend for a given type? More...
 
void crypt_init (void)
 Initialise the crypto backends. More...
 
void crypt_invoke_message (SecurityFlags type)
 Display an informative message. More...
 
int crypt_pgp_application_handler (struct Body *m, struct State *s)
 Wrapper for CryptModuleSpecs::application_handler() More...
 
int crypt_pgp_check_traditional (FILE *fp, struct Body *b, bool just_one)
 Wrapper for CryptModuleSpecs::pgp_check_traditional() More...
 
int crypt_pgp_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
 Wrapper for CryptModuleSpecs::decrypt_mime() More...
 
int crypt_pgp_encrypted_handler (struct Body *a, struct State *s)
 Wrapper for CryptModuleSpecs::encrypted_handler() More...
 
void crypt_pgp_extract_key_from_attachment (FILE *fp, struct Body *top)
 Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment() More...
 
void crypt_pgp_invoke_getkeys (struct Address *addr)
 Wrapper for CryptModuleSpecs::pgp_invoke_getkeys() More...
 
struct Bodycrypt_pgp_make_key_attachment (void)
 Wrapper for CryptModuleSpecs::pgp_make_key_attachment() More...
 
int crypt_pgp_send_menu (struct Email *e)
 Wrapper for CryptModuleSpecs::send_menu() More...
 
int crypt_smime_application_handler (struct Body *m, struct State *s)
 Wrapper for CryptModuleSpecs::application_handler() More...
 
int crypt_smime_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
 Wrapper for CryptModuleSpecs::decrypt_mime() More...
 
void crypt_smime_getkeys (struct Envelope *env)
 Wrapper for CryptModuleSpecs::smime_getkeys() More...
 
int crypt_smime_send_menu (struct Email *e)
 Wrapper for CryptModuleSpecs::send_menu() More...
 
int crypt_smime_verify_sender (struct Mailbox *m, struct Email *e)
 Wrapper for CryptModuleSpecs::smime_verify_sender() More...
 
void crypto_module_free (void)
 Clean up the crypto modules. More...
 

Variables

bool C_CryptTimestamp
 Config: Add a timestamp to PGP or SMIME output to prevent spoofing. More...
 
unsigned char C_PgpEncryptSelf
 Deprecated, see C_PgpSelfEncrypt. More...
 
unsigned char C_PgpMimeAuto
 Config: Prompt the user to use MIME if inline PGP fails. More...
 
bool C_PgpRetainableSigs
 Config: Create nested multipart/signed or encrypted messages. More...
 
bool C_PgpSelfEncrypt
 Config: Encrypted messages will also be encrypted to C_PgpDefaultKey too. More...
 
bool C_PgpStrictEnc
 Config: Encode PGP signed messages with quoted-printable (don't unset) More...
 
unsigned char C_SmimeEncryptSelf
 Deprecated, see C_SmimeSelfEncrypt. More...
 
bool C_SmimeSelfEncrypt
 Config: Encrypted messages will also be encrypt to C_SmimeDefaultKey too. More...
 
bool C_CryptUseGpgme
 Config: Use GPGME crypto backend. More...
 
bool C_PgpCheckExit
 Config: Check the exit code of PGP subprocess. More...
 
bool C_PgpCheckGpgDecryptStatusFd
 Config: File descriptor used for status info. More...
 
struct RegexC_PgpDecryptionOkay
 Config: Text indicating a successful decryption. More...
 
struct RegexC_PgpGoodSign
 Config: Text indicating a good signature. More...
 
long C_PgpTimeout
 Config: Time in seconds to cache a passphrase. More...
 
bool C_PgpUseGpgAgent
 Config: Use a PGP agent for caching passwords. More...
 
char * C_PgpClearsignCommand
 Config: (pgp) External command to inline-sign a message. More...
 
char * C_PgpDecodeCommand
 Config: (pgp) External command to decode a PGP attachment. More...
 
char * C_PgpDecryptCommand
 Config: (pgp) External command to decrypt a PGP message. More...
 
char * C_PgpEncryptOnlyCommand
 Config: (pgp) External command to encrypt, but not sign a message. More...
 
char * C_PgpEncryptSignCommand
 Config: (pgp) External command to encrypt and sign a message. More...
 
char * C_PgpExportCommand
 Config: (pgp) External command to export a public key from the user's keyring. More...
 
char * C_PgpGetkeysCommand
 Config: (pgp) External command to download a key for an email address. More...
 
char * C_PgpImportCommand
 Config: (pgp) External command to import a key into the user's keyring. More...
 
char * C_PgpListPubringCommand
 Config: (pgp) External command to list the public keys in a user's keyring. More...
 
char * C_PgpListSecringCommand
 Config: (pgp) External command to list the private keys in a user's keyring. More...
 
char * C_PgpSignCommand
 Config: (pgp) External command to create a detached PGP signature. More...
 
char * C_PgpVerifyCommand
 Config: (pgp) External command to verify PGP signatures. More...
 
char * C_PgpVerifyKeyCommand
 Config: (pgp) External command to verify key information. More...
 
bool C_SmimeAskCertLabel
 Config: Prompt the user for a label for SMIME certificates. More...
 
char * C_SmimeCaLocation
 Config: File containing trusted certificates. More...
 
char * C_SmimeCertificates
 Config: File containing user's public certificates. More...
 
char * C_SmimeDecryptCommand
 Config: (smime) External command to decrypt an SMIME message. More...
 
bool C_SmimeDecryptUseDefaultKey
 Config: Use the default key for decryption. More...
 
char * C_SmimeEncryptCommand
 Config: (smime) External command to encrypt a message. More...
 
char * C_SmimeGetCertCommand
 Config: (smime) External command to extract a certificate from a message. More...
 
char * C_SmimeGetCertEmailCommand
 Config: (smime) External command to get a certificate for an email. More...
 
char * C_SmimeGetSignerCertCommand
 Config: (smime) External command to extract a certificate from an email. More...
 
char * C_SmimeImportCertCommand
 Config: (smime) External command to import a certificate. More...
 
char * C_SmimeKeys
 Config: File containing user's private certificates. More...
 
char * C_SmimePk7outCommand
 Config: (smime) External command to extract a public certificate. More...
 
char * C_SmimeSignCommand
 Config: (smime) External command to sign a message. More...
 
char * C_SmimeSignDigestAlg
 Config: Digest algorithm. More...
 
long C_SmimeTimeout
 Config: Time in seconds to cache a passphrase. More...
 
char * C_SmimeVerifyCommand
 Config: (smime) External command to verify a signed message. More...
 
char * C_SmimeVerifyOpaqueCommand
 Config: (smime) External command to verify a signature. More...
 

Detailed Description

API for encryption/signing of emails.

Authors
  • Werner Koch
  • g10code GmbH
  • Pietro Cerutti

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file ncrypt.h.

Macro Definition Documentation

◆ SEC_NO_FLAGS

#define SEC_NO_FLAGS   0

No flags are set.

Definition at line 121 of file ncrypt.h.

◆ SEC_ENCRYPT

#define SEC_ENCRYPT   (1 << 0)

Email is encrypted.

Definition at line 122 of file ncrypt.h.

◆ SEC_SIGN

#define SEC_SIGN   (1 << 1)

Email is signed.

Definition at line 123 of file ncrypt.h.

◆ SEC_GOODSIGN

#define SEC_GOODSIGN   (1 << 2)

Email has a valid signature.

Definition at line 124 of file ncrypt.h.

◆ SEC_BADSIGN

#define SEC_BADSIGN   (1 << 3)

Email has a bad signature.

Definition at line 125 of file ncrypt.h.

◆ SEC_PARTSIGN

#define SEC_PARTSIGN   (1 << 4)

Not all parts of the email is signed.

Definition at line 126 of file ncrypt.h.

◆ SEC_SIGNOPAQUE

#define SEC_SIGNOPAQUE   (1 << 5)

Email has an opaque signature (encrypted)

Definition at line 127 of file ncrypt.h.

◆ SEC_KEYBLOCK

#define SEC_KEYBLOCK   (1 << 6)

Email has a key attached.

Definition at line 128 of file ncrypt.h.

◆ SEC_INLINE

#define SEC_INLINE   (1 << 7)

Email has an inline signature.

Definition at line 129 of file ncrypt.h.

◆ SEC_OPPENCRYPT

#define SEC_OPPENCRYPT   (1 << 8)

Opportunistic encrypt mode.

Definition at line 130 of file ncrypt.h.

◆ SEC_AUTOCRYPT

#define SEC_AUTOCRYPT   (1 << 9)

Message will be, or was Autocrypt encrypt+signed.

Definition at line 131 of file ncrypt.h.

◆ SEC_AUTOCRYPT_OVERRIDE

#define SEC_AUTOCRYPT_OVERRIDE   (1 << 10)

Indicates manual set/unset of encryption.

Definition at line 132 of file ncrypt.h.

◆ APPLICATION_PGP

#define APPLICATION_PGP   (1 << 11)

Use PGP to encrypt/sign.

Definition at line 134 of file ncrypt.h.

◆ APPLICATION_SMIME

#define APPLICATION_SMIME   (1 << 12)

Use SMIME to encrypt/sign.

Definition at line 135 of file ncrypt.h.

◆ PGP_TRADITIONAL_CHECKED

#define PGP_TRADITIONAL_CHECKED   (1 << 13)

Email has a traditional (inline) signature.

Definition at line 136 of file ncrypt.h.

◆ SEC_ALL_FLAGS

#define SEC_ALL_FLAGS   ((1 << 14) - 1)

Definition at line 138 of file ncrypt.h.

◆ PGP_ENCRYPT

#define PGP_ENCRYPT   (APPLICATION_PGP | SEC_ENCRYPT)

Definition at line 140 of file ncrypt.h.

◆ PGP_SIGN

#define PGP_SIGN   (APPLICATION_PGP | SEC_SIGN)

Definition at line 141 of file ncrypt.h.

◆ PGP_GOODSIGN

#define PGP_GOODSIGN   (APPLICATION_PGP | SEC_GOODSIGN)

Definition at line 142 of file ncrypt.h.

◆ PGP_KEY

#define PGP_KEY   (APPLICATION_PGP | SEC_KEYBLOCK)

Definition at line 143 of file ncrypt.h.

◆ PGP_INLINE

#define PGP_INLINE   (APPLICATION_PGP | SEC_INLINE)

Definition at line 144 of file ncrypt.h.

◆ SMIME_ENCRYPT

#define SMIME_ENCRYPT   (APPLICATION_SMIME | SEC_ENCRYPT)

Definition at line 146 of file ncrypt.h.

◆ SMIME_SIGN

#define SMIME_SIGN   (APPLICATION_SMIME | SEC_SIGN)

Definition at line 147 of file ncrypt.h.

◆ SMIME_GOODSIGN

#define SMIME_GOODSIGN   (APPLICATION_SMIME | SEC_GOODSIGN)

Definition at line 148 of file ncrypt.h.

◆ SMIME_BADSIGN

#define SMIME_BADSIGN   (APPLICATION_SMIME | SEC_BADSIGN)

Definition at line 149 of file ncrypt.h.

◆ SMIME_OPAQUE

#define SMIME_OPAQUE   (APPLICATION_SMIME | SEC_SIGNOPAQUE)

Definition at line 150 of file ncrypt.h.

◆ WithCrypto

#define WithCrypto   (APPLICATION_PGP | APPLICATION_SMIME)

Definition at line 160 of file ncrypt.h.

◆ KEYFLAG_NO_FLAGS

#define KEYFLAG_NO_FLAGS   0

No flags are set.

Definition at line 170 of file ncrypt.h.

◆ KEYFLAG_CANSIGN

#define KEYFLAG_CANSIGN   (1 << 0)

Key is suitable for signing.

Definition at line 171 of file ncrypt.h.

◆ KEYFLAG_CANENCRYPT

#define KEYFLAG_CANENCRYPT   (1 << 1)

Key is suitable for encryption.

Definition at line 172 of file ncrypt.h.

◆ KEYFLAG_ISX509

#define KEYFLAG_ISX509   (1 << 2)

Key is an X.509 key.

Definition at line 173 of file ncrypt.h.

◆ KEYFLAG_SECRET

#define KEYFLAG_SECRET   (1 << 7)

Key is a secret key.

Definition at line 174 of file ncrypt.h.

◆ KEYFLAG_EXPIRED

#define KEYFLAG_EXPIRED   (1 << 8)

Key is expired.

Definition at line 175 of file ncrypt.h.

◆ KEYFLAG_REVOKED

#define KEYFLAG_REVOKED   (1 << 9)

Key is revoked.

Definition at line 176 of file ncrypt.h.

◆ KEYFLAG_DISABLED

#define KEYFLAG_DISABLED   (1 << 10)

Key is marked disabled.

Definition at line 177 of file ncrypt.h.

◆ KEYFLAG_SUBKEY

#define KEYFLAG_SUBKEY   (1 << 11)

Key is a subkey.

Definition at line 178 of file ncrypt.h.

◆ KEYFLAG_CRITICAL

#define KEYFLAG_CRITICAL   (1 << 12)

Key is marked critical.

Definition at line 179 of file ncrypt.h.

◆ KEYFLAG_PREFER_ENCRYPTION

#define KEYFLAG_PREFER_ENCRYPTION   (1 << 13)

Key's owner prefers encryption.

Definition at line 180 of file ncrypt.h.

◆ KEYFLAG_PREFER_SIGNING

#define KEYFLAG_PREFER_SIGNING   (1 << 14)

Key's owner prefers signing.

Definition at line 181 of file ncrypt.h.

◆ KEYFLAG_CANTUSE

#define KEYFLAG_CANTUSE   (KEYFLAG_DISABLED | KEYFLAG_REVOKED | KEYFLAG_EXPIRED)

Definition at line 183 of file ncrypt.h.

◆ KEYFLAG_RESTRICTIONS

#define KEYFLAG_RESTRICTIONS   (KEYFLAG_CANTUSE | KEYFLAG_CRITICAL)

Definition at line 184 of file ncrypt.h.

◆ KEYFLAG_ABILITIES

Definition at line 186 of file ncrypt.h.

Typedef Documentation

◆ SecurityFlags

typedef uint16_t SecurityFlags

Flags, e.g. SEC_ENCRYPT.

Definition at line 120 of file ncrypt.h.

◆ KeyFlags

typedef uint16_t KeyFlags

Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.

Definition at line 169 of file ncrypt.h.

Function Documentation

◆ crypt_extract_keys_from_messages()

void crypt_extract_keys_from_messages ( struct Mailbox m,
struct EmailList *  el 
)

Extract keys from a message.

Parameters
mMailbox
elList of Emails to process

The extracted keys will be added to the user's keyring.

Definition at line 855 of file crypt.c.

856 {
857  if (!WithCrypto)
858  return;
859 
860  char tempfname[PATH_MAX];
861 
862  mutt_mktemp(tempfname, sizeof(tempfname));
863  FILE *fp_out = mutt_file_fopen(tempfname, "w");
864  if (!fp_out)
865  {
866  mutt_perror(tempfname);
867  return;
868  }
869 
871  OptDontHandlePgpKeys = true;
872 
873  struct EmailNode *en = NULL;
874  STAILQ_FOREACH(en, el, entries)
875  {
876  struct Email *e = en->email;
877 
880  {
881  mutt_file_fclose(&fp_out);
882  break;
883  }
884 
885  if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
886  {
888  fflush(fp_out);
889 
890  mutt_endwin();
891  puts(_("Trying to extract PGP keys...\n"));
892  crypt_pgp_invoke_import(tempfname);
893  }
894 
895  if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME))
896  {
897  if (e->security & SEC_ENCRYPT)
898  {
900  CH_NO_FLAGS);
901  }
902  else
904  fflush(fp_out);
905 
906  char *mbox = NULL;
907  if (!TAILQ_EMPTY(&e->env->from))
908  {
910  mbox = TAILQ_FIRST(&e->env->from)->mailbox;
911  }
912  else if (!TAILQ_EMPTY(&e->env->sender))
913  {
915  mbox = TAILQ_FIRST(&e->env->sender)->mailbox;
916  }
917  if (mbox)
918  {
919  mutt_endwin();
920  puts(_("Trying to extract S/MIME certificates..."));
921  crypt_smime_invoke_import(tempfname, mbox);
922  }
923  }
924 
925  rewind(fp_out);
926  }
927 
928  mutt_file_fclose(&fp_out);
929  if (isendwin())
931 
932  mutt_file_unlink(tempfname);
933 
934  if (WithCrypto & APPLICATION_PGP)
935  OptDontHandlePgpKeys = false;
936 }
#define MUTT_CM_DECODE_CRYPT
Definition: copy.h:47
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:304
The envelope/body of an email.
Definition: email.h:39
#define TAILQ_FIRST(head)
Definition: queue.h:717
#define mutt_perror(...)
Definition: logging.h:85
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:192
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Mailbox.
Definition: copy.c:806
#define _(a)
Definition: message.h:28
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:150
struct Envelope * env
Envelope information.
Definition: email.h:91
WHERE bool OptDontHandlePgpKeys
(pseudo) used to extract PGP keys
Definition: options.h:34
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
void crypt_pgp_invoke_import(const char *fname)
Wrapper for CryptModuleSpecs::pgp_invoke_import()
Definition: cryptglue.c:353
#define PATH_MAX
Definition: mutt.h:52
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
Definition: copy.h:45
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:532
struct Email * email
Email in the list.
Definition: email.h:122
struct AddressList sender
Email&#39;s sender.
Definition: envelope.h:61
List of Emails.
Definition: email.h:120
void crypt_smime_invoke_import(char *infile, char *mailbox)
Wrapper for CryptModuleSpecs::smime_invoke_import()
Definition: cryptglue.c:508
#define TAILQ_EMPTY(head)
Definition: queue.h:715
#define MUTT_CM_NOHEADER
Don&#39;t copy the message header.
Definition: copy.h:35
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:583
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_forget_passphrase()

void crypt_forget_passphrase ( void  )

Forget a passphrase and display a message.

Definition at line 105 of file crypt.c.

106 {
109 
112 
113  if (WithCrypto)
114  {
115  /* L10N: Due to the implementation details (e.g. some passwords are managed
116  by gpg-agent) we can't know whether we forgot zero, 1, 12, ...
117  passwords. So in English we use "Passphrases". Your language might
118  have other means to express this. */
119  mutt_message(_("Passphrases forgotten"));
120  }
121 }
#define mutt_message(...)
Definition: logging.h:83
void crypt_pgp_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:179
#define _(a)
Definition: message.h:28
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:402
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_get_keys()

int crypt_get_keys ( struct Email e,
char **  keylist,
bool  oppenc_mode 
)

Check we have all the keys we need.

Parameters
[in]eEmail with addresses to match
[out]keylistKeys needed
[in]oppenc_modeIf true, use opportunistic encryption
Return values
0Success
-1Error

Do a quick check to make sure that we can find all of the encryption keys if the user has requested this service. Return the list of keys in KEYLIST. If oppenc_mode is true, only keys that can be determined without prompting will be used.

Definition at line 952 of file crypt.c.

953 {
954  if (!WithCrypto)
955  return 0;
956 
957  struct AddressList addrlist = TAILQ_HEAD_INITIALIZER(addrlist);
958  const char *fqdn = mutt_fqdn(true);
959  char *self_encrypt = NULL;
960 
961  /* Do a quick check to make sure that we can find all of the encryption
962  * keys if the user has requested this service. */
963 
964  *keylist = NULL;
965 
966 #ifdef USE_AUTOCRYPT
967  if (!oppenc_mode && (e->security & SEC_AUTOCRYPT))
968  {
970  return -1;
971  return 0;
972  }
973 #endif
974 
976  OptPgpCheckTrust = true;
977 
978  mutt_addrlist_copy(&addrlist, &e->env->to, false);
979  mutt_addrlist_copy(&addrlist, &e->env->cc, false);
980  mutt_addrlist_copy(&addrlist, &e->env->bcc, false);
981  mutt_addrlist_qualify(&addrlist, fqdn);
982  mutt_addrlist_dedupe(&addrlist);
983 
984  if (oppenc_mode || (e->security & SEC_ENCRYPT))
985  {
986  if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
987  {
988  *keylist = crypt_pgp_find_keys(&addrlist, oppenc_mode);
989  if (!*keylist)
990  {
991  mutt_addrlist_clear(&addrlist);
992  return -1;
993  }
994  OptPgpCheckTrust = false;
996  self_encrypt = C_PgpDefaultKey;
997  }
998  if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME))
999  {
1000  *keylist = crypt_smime_find_keys(&addrlist, oppenc_mode);
1001  if (!*keylist)
1002  {
1003  mutt_addrlist_clear(&addrlist);
1004  return -1;
1005  }
1007  self_encrypt = C_SmimeDefaultKey;
1008  }
1009  }
1010 
1011  if (!oppenc_mode && self_encrypt)
1012  {
1013  const size_t keylist_size = mutt_str_strlen(*keylist);
1014  mutt_mem_realloc(keylist, keylist_size + mutt_str_strlen(self_encrypt) + 2);
1015  sprintf(*keylist + keylist_size, " %s", self_encrypt);
1016  }
1017 
1018  mutt_addrlist_clear(&addrlist);
1019 
1020  return 0;
1021 }
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
char * crypt_smime_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
Definition: cryptglue.c:475
WHERE char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
Definition: globals.h:171
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1381
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:727
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
bool C_PgpSelfEncrypt
Config: Encrypted messages will also be encrypted to C_PgpDefaultKey too.
Definition: crypt.c:72
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1318
unsigned char C_PgpEncryptSelf
Deprecated, see C_PgpSelfEncrypt.
Definition: crypt.c:69
struct Envelope * env
Envelope information.
Definition: email.h:91
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
bool C_SmimeSelfEncrypt
Config: Encrypted messages will also be encrypt to C_SmimeDefaultKey too.
Definition: crypt.c:75
Do no use Autocrypt.
Definition: autocrypt.h:104
unsigned char C_SmimeEncryptSelf
Deprecated, see C_SmimeSelfEncrypt.
Definition: crypt.c:74
WHERE bool OptPgpCheckTrust
(pseudo) used by pgp_select_key ()
Definition: options.h:47
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
const char * mutt_fqdn(bool may_hide_host)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:2527
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:640
char * crypt_pgp_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
Definition: cryptglue.c:306
enum AutocryptRec mutt_autocrypt_ui_recommendation(struct Email *e, char **keylist)
Get the recommended action for an Email.
Definition: autocrypt.c:562
WHERE char * C_PgpDefaultKey
Config: Default key to use for PGP operations.
Definition: globals.h:167
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:631
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_opportunistic_encrypt()

void crypt_opportunistic_encrypt ( struct Email e)

Can all recipients be determined.

Parameters
eEmail

Check if all recipients keys can be automatically determined. Enable encryption if they can, otherwise disable encryption.

Definition at line 1030 of file crypt.c.

1031 {
1032  if (!WithCrypto)
1033  return;
1034 
1036  return;
1037 
1038  char *pgpkeylist = NULL;
1039 
1040  crypt_get_keys(e, &pgpkeylist, 1);
1041  if (pgpkeylist)
1042  {
1043  e->security |= SEC_ENCRYPT;
1044  FREE(&pgpkeylist);
1045  }
1046  else
1047  {
1048  e->security &= ~SEC_ENCRYPT;
1049  }
1050 }
int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode)
Check we have all the keys we need.
Definition: crypt.c:952
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
WHERE bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient&#39;s key is available.
Definition: globals.h:280
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: ncrypt.h:130
#define FREE(x)
Definition: memory.h:40
#define WithCrypto
Definition: ncrypt.h:160
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_query()

SecurityFlags crypt_query ( struct Body m)

Check out the type of encryption used.

Parameters
mBody of email
Return values
numFlags, see SecurityFlags
0Error (SEC_NO_FLAGS)

Set the cached status values if there are any.

Definition at line 696 of file crypt.c.

697 {
698  if (!WithCrypto || !m)
699  return SEC_NO_FLAGS;
700 
702 
703  if (m->type == TYPE_APPLICATION)
704  {
706  rc |= mutt_is_application_pgp(m);
707 
709  {
710  rc |= mutt_is_application_smime(m);
711  if (rc && m->goodsig)
712  rc |= SEC_GOODSIGN;
713  if (rc && m->badsig)
714  rc |= SEC_BADSIGN;
715  }
716  }
717  else if (((WithCrypto & APPLICATION_PGP) != 0) && (m->type == TYPE_TEXT))
718  {
719  rc |= mutt_is_application_pgp(m);
720  if (rc && m->goodsig)
721  rc |= SEC_GOODSIGN;
722  }
723 
724  if (m->type == TYPE_MULTIPART)
725  {
727  rc |= mutt_is_multipart_signed(m);
729 
730  if (rc && m->goodsig)
731  rc |= SEC_GOODSIGN;
732 #ifdef USE_AUTOCRYPT
733  if (rc && m->is_autocrypt)
734  rc |= SEC_AUTOCRYPT;
735 #endif
736  }
737 
738  if ((m->type == TYPE_MULTIPART) || (m->type == TYPE_MESSAGE))
739  {
740  SecurityFlags u = m->parts ? SEC_ALL_FLAGS : SEC_NO_FLAGS; /* Bits set in all parts */
741  SecurityFlags w = SEC_NO_FLAGS; /* Bits set in any part */
742 
743  for (struct Body *b = m->parts; b; b = b->next)
744  {
745  const SecurityFlags v = crypt_query(b);
746  u &= v;
747  w |= v;
748  }
749  rc |= u | (w & ~SEC_GOODSIGN);
750 
751  if ((w & SEC_GOODSIGN) && !(u & SEC_GOODSIGN))
752  rc |= SEC_PARTSIGN;
753  }
754 
755  return rc;
756 }
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
Definition: body.h:85
struct Body * next
next attachment in the list
Definition: body.h:53
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: ncrypt.h:126
The body of an email.
Definition: body.h:34
#define SEC_BADSIGN
Email has a bad signature.
Definition: ncrypt.h:125
#define SEC_ALL_FLAGS
Definition: ncrypt.h:138
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:453
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:124
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
Definition: body.h:83
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:412
bool goodsig
Good cryptographic signature.
Definition: body.h:81
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:560
Type: &#39;text/*&#39;.
Definition: mime.h:38
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:515
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:619
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Type: &#39;message/*&#39;.
Definition: mime.h:35
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: ncrypt.h:120
#define WithCrypto
Definition: ncrypt.h:160
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:696
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_valid_passphrase()

bool crypt_valid_passphrase ( SecurityFlags  flags)

Check that we have a usable passphrase, ask if not.

Parameters
flagsFlags, see SecurityFlags
Return values
trueSuccess
falseFailed

Definition at line 147 of file crypt.c.

148 {
149  bool rc = false;
150 
151 #ifndef DEBUG
152  disable_coredumps();
153 #endif
154 
155  if (((WithCrypto & APPLICATION_PGP) != 0) && (flags & APPLICATION_PGP))
157 
158  if (((WithCrypto & APPLICATION_SMIME) != 0) && (flags & APPLICATION_SMIME))
160 
161  return rc;
162 }
bool crypt_smime_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
Definition: cryptglue.c:411
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define WithCrypto
Definition: ncrypt.h:160
bool crypt_pgp_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
Definition: cryptglue.c:188
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_application_pgp()

SecurityFlags mutt_is_application_pgp ( struct Body m)

Does the message use PGP?

Parameters
mBody of email
Return values
>0Message uses PGP, e.g. PGP_ENCRYPT
0Message doesn't use PGP, (SEC_NO_FLAGS)

Definition at line 560 of file crypt.c.

561 {
563  char *p = NULL;
564 
565  if (m->type == TYPE_APPLICATION)
566  {
567  if ((mutt_str_strcasecmp(m->subtype, "pgp") == 0) ||
568  (mutt_str_strcasecmp(m->subtype, "x-pgp-message") == 0))
569  {
570  p = mutt_param_get(&m->parameter, "x-action");
571  if (p && ((mutt_str_strcasecmp(p, "sign") == 0) ||
572  (mutt_str_strcasecmp(p, "signclear") == 0)))
573  {
574  t |= PGP_SIGN;
575  }
576 
577  p = mutt_param_get(&m->parameter, "format");
578  if (p && (mutt_str_strcasecmp(p, "keys-only") == 0))
579  {
580  t |= PGP_KEY;
581  }
582 
583  if (t == SEC_NO_FLAGS)
584  t |= PGP_ENCRYPT; /* not necessarily correct, but... */
585  }
586 
587  if (mutt_str_strcasecmp(m->subtype, "pgp-signed") == 0)
588  t |= PGP_SIGN;
589 
590  if (mutt_str_strcasecmp(m->subtype, "pgp-keys") == 0)
591  t |= PGP_KEY;
592  }
593  else if ((m->type == TYPE_TEXT) && (mutt_str_strcasecmp("plain", m->subtype) == 0))
594  {
595  if (((p = mutt_param_get(&m->parameter, "x-mutt-action")) ||
596  (p = mutt_param_get(&m->parameter, "x-action")) ||
597  (p = mutt_param_get(&m->parameter, "action"))) &&
598  mutt_str_startswith(p, "pgp-sign", CASE_IGNORE))
599  {
600  t |= PGP_SIGN;
601  }
602  else if (p && mutt_str_startswith(p, "pgp-encrypt", CASE_IGNORE))
603  t |= PGP_ENCRYPT;
604  else if (p && mutt_str_startswith(p, "pgp-keys", CASE_IGNORE))
605  t |= PGP_KEY;
606  }
607  if (t)
608  t |= PGP_INLINE;
609 
610  return t;
611 }
#define PGP_INLINE
Definition: ncrypt.h:144
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
#define PGP_SIGN
Definition: ncrypt.h:141
char * subtype
content-type subtype
Definition: body.h:37
#define PGP_KEY
Definition: ncrypt.h:143
Type: &#39;text/*&#39;.
Definition: mime.h:38
Ignore case when comparing strings.
Definition: string2.h:68
unsigned int type
content-type primary type
Definition: body.h:65
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: ncrypt.h:120
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define PGP_ENCRYPT
Definition: ncrypt.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_application_smime()

SecurityFlags mutt_is_application_smime ( struct Body m)

Does the message use S/MIME?

Parameters
mBody of email
Return values
>0Message uses S/MIME, e.g. SMIME_ENCRYPT
0Message doesn't use S/MIME, (SEC_NO_FLAGS)

Definition at line 619 of file crypt.c.

620 {
621  if (!m)
622  return SEC_NO_FLAGS;
623 
624  if (((m->type & TYPE_APPLICATION) == 0) || !m->subtype)
625  return SEC_NO_FLAGS;
626 
627  char *t = NULL;
628  bool complain = false;
629  /* S/MIME MIME types don't need x- anymore, see RFC2311 */
630  if ((mutt_str_strcasecmp(m->subtype, "x-pkcs7-mime") == 0) ||
631  (mutt_str_strcasecmp(m->subtype, "pkcs7-mime") == 0))
632  {
633  t = mutt_param_get(&m->parameter, "smime-type");
634  if (t)
635  {
636  if (mutt_str_strcasecmp(t, "enveloped-data") == 0)
637  return SMIME_ENCRYPT;
638  else if (mutt_str_strcasecmp(t, "signed-data") == 0)
639  return SMIME_SIGN | SMIME_OPAQUE;
640  else
641  return SEC_NO_FLAGS;
642  }
643  /* Netscape 4.7 uses
644  * Content-Description: S/MIME Encrypted Message
645  * instead of Content-Type parameter */
646  if (mutt_str_strcasecmp(m->description, "S/MIME Encrypted Message") == 0)
647  return SMIME_ENCRYPT;
648  complain = true;
649  }
650  else if (mutt_str_strcasecmp(m->subtype, "octet-stream") != 0)
651  return SEC_NO_FLAGS;
652 
653  t = mutt_param_get(&m->parameter, "name");
654 
655  if (!t)
656  t = m->d_filename;
657  if (!t)
658  t = m->filename;
659  if (!t)
660  {
661  if (complain)
662  {
663  mutt_message(
664  _("S/MIME messages with no hints on content are unsupported"));
665  }
666  return SEC_NO_FLAGS;
667  }
668 
669  /* no .p7c, .p10 support yet. */
670 
671  int len = mutt_str_strlen(t) - 4;
672  if ((len > 0) && (*(t + len) == '.'))
673  {
674  len++;
675  if (mutt_str_strcasecmp((t + len), "p7m") == 0)
676  {
677  /* Not sure if this is the correct thing to do, but
678  * it's required for compatibility with Outlook */
679  return SMIME_SIGN | SMIME_OPAQUE;
680  }
681  else if (mutt_str_strcasecmp((t + len), "p7s") == 0)
682  return SMIME_SIGN | SMIME_OPAQUE;
683  }
684 
685  return SEC_NO_FLAGS;
686 }
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define mutt_message(...)
Definition: logging.h:83
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
#define _(a)
Definition: message.h:28
#define SMIME_SIGN
Definition: ncrypt.h:147
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
#define SMIME_OPAQUE
Definition: ncrypt.h:150
char * subtype
content-type subtype
Definition: body.h:37
char * description
content-description
Definition: body.h:40
unsigned int type
content-type primary type
Definition: body.h:65
#define SMIME_ENCRYPT
Definition: ncrypt.h:146
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
char * d_filename
filename to be used for the content-disposition header.
Definition: body.h:47
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
Type: &#39;application/*&#39;.
Definition: mime.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_malformed_multipart_pgp_encrypted()

SecurityFlags mutt_is_malformed_multipart_pgp_encrypted ( struct Body b)

Check for malformed layout.

Parameters
bBody of email
Return values
numSuccess, see SecurityFlags
0Error, (SEC_NO_FLAGS)

This checks for the malformed layout caused by MS Exchange in some cases:

<multipart/mixed>
<text/plain>
<application/pgp-encrypted> [BASE64-encoded]
<application/octet-stream> [BASE64-encoded]

See ticket #3742

Definition at line 515 of file crypt.c.

516 {
517  if (!(WithCrypto & APPLICATION_PGP))
518  return SEC_NO_FLAGS;
519 
520  if (!b || (b->type != TYPE_MULTIPART) || !b->subtype ||
521  (mutt_str_strcasecmp(b->subtype, "mixed") != 0))
522  {
523  return SEC_NO_FLAGS;
524  }
525 
526  b = b->parts;
527  if (!b || (b->type != TYPE_TEXT) || !b->subtype ||
528  (mutt_str_strcasecmp(b->subtype, "plain") != 0) || (b->length != 0))
529  {
530  return SEC_NO_FLAGS;
531  }
532 
533  b = b->next;
534  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
535  (mutt_str_strcasecmp(b->subtype, "pgp-encrypted") != 0))
536  {
537  return SEC_NO_FLAGS;
538  }
539 
540  b = b->next;
541  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
542  (mutt_str_strcasecmp(b->subtype, "octet-stream") != 0))
543  {
544  return SEC_NO_FLAGS;
545  }
546 
547  b = b->next;
548  if (b)
549  return SEC_NO_FLAGS;
550 
551  return PGP_ENCRYPT;
552 }
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
struct Body * next
next attachment in the list
Definition: body.h:53
char * subtype
content-type subtype
Definition: body.h:37
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
Type: &#39;text/*&#39;.
Definition: mime.h:38
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
#define WithCrypto
Definition: ncrypt.h:160
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define PGP_ENCRYPT
Definition: ncrypt.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_multipart_encrypted()

SecurityFlags mutt_is_multipart_encrypted ( struct Body b)

Does the message have encrypted parts?

Parameters
bBody of email
Return values
numMessage has got encrypted parts, see SecurityFlags
0Message hasn't got encrypted parts (SEC_NO_FLAGS)

Definition at line 453 of file crypt.c.

454 {
455  if ((WithCrypto & APPLICATION_PGP) == 0)
456  return SEC_NO_FLAGS;
457 
458  char *p = NULL;
459 
460  if (!b || (b->type != TYPE_MULTIPART) || !b->subtype ||
461  (mutt_str_strcasecmp(b->subtype, "encrypted") != 0) ||
462  !(p = mutt_param_get(&b->parameter, "protocol")) ||
463  (mutt_str_strcasecmp(p, "application/pgp-encrypted") != 0))
464  {
465  return SEC_NO_FLAGS;
466  }
467 
468  return PGP_ENCRYPT;
469 }
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
char * subtype
content-type subtype
Definition: body.h:37
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
#define PGP_ENCRYPT
Definition: ncrypt.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_multipart_signed()

SecurityFlags mutt_is_multipart_signed ( struct Body b)

Is a message signed?

Parameters
bBody of email
Return values
numMessage is signed, see SecurityFlags
0Message is not signed (SEC_NO_FLAGS)

Definition at line 412 of file crypt.c.

413 {
414  if (!b || (b->type != TYPE_MULTIPART) || !b->subtype ||
415  (mutt_str_strcasecmp(b->subtype, "signed") != 0))
416  {
417  return SEC_NO_FLAGS;
418  }
419 
420  char *p = mutt_param_get(&b->parameter, "protocol");
421  if (!p)
422  return SEC_NO_FLAGS;
423 
424  if (!(mutt_str_strcasecmp(p, "multipart/mixed") != 0))
425  return SEC_SIGN;
426 
427  if (((WithCrypto & APPLICATION_PGP) != 0) &&
428  !(mutt_str_strcasecmp(p, "application/pgp-signature") != 0))
429  {
430  return PGP_SIGN;
431  }
432 
433  if (((WithCrypto & APPLICATION_SMIME) != 0) &&
434  !(mutt_str_strcasecmp(p, "application/x-pkcs7-signature") != 0))
435  {
436  return SMIME_SIGN;
437  }
438  if (((WithCrypto & APPLICATION_SMIME) != 0) &&
439  !(mutt_str_strcasecmp(p, "application/pkcs7-signature") != 0))
440  {
441  return SMIME_SIGN;
442  }
443 
444  return SEC_NO_FLAGS;
445 }
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
#define SMIME_SIGN
Definition: ncrypt.h:147
#define PGP_SIGN
Definition: ncrypt.h:141
char * subtype
content-type subtype
Definition: body.h:37
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_valid_multipart_pgp_encrypted()

int mutt_is_valid_multipart_pgp_encrypted ( struct Body b)

Is this a valid multi-part encrypted message?

Parameters
bBody of email
Return values
>0Message is valid, with encrypted parts, e.g. PGP_ENCRYPT
0Message hasn't got encrypted parts

Definition at line 477 of file crypt.c.

478 {
480  return 0;
481 
482  b = b->parts;
483  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
484  (mutt_str_strcasecmp(b->subtype, "pgp-encrypted") != 0))
485  {
486  return 0;
487  }
488 
489  b = b->next;
490  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
491  (mutt_str_strcasecmp(b->subtype, "octet-stream") != 0))
492  {
493  return 0;
494  }
495 
496  return PGP_ENCRYPT;
497 }
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
struct Body * next
next attachment in the list
Definition: body.h:53
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:453
char * subtype
content-type subtype
Definition: body.h:37
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
unsigned int type
content-type primary type
Definition: body.h:65
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define PGP_ENCRYPT
Definition: ncrypt.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_protect()

int mutt_protect ( struct Email e,
char *  keylist,
bool  postpone 
)

Encrypt and/or sign a message.

Parameters
eEmail
keylistList of keys to encrypt to (space-separated)
postponeWhen true, signing is automatically disabled
Return values
0Success
-1Error

Definition at line 172 of file crypt.c.

173 {
174  struct Body *pbody = NULL, *tmp_pbody = NULL;
175  struct Body *tmp_smime_pbody = NULL;
176  struct Body *tmp_pgp_pbody = NULL;
177  bool has_retainable_sig = false;
178 
179  if (!WithCrypto)
180  return -1;
181 
182  int security = e->security;
183  int sign = security & (SEC_AUTOCRYPT | SEC_SIGN);
184  if (postpone)
185  {
186  sign = SEC_NO_FLAGS;
187  security &= ~SEC_SIGN;
188  }
189 
190  if (!(security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) && !sign)
191  return 0;
192 
193  if (sign && !(security & SEC_AUTOCRYPT) && !crypt_valid_passphrase(security))
194  return -1;
195 
196  if (((WithCrypto & APPLICATION_PGP) != 0) && !(security & SEC_AUTOCRYPT) &&
197  ((security & PGP_INLINE) == PGP_INLINE))
198  {
199  if ((e->content->type != TYPE_TEXT) ||
200  (mutt_str_strcasecmp(e->content->subtype, "plain") != 0))
201  {
203  _("Inline PGP can't be used with attachments. "
204  "Revert to PGP/MIME?")) != MUTT_YES)
205  {
206  mutt_error(
207  _("Mail not sent: inline PGP can't be used with attachments"));
208  return -1;
209  }
210  }
211  else if (mutt_str_strcasecmp("flowed", mutt_param_get(&e->content->parameter, "format")) == 0)
212  {
214  _("Inline PGP can't be used with format=flowed. "
215  "Revert to PGP/MIME?"))) != MUTT_YES)
216  {
217  mutt_error(
218  _("Mail not sent: inline PGP can't be used with format=flowed"));
219  return -1;
220  }
221  }
222  else
223  {
224  /* they really want to send it inline... go for it */
225  if (!isendwin())
226  {
227  mutt_endwin();
228  puts(_("Invoking PGP..."));
229  }
230  pbody = crypt_pgp_traditional_encryptsign(e->content, security, keylist);
231  if (pbody)
232  {
233  e->content = pbody;
234  return 0;
235  }
236 
237  /* otherwise inline won't work...ask for revert */
238  if (query_quadoption(
240  _("Message can't be sent inline. Revert to using PGP/MIME?")) != MUTT_YES)
241  {
242  mutt_error(_("Mail not sent"));
243  return -1;
244  }
245  }
246 
247  /* go ahead with PGP/MIME */
248  }
249 
250  if (!isendwin())
251  mutt_endwin();
252 
254  tmp_smime_pbody = e->content;
255  if (WithCrypto & APPLICATION_PGP)
256  tmp_pgp_pbody = e->content;
257 
258  if (C_CryptUsePka && sign)
259  {
260  /* Set sender (necessary for e.g. PKA). */
261  const char *mailbox = NULL;
262  struct Address *from = TAILQ_FIRST(&e->env->from);
263  bool free_from = false;
264 
265  if (!from)
266  {
267  free_from = true;
268  from = mutt_default_from();
269  }
270 
271  mailbox = from->mailbox;
272  if (!mailbox && C_EnvelopeFromAddress)
273  mailbox = C_EnvelopeFromAddress->mailbox;
274 
275  if (((WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
276  crypt_smime_set_sender(mailbox);
277  else if (((WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP))
278  crypt_pgp_set_sender(mailbox);
279 
280  if (free_from)
281  mutt_addr_free(&from);
282  }
283 
285  {
286  struct Envelope *protected_headers = mutt_env_new();
287  mutt_str_replace(&protected_headers->subject, e->env->subject);
288  /* Note: if other headers get added, such as to, cc, then a call to
289  * mutt_env_to_intl() will need to be added here too. */
290  mutt_prepare_envelope(protected_headers, 0);
291 
293  e->content->mime_headers = protected_headers;
294  }
295 
296  /* A note about e->content->mime_headers. If postpone or send
297  * fails, the mime_headers is cleared out before returning to the
298  * compose menu. So despite the "robustness" code above and in the
299  * gen_gossip_list function below, mime_headers will not be set when
300  * entering mutt_protect().
301  *
302  * This is important to note because the user could toggle
303  * $crypt_protected_headers_write or $autocrypt off back in the
304  * compose menu. We don't want mutt_write_rfc822_header() to write
305  * stale data from one option if the other is set.
306  */
307 #ifdef USE_AUTOCRYPT
308  if (C_Autocrypt && !postpone && (security & SEC_AUTOCRYPT))
309  {
311  }
312 #endif
313 
314  if (sign)
315  {
316  if (((WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
317  {
318  tmp_pbody = crypt_smime_sign_message(e->content);
319  if (!tmp_pbody)
320  goto bail;
321  pbody = tmp_pbody;
322  tmp_smime_pbody = tmp_pbody;
323  }
324 
325  if (((WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP) &&
326  (!(security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) || C_PgpRetainableSigs))
327  {
328  tmp_pbody = crypt_pgp_sign_message(e->content);
329  if (!tmp_pbody)
330  goto bail;
331 
332  has_retainable_sig = true;
333  sign = SEC_NO_FLAGS;
334  pbody = tmp_pbody;
335  tmp_pgp_pbody = tmp_pbody;
336  }
337 
338  if ((WithCrypto != 0) && (security & APPLICATION_SMIME) && (security & APPLICATION_PGP))
339  {
340  /* here comes the draft ;-) */
341  }
342  }
343 
344  if (security & (SEC_ENCRYPT | SEC_AUTOCRYPT))
345  {
346  if (((WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
347  {
348  tmp_pbody = crypt_smime_build_smime_entity(tmp_smime_pbody, keylist);
349  if (!tmp_pbody)
350  {
351  /* signed ? free it! */
352  goto bail;
353  }
354  /* free tmp_body if messages was signed AND encrypted ... */
355  if ((tmp_smime_pbody != e->content) && (tmp_smime_pbody != tmp_pbody))
356  {
357  /* detach and don't delete e->content,
358  * which tmp_smime_pbody->parts after signing. */
359  tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
360  e->content->next = NULL;
361  mutt_body_free(&tmp_smime_pbody);
362  }
363  pbody = tmp_pbody;
364  }
365 
366  if (((WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP))
367  {
368  pbody = crypt_pgp_encrypt_message(e, tmp_pgp_pbody, keylist, sign);
369  if (!pbody)
370  {
371  /* did we perform a retainable signature? */
372  if (has_retainable_sig)
373  {
374  /* remove the outer multipart layer */
375  tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody);
376  /* get rid of the signature */
377  mutt_body_free(&tmp_pgp_pbody->next);
378  }
379 
380  goto bail;
381  }
382 
383  /* destroy temporary signature envelope when doing retainable
384  * signatures.
385 
386  */
387  if (has_retainable_sig)
388  {
389  tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody);
390  mutt_body_free(&tmp_pgp_pbody->next);
391  }
392  }
393  }
394 
395  if (pbody)
396  {
397  e->content = pbody;
398  return 0;
399  }
400 
401 bail:
403  return -1;
404 }
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:205
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: sendlib.c:1742
#define PGP_INLINE
Definition: ncrypt.h:144
#define TAILQ_FIRST(head)
Definition: queue.h:717
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3331
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
struct Body * content
List of MIME parts.
Definition: email.h:92
WHERE bool C_CryptUsePka
Config: Use GPGME to use PKA (lookup PGP keys using DNS)
Definition: globals.h:275
WHERE bool C_CryptProtectedHeadersWrite
Config: Generate protected header (Memory Hole) for signed and encrypted emails.
Definition: globals.h:283
void crypt_pgp_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
Definition: cryptglue.c:393
#define _(a)
Definition: message.h:28
struct Body * next
next attachment in the list
Definition: body.h:53
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:439
The body of an email.
Definition: body.h:34
void mutt_prepare_envelope(struct Envelope *env, bool final)
Prepare an email header.
Definition: sendlib.c:2997
struct Body * crypt_smime_sign_message(struct Body *a)
Wrapper for CryptModuleSpecs::sign_message()
Definition: cryptglue.c:486
void crypt_smime_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
Definition: cryptglue.c:539
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
bool C_PgpRetainableSigs
Config: Create nested multipart/signed or encrypted messages.
Definition: crypt.c:71
struct Envelope * env
Envelope information.
Definition: email.h:91
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:42
char * subtype
content-type subtype
Definition: body.h:37
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
struct Address * mutt_default_from(void)
Get a default &#39;from&#39; Address.
Definition: send.c:1307
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
Type: &#39;text/*&#39;.
Definition: mime.h:38
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
struct Body * crypt_pgp_traditional_encryptsign(struct Body *a, int flags, char *keylist)
Wrapper for CryptModuleSpecs::pgp_traditional_encryptsign()
Definition: cryptglue.c:284
struct Body * crypt_pgp_sign_message(struct Body *a)
Wrapper for CryptModuleSpecs::sign_message()
Definition: cryptglue.c:317
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
unsigned char C_PgpMimeAuto
Config: Prompt the user to use MIME if inline PGP fails.
Definition: crypt.c:70
struct Body * crypt_smime_build_smime_entity(struct Body *a, char *certlist)
Wrapper for CryptModuleSpecs::smime_build_smime_entity()
Definition: cryptglue.c:497
char * subject
Email&#39;s subject.
Definition: envelope.h:66
int mutt_autocrypt_generate_gossip_list(struct Email *e)
Create the gossip list headers.
Definition: autocrypt.c:798
#define mutt_error(...)
Definition: logging.h:84
WHERE struct Address * C_EnvelopeFromAddress
Config: Manually set the sender for outgoing messages.
Definition: globals.h:98
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
struct Body * crypt_pgp_encrypt_message(struct Email *e, struct Body *a, char *keylist, int sign)
Wrapper for CryptModuleSpecs::pgp_encrypt_message()
Definition: cryptglue.c:328
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
The header of an Email.
Definition: envelope.h:54
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_protected_headers_handler()

int mutt_protected_headers_handler ( struct Body m,
struct State s 
)

Process a protected header - Implements handler_t.

Definition at line 1096 of file crypt.c.

1097 {
1098  if (C_CryptProtectedHeadersRead && a->mime_headers)
1099  {
1100  if (a->mime_headers->subject)
1101  {
1102  if ((s->flags & MUTT_DISPLAY) && C_Weed && mutt_matches_ignore("subject"))
1103  return 0;
1104 
1106  mutt_write_one_header(s->fp_out, "Subject", a->mime_headers->subject, s->prefix,
1109  state_puts("\n", s);
1110  }
1111  }
1112 
1113  return 0;
1114 }
bool mutt_matches_ignore(const char *s)
Does the string match the ignore list.
Definition: parse.c:307
#define MUTT_DISPLAY
Output is displayed to the user.
Definition: state.h:32
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
WHERE short C_Wrap
Config: Width to wrap text in the pager.
Definition: globals.h:157
FILE * fp_out
File to write to.
Definition: state.h:47
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:40
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:337
void state_mark_protected_header(struct State *s)
Write a unique marker around protected headers.
Definition: state.c:53
WHERE bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: globals.h:281
#define state_puts(str, state)
Definition: state.h:54
int mutt_write_one_header(FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, CopyHeaderFlags chflags)
Write one header line to a file.
Definition: sendlib.c:2133
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_should_hide_protected_subject()

bool mutt_should_hide_protected_subject ( struct Email e)

Should NeoMutt hide the protected subject?

Parameters
eEmail to test
Return values
boolTrue if the subject should be protected

Definition at line 1082 of file crypt.c.

1083 {
1086  {
1087  return true;
1088  }
1089 
1090  return false;
1091 }
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
WHERE char * C_CryptProtectedHeadersSubject
Config: Use this as the subject for encrypted emails.
Definition: globals.h:110
WHERE bool C_CryptProtectedHeadersWrite
Config: Generate protected header (Memory Hole) for signed and encrypted emails.
Definition: globals.h:283
#define SEC_INLINE
Email has an inline signature.
Definition: ncrypt.h:129
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
+ Here is the caller graph for this function:

◆ mutt_signed_handler()

int mutt_signed_handler ( struct Body a,
struct State s 
)

Verify a "multipart/signed" body - Implements handler_t.

Definition at line 1119 of file crypt.c.

1120 {
1121  if (!WithCrypto)
1122  return -1;
1123 
1124  bool inconsistent = false;
1125  struct Body *b = a;
1126  struct Body **signatures = NULL;
1127  int sigcnt = 0;
1128  int rc = 0;
1129 
1130  a = a->parts;
1131  SecurityFlags signed_type = mutt_is_multipart_signed(b);
1132  if (signed_type == SEC_NO_FLAGS)
1133  {
1134  /* A null protocol value is already checked for in mutt_body_handler() */
1135  state_printf(s,
1136  _("[-- Error: "
1137  "Unknown multipart/signed protocol %s --]\n\n"),
1138  mutt_param_get(&b->parameter, "protocol"));
1139  return mutt_body_handler(a, s);
1140  }
1141 
1142  if (!(a && a->next))
1143  inconsistent = true;
1144  else
1145  {
1146  switch (signed_type)
1147  {
1148  case SEC_SIGN:
1149  if ((a->next->type != TYPE_MULTIPART) ||
1150  (mutt_str_strcasecmp(a->next->subtype, "mixed") != 0))
1151  {
1152  inconsistent = true;
1153  }
1154  break;
1155  case PGP_SIGN:
1156  if ((a->next->type != TYPE_APPLICATION) ||
1157  (mutt_str_strcasecmp(a->next->subtype, "pgp-signature") != 0))
1158  {
1159  inconsistent = true;
1160  }
1161  break;
1162  case SMIME_SIGN:
1163  if ((a->next->type != TYPE_APPLICATION) ||
1164  ((mutt_str_strcasecmp(a->next->subtype, "x-pkcs7-signature") != 0) &&
1165  (mutt_str_strcasecmp(a->next->subtype, "pkcs7-signature") != 0)))
1166  {
1167  inconsistent = true;
1168  }
1169  break;
1170  default:
1171  inconsistent = true;
1172  }
1173  }
1174  if (inconsistent)
1175  {
1176  state_attach_puts(_("[-- Error: "
1177  "Missing or bad-format multipart/signed signature"
1178  " --]\n\n"),
1179  s);
1180  return mutt_body_handler(a, s);
1181  }
1182 
1183  if (s->flags & MUTT_DISPLAY)
1184  {
1185  crypt_fetch_signatures(&signatures, a->next, &sigcnt);
1186 
1187  if (sigcnt != 0)
1188  {
1189  char tempfile[PATH_MAX];
1190  mutt_mktemp(tempfile, sizeof(tempfile));
1191  bool goodsig = true;
1192  if (crypt_write_signed(a, s, tempfile) == 0)
1193  {
1194  for (int i = 0; i < sigcnt; i++)
1195  {
1196  if (((WithCrypto & APPLICATION_PGP) != 0) &&
1197  (signatures[i]->type == TYPE_APPLICATION) &&
1198  (mutt_str_strcasecmp(signatures[i]->subtype, "pgp-signature") == 0))
1199  {
1200  if (crypt_pgp_verify_one(signatures[i], s, tempfile) != 0)
1201  goodsig = false;
1202 
1203  continue;
1204  }
1205 
1206  if (((WithCrypto & APPLICATION_SMIME) != 0) &&
1207  (signatures[i]->type == TYPE_APPLICATION) &&
1208  ((mutt_str_strcasecmp(signatures[i]->subtype,
1209  "x-pkcs7-signature") == 0) ||
1210  (mutt_str_strcasecmp(signatures[i]->subtype,
1211  "pkcs7-signature") == 0)))
1212  {
1213  if (crypt_smime_verify_one(signatures[i], s, tempfile) != 0)
1214  goodsig = false;
1215 
1216  continue;
1217  }
1218 
1219  state_printf(s,
1220  _("[-- Warning: "
1221  "We can't verify %s/%s signatures. --]\n\n"),
1222  TYPE(signatures[i]), signatures[i]->subtype);
1223  }
1224  }
1225 
1226  mutt_file_unlink(tempfile);
1227 
1228  b->goodsig = goodsig;
1229  b->badsig = !goodsig;
1230 
1231  /* Now display the signed body */
1232  state_attach_puts(_("[-- The following data is signed --]\n\n"), s);
1233 
1235 
1236  FREE(&signatures);
1237  }
1238  else
1239  state_attach_puts(_("[-- Warning: Can't find any signatures. --]\n\n"), s);
1240  }
1241 
1242  rc = mutt_body_handler(a, s);
1243 
1244  if ((s->flags & MUTT_DISPLAY) && (sigcnt != 0))
1245  state_attach_puts(_("\n[-- End of signed data --]\n"), s);
1246 
1247  return rc;
1248 }
int mutt_protected_headers_handler(struct Body *a, struct State *s)
Process a protected header - Implements handler_t.
Definition: crypt.c:1096
int state_printf(struct State *s, const char *fmt,...)
Write a formatted string to the State.
Definition: state.c:147
#define MUTT_DISPLAY
Output is displayed to the user.
Definition: state.h:32
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:192
#define _(a)
Definition: message.h:28
struct Body * next
next attachment in the list
Definition: body.h:53
#define SMIME_SIGN
Definition: ncrypt.h:147
int crypt_write_signed(struct Body *a, struct State *s, const char *tempfile)
Write the message body/part.
Definition: crypt.c:768
void state_attach_puts(const char *t, struct State *s)
Write a string to the state.
Definition: state.c:64
The body of an email.
Definition: body.h:34
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
Definition: body.h:83
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:412
#define PGP_SIGN
Definition: ncrypt.h:141
char * subtype
content-type subtype
Definition: body.h:37
bool goodsig
Good cryptographic signature.
Definition: body.h:81
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
#define PATH_MAX
Definition: mutt.h:52
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
static void crypt_fetch_signatures(struct Body ***signatures, struct Body *a, int *n)
Create an array of an emails parts.
Definition: crypt.c:1058
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define TYPE(body)
Definition: mime.h:83
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
#define FREE(x)
Definition: memory.h:40
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
int crypt_smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
Definition: cryptglue.c:517
int mutt_body_handler(struct Body *b, struct State *s)
Handler for the Body of an email.
Definition: handler.c:1545
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: ncrypt.h:120
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
int crypt_pgp_verify_one(struct Body *sigbdy, struct State *s, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
Definition: cryptglue.c:362
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_has_module_backend()

bool crypt_has_module_backend ( SecurityFlags  type)

Is there a crypto backend for a given type?

Parameters
typeCrypto type, see SecurityFlags
Return values
trueBackend is present
falseBackend is not present

Definition at line 159 of file cryptglue.c.

160 {
161  if (((WithCrypto & APPLICATION_PGP) != 0) && (type & APPLICATION_PGP) &&
162  crypto_module_lookup(APPLICATION_PGP))
163  {
164  return true;
165  }
166 
167  if (((WithCrypto & APPLICATION_SMIME) != 0) && (type & APPLICATION_SMIME) &&
168  crypto_module_lookup(APPLICATION_SMIME))
169  {
170  return true;
171  }
172 
173  return false;
174 }
unsigned int type
content-type primary type
Definition: body.h:65
struct CryptModuleSpecs * crypto_module_lookup(int identifier)
Lookup a crypto module by name.
Definition: crypt_mod.c:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_init()

void crypt_init ( void  )

Initialise the crypto backends.

This calls CryptModuleSpecs::init()

Definition at line 92 of file cryptglue.c.

93 {
94 #ifdef CRYPT_BACKEND_CLASSIC_PGP
95  if (
96 #ifdef CRYPT_BACKEND_GPGME
98 #else
99  1
100 #endif
101  )
103 #endif
104 
105 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
106  if (
107 #ifdef CRYPT_BACKEND_GPGME
108  (!C_CryptUseGpgme)
109 #else
110  1
111 #endif
112  )
114 #endif
115 
116  if (C_CryptUseGpgme)
117  {
118 #ifdef CRYPT_BACKEND_GPGME
121 #else
122  mutt_message(_("\"crypt_use_gpgme\" set"
123  " but not built with GPGME support"));
124  if (mutt_any_key_to_continue(NULL) == -1)
125  mutt_exit(1);
126 #endif
127  }
128 
129 #if defined(CRYPT_BACKEND_CLASSIC_PGP) || \
130  defined(CRYPT_BACKEND_CLASSIC_SMIME) || defined(CRYPT_BACKEND_GPGME)
131  if (CRYPT_MOD_CALL_CHECK(PGP, init))
132  CRYPT_MOD_CALL(PGP, init)();
133 
134  if (CRYPT_MOD_CALL_CHECK(SMIME, init))
135  CRYPT_MOD_CALL(SMIME, init)();
136 #endif
137 }
struct CryptModuleSpecs CryptModPgpGpgme
GPGME PGP - Implements CryptModuleSpecs.
#define mutt_message(...)
Definition: logging.h:83
bool C_CryptUseGpgme
Config: Use GPGME crypto backend.
Definition: cryptglue.c:56
#define _(a)
Definition: message.h:28
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
void crypto_module_register(struct CryptModuleSpecs *specs)
Register a new crypto module.
Definition: crypt_mod.c:51
struct CryptModuleSpecs CryptModSmimeClassic
CLI SMIME - Implements CryptModuleSpecs.
struct CryptModuleSpecs CryptModPgpClassic
CLI PGP - Implements CryptModuleSpecs.
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition: main.c:210
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:532
struct CryptModuleSpecs CryptModSmimeGpgme
GPGME SMIME - Implements CryptModuleSpecs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_invoke_message()

void crypt_invoke_message ( SecurityFlags  type)

Display an informative message.

Parameters
typeCrypto type, see SecurityFlags

Show a message that a backend will be invoked.

Definition at line 145 of file cryptglue.c.

146 {
147  if (((WithCrypto & APPLICATION_PGP) != 0) && (type & APPLICATION_PGP))
148  mutt_message(_("Invoking PGP..."));
149  else if (((WithCrypto & APPLICATION_SMIME) != 0) && (type & APPLICATION_SMIME))
150  mutt_message(_("Invoking S/MIME..."));
151 }
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the caller graph for this function:

◆ crypt_pgp_application_handler()

int crypt_pgp_application_handler ( struct Body m,
struct State s 
)

Wrapper for CryptModuleSpecs::application_handler()

Implements handler_t

Definition at line 226 of file cryptglue.c.

227 {
228  if (CRYPT_MOD_CALL_CHECK(PGP, application_handler))
229  return CRYPT_MOD_CALL(PGP, application_handler)(m, s);
230 
231  return -1;
232 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_pgp_check_traditional()

int crypt_pgp_check_traditional ( FILE *  fp,
struct Body b,
bool  just_one 
)

Wrapper for CryptModuleSpecs::pgp_check_traditional()

Definition at line 273 of file cryptglue.c.

274 {
275  if (CRYPT_MOD_CALL_CHECK(PGP, pgp_check_traditional))
276  return CRYPT_MOD_CALL(PGP, pgp_check_traditional)(fp, b, just_one);
277 
278  return 0;
279 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_pgp_decrypt_mime()

int crypt_pgp_decrypt_mime ( FILE *  fp_in,
FILE **  fp_out,
struct Body b,
struct Body **  cur 
)

Wrapper for CryptModuleSpecs::decrypt_mime()

Definition at line 199 of file cryptglue.c.

200 {
201 #ifdef USE_AUTOCRYPT
202  if (C_Autocrypt)
203  {
204  OptAutocryptGpgme = true;
205  int result = pgp_gpgme_decrypt_mime(fp_in, fp_out, b, cur);
206  OptAutocryptGpgme = false;
207  if (result == 0)
208  {
209  b->is_autocrypt = true;
210  return result;
211  }
212  }
213 #endif
214 
215  if (CRYPT_MOD_CALL_CHECK(PGP, decrypt_mime))
216  return CRYPT_MOD_CALL(PGP, decrypt_mime)(fp_in, fp_out, b, cur);
217 
218  return -1;
219 }
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:205
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
Definition: body.h:85
WHERE bool OptAutocryptGpgme
(pseudo) use Autocrypt context inside ncrypt/crypt_gpgme.c
Definition: options.h:32
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
int pgp_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Implements CryptModuleSpecs::decrypt_mime()
Definition: crypt_gpgme.c:2351
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_pgp_encrypted_handler()

int crypt_pgp_encrypted_handler ( struct Body a,
struct State s 
)

Wrapper for CryptModuleSpecs::encrypted_handler()

Implements handler_t

Definition at line 239 of file cryptglue.c.

240 {
241 #ifdef USE_AUTOCRYPT
242  if (C_Autocrypt)
243  {
244  OptAutocryptGpgme = true;
245  int result = pgp_gpgme_encrypted_handler(a, s);
246  OptAutocryptGpgme = false;
247  if (result == 0)
248  {
249  a->is_autocrypt = true;
250  return result;
251  }
252  }
253 #endif
254 
255  if (CRYPT_MOD_CALL_CHECK(PGP, encrypted_handler))
256  return CRYPT_MOD_CALL(PGP, encrypted_handler)(a, s);
257 
258  return -1;
259 }
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:205
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
Definition: body.h:85
WHERE bool OptAutocryptGpgme
(pseudo) use Autocrypt context inside ncrypt/crypt_gpgme.c
Definition: options.h:32
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s)
Implements CryptModuleSpecs::encrypted_handler()
Definition: crypt_gpgme.c:3197
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crypt_pgp_extract_key_from_attachment()

void crypt_pgp_extract_key_from_attachment ( FILE *  fp,
struct Body top 
)

Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment()

Definition at line 384 of file cryptglue.c.

385 {
386  if (CRYPT_MOD_CALL_CHECK(PGP, pgp_extract_key_from_attachment))
387  CRYPT_MOD_CALL(PGP, pgp_extract_key_from_attachment)(fp, top);
388 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_pgp_invoke_getkeys()

void crypt_pgp_invoke_getkeys ( struct Address addr)

Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()

Definition at line 264 of file cryptglue.c.

265 {
266  if (CRYPT_MOD_CALL_CHECK(PGP, pgp_invoke_getkeys))
267  CRYPT_MOD_CALL(PGP, pgp_invoke_getkeys)(addr);
268 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_pgp_make_key_attachment()

struct Body* crypt_pgp_make_key_attachment ( void  )

Wrapper for CryptModuleSpecs::pgp_make_key_attachment()

Definition at line 295 of file cryptglue.c.

296 {
297  if (CRYPT_MOD_CALL_CHECK(PGP, pgp_make_key_attachment))
298  return CRYPT_MOD_CALL(PGP, pgp_make_key_attachment)();
299 
300  return NULL;
301 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_pgp_send_menu()

int crypt_pgp_send_menu ( struct Email e)

Wrapper for CryptModuleSpecs::send_menu()

Definition at line 373 of file cryptglue.c.

374 {
375  if (CRYPT_MOD_CALL_CHECK(PGP, send_menu))
376  return CRYPT_MOD_CALL(PGP, send_menu)(e);
377 
378  return 0;
379 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_smime_application_handler()

int crypt_smime_application_handler ( struct Body m,
struct State s 
)

Wrapper for CryptModuleSpecs::application_handler()

Implements handler_t

Definition at line 435 of file cryptglue.c.

436 {
437  if (CRYPT_MOD_CALL_CHECK(SMIME, application_handler))
438  return CRYPT_MOD_CALL(SMIME, application_handler)(m, s);
439 
440  return -1;
441 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_smime_decrypt_mime()

int crypt_smime_decrypt_mime ( FILE *  fp_in,
FILE **  fp_out,
struct Body b,
struct Body **  cur 
)

Wrapper for CryptModuleSpecs::decrypt_mime()

Definition at line 422 of file cryptglue.c.

423 {
424  if (CRYPT_MOD_CALL_CHECK(SMIME, decrypt_mime))
425  return CRYPT_MOD_CALL(SMIME, decrypt_mime)(fp_in, fp_out, b, cur);
426 
427  return -1;
428 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_smime_getkeys()

void crypt_smime_getkeys ( struct Envelope env)

Wrapper for CryptModuleSpecs::smime_getkeys()

Definition at line 455 of file cryptglue.c.

456 {
457  if (CRYPT_MOD_CALL_CHECK(SMIME, smime_getkeys))
458  CRYPT_MOD_CALL(SMIME, smime_getkeys)(env);
459 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_smime_send_menu()

int crypt_smime_send_menu ( struct Email e)

Wrapper for CryptModuleSpecs::send_menu()

Definition at line 528 of file cryptglue.c.

529 {
530  if (CRYPT_MOD_CALL_CHECK(SMIME, send_menu))
531  return CRYPT_MOD_CALL(SMIME, send_menu)(e);
532 
533  return 0;
534 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypt_smime_verify_sender()

int crypt_smime_verify_sender ( struct Mailbox m,
struct Email e 
)

Wrapper for CryptModuleSpecs::smime_verify_sender()

Definition at line 464 of file cryptglue.c.

465 {
466  if (CRYPT_MOD_CALL_CHECK(SMIME, smime_verify_sender))
467  return CRYPT_MOD_CALL(SMIME, smime_verify_sender)(m, e);
468 
469  return 1;
470 }
#define CRYPT_MOD_CALL(identifier, func)
Definition: cryptglue.c:84
#define CRYPT_MOD_CALL_CHECK(identifier, func)
Definition: cryptglue.c:78
+ Here is the caller graph for this function:

◆ crypto_module_free()

void crypto_module_free ( void  )

Clean up the crypto modules.

Definition at line 81 of file crypt_mod.c.

82 {
83  struct CryptModule *np = NULL, *tmp = NULL;
84  STAILQ_FOREACH_SAFE(np, &CryptModules, entries, tmp)
85  {
86  STAILQ_REMOVE(&CryptModules, np, CryptModule, entries);
87  FREE(&np);
88  }
89 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
A crypto plugin module.
Definition: crypt_mod.c:38
static struct CryptModuleList CryptModules
Definition: crypt_mod.c:45
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

Variable Documentation

◆ C_CryptTimestamp

bool C_CryptTimestamp

Config: Add a timestamp to PGP or SMIME output to prevent spoofing.

Definition at line 65 of file crypt.c.

◆ C_PgpEncryptSelf

unsigned char C_PgpEncryptSelf

Deprecated, see C_PgpSelfEncrypt.

Definition at line 69 of file crypt.c.

◆ C_PgpMimeAuto

unsigned char C_PgpMimeAuto

Config: Prompt the user to use MIME if inline PGP fails.

Definition at line 70 of file crypt.c.

◆ C_PgpRetainableSigs

bool C_PgpRetainableSigs

Config: Create nested multipart/signed or encrypted messages.

Definition at line 71 of file crypt.c.

◆ C_PgpSelfEncrypt

bool C_PgpSelfEncrypt

Config: Encrypted messages will also be encrypted to C_PgpDefaultKey too.

Definition at line 72 of file crypt.c.

◆ C_PgpStrictEnc

bool C_PgpStrictEnc

Config: Encode PGP signed messages with quoted-printable (don't unset)

Definition at line 73 of file crypt.c.

◆ C_SmimeEncryptSelf

unsigned char C_SmimeEncryptSelf

Deprecated, see C_SmimeSelfEncrypt.

Definition at line 74 of file crypt.c.

◆ C_SmimeSelfEncrypt

bool C_SmimeSelfEncrypt

Config: Encrypted messages will also be encrypt to C_SmimeDefaultKey too.

Definition at line 75 of file crypt.c.

◆ C_CryptUseGpgme

bool C_CryptUseGpgme

Config: Use GPGME crypto backend.

Definition at line 56 of file cryptglue.c.

◆ C_PgpCheckExit

bool C_PgpCheckExit

Config: Check the exit code of PGP subprocess.

Definition at line 72 of file pgp.c.

◆ C_PgpCheckGpgDecryptStatusFd

bool C_PgpCheckGpgDecryptStatusFd

Config: File descriptor used for status info.

Definition at line 73 of file pgp.c.

◆ C_PgpDecryptionOkay

struct Regex* C_PgpDecryptionOkay

Config: Text indicating a successful decryption.

Definition at line 74 of file pgp.c.

◆ C_PgpGoodSign

struct Regex* C_PgpGoodSign

Config: Text indicating a good signature.

Definition at line 75 of file pgp.c.

◆ C_PgpTimeout

long C_PgpTimeout

Config: Time in seconds to cache a passphrase.

Definition at line 76 of file pgp.c.

◆ C_PgpUseGpgAgent

bool C_PgpUseGpgAgent

Config: Use a PGP agent for caching passwords.

Definition at line 77 of file pgp.c.

◆ C_PgpClearsignCommand

char* C_PgpClearsignCommand

Config: (pgp) External command to inline-sign a message.

Definition at line 54 of file pgpinvoke.c.

◆ C_PgpDecodeCommand

char* C_PgpDecodeCommand

Config: (pgp) External command to decode a PGP attachment.

Definition at line 55 of file pgpinvoke.c.

◆ C_PgpDecryptCommand

char* C_PgpDecryptCommand

Config: (pgp) External command to decrypt a PGP message.

Definition at line 56 of file pgpinvoke.c.

◆ C_PgpEncryptOnlyCommand

char* C_PgpEncryptOnlyCommand

Config: (pgp) External command to encrypt, but not sign a message.

Definition at line 57 of file pgpinvoke.c.

◆ C_PgpEncryptSignCommand

char* C_PgpEncryptSignCommand

Config: (pgp) External command to encrypt and sign a message.

Definition at line 58 of file pgpinvoke.c.

◆ C_PgpExportCommand

char* C_PgpExportCommand

Config: (pgp) External command to export a public key from the user's keyring.

Definition at line 59 of file pgpinvoke.c.

◆ C_PgpGetkeysCommand

char* C_PgpGetkeysCommand

Config: (pgp) External command to download a key for an email address.

Definition at line 60 of file pgpinvoke.c.

◆ C_PgpImportCommand

char* C_PgpImportCommand

Config: (pgp) External command to import a key into the user's keyring.

Definition at line 61 of file pgpinvoke.c.

◆ C_PgpListPubringCommand

char* C_PgpListPubringCommand

Config: (pgp) External command to list the public keys in a user's keyring.

Definition at line 62 of file pgpinvoke.c.

◆ C_PgpListSecringCommand

char* C_PgpListSecringCommand

Config: (pgp) External command to list the private keys in a user's keyring.

Definition at line 63 of file pgpinvoke.c.

◆ C_PgpSignCommand

char* C_PgpSignCommand

Config: (pgp) External command to create a detached PGP signature.

Definition at line 64 of file pgpinvoke.c.

◆ C_PgpVerifyCommand

char* C_PgpVerifyCommand

Config: (pgp) External command to verify PGP signatures.

Definition at line 65 of file pgpinvoke.c.

◆ C_PgpVerifyKeyCommand

char* C_PgpVerifyKeyCommand

Config: (pgp) External command to verify key information.

Definition at line 66 of file pgpinvoke.c.

◆ C_SmimeAskCertLabel

bool C_SmimeAskCertLabel

Config: Prompt the user for a label for SMIME certificates.

Definition at line 70 of file smime.c.

◆ C_SmimeCaLocation

char* C_SmimeCaLocation

Config: File containing trusted certificates.

Definition at line 71 of file smime.c.

◆ C_SmimeCertificates

char* C_SmimeCertificates

Config: File containing user's public certificates.

Definition at line 72 of file smime.c.

◆ C_SmimeDecryptCommand

char* C_SmimeDecryptCommand

Config: (smime) External command to decrypt an SMIME message.

Definition at line 73 of file smime.c.

◆ C_SmimeDecryptUseDefaultKey

bool C_SmimeDecryptUseDefaultKey

Config: Use the default key for decryption.

Definition at line 74 of file smime.c.

◆ C_SmimeEncryptCommand

char* C_SmimeEncryptCommand

Config: (smime) External command to encrypt a message.

Definition at line 75 of file smime.c.

◆ C_SmimeGetCertCommand

char* C_SmimeGetCertCommand

Config: (smime) External command to extract a certificate from a message.

Definition at line 76 of file smime.c.

◆ C_SmimeGetCertEmailCommand

char* C_SmimeGetCertEmailCommand

Config: (smime) External command to get a certificate for an email.

Definition at line 77 of file smime.c.

◆ C_SmimeGetSignerCertCommand

char* C_SmimeGetSignerCertCommand

Config: (smime) External command to extract a certificate from an email.

Definition at line 78 of file smime.c.

◆ C_SmimeImportCertCommand

char* C_SmimeImportCertCommand

Config: (smime) External command to import a certificate.

Definition at line 79 of file smime.c.

◆ C_SmimeKeys

char* C_SmimeKeys

Config: File containing user's private certificates.

Definition at line 80 of file smime.c.

◆ C_SmimePk7outCommand

char* C_SmimePk7outCommand

Config: (smime) External command to extract a public certificate.

Definition at line 81 of file smime.c.

◆ C_SmimeSignCommand

char* C_SmimeSignCommand

Config: (smime) External command to sign a message.

Definition at line 82 of file smime.c.

◆ C_SmimeSignDigestAlg

char* C_SmimeSignDigestAlg

Config: Digest algorithm.

Definition at line 83 of file smime.c.

◆ C_SmimeTimeout

long C_SmimeTimeout

Config: Time in seconds to cache a passphrase.

Definition at line 84 of file smime.c.

◆ C_SmimeVerifyCommand

char* C_SmimeVerifyCommand

Config: (smime) External command to verify a signed message.

Definition at line 85 of file smime.c.

◆ C_SmimeVerifyOpaqueCommand

char* C_SmimeVerifyOpaqueCommand

Config: (smime) External command to verify a signature.

Definition at line 86 of file smime.c.