API for encryption/signing of emails. More...
#include <stdbool.h>#include <stdint.h>#include <stdio.h>Go to the source code of this file.
Typedefs | |
| typedef uint16_t | SecurityFlags |
| typedef uint16_t | KeyFlags |
Enumerations | |
| enum | SecurityFlag { SEC_NONE = 0 , SEC_ENCRYPT = 1U << 0 , SEC_SIGN = 1U << 1 , SEC_GOODSIGN = 1U << 2 , SEC_BADSIGN = 1U << 3 , SEC_PARTSIGN = 1U << 4 , SEC_SIGNOPAQUE = 1U << 5 , SEC_KEYBLOCK = 1U << 6 , SEC_INLINE = 1U << 7 , SEC_OPPENCRYPT = 1U << 8 , SEC_AUTOCRYPT = 1U << 9 , SEC_AUTOCRYPT_OVERRIDE = 1U << 10 } |
| Flags describing an email's cryptographic state. More... | |
| enum | KeyFlag { KEYFLAG_NONE = 0 , KEYFLAG_CANSIGN = 1U << 0 , KEYFLAG_CANENCRYPT = 1U << 1 , KEYFLAG_ISX509 = 1U << 2 , KEYFLAG_SECRET = 1U << 7 , KEYFLAG_EXPIRED = 1U << 8 , KEYFLAG_REVOKED = 1U << 9 , KEYFLAG_DISABLED = 1U << 10 , KEYFLAG_SUBKEY = 1U << 11 , KEYFLAG_CRITICAL = 1U << 12 , KEYFLAG_PREFER_ENCRYPTION = 1U << 13 , KEYFLAG_PREFER_SIGNING = 1U << 14 } |
| Flags describing PGP/SMIME keys. More... | |
Functions | |
| void | pgp_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic) |
| Initialise the PGP Keybindings - Implements ::init_keys_api. | |
| void | crypt_extract_keys_from_messages (struct Mailbox *m, struct EmailArray *ea) |
| Extract keys from a message. | |
| void | crypt_forget_passphrase (void) |
| Forget a passphrase and display a message. | |
| int | crypt_get_keys (struct Email *e, char **keylist, bool oppenc_mode) |
| Check we have all the keys we need. | |
| void | crypt_opportunistic_encrypt (struct Email *e) |
| Can all recipients be determined. | |
| SecurityFlags | crypt_query (struct Body *b) |
| Check out the type of encryption used. | |
| bool | crypt_valid_passphrase (SecurityFlags flags) |
| Check that we have a usable passphrase, ask if not. | |
| SecurityFlags | mutt_is_application_pgp (const struct Body *b) |
| Does the message use PGP? | |
| SecurityFlags | mutt_is_application_smime (struct Body *b) |
| Does the message use S/MIME? | |
| SecurityFlags | mutt_is_malformed_multipart_pgp_encrypted (struct Body *b) |
| Check for malformed layout. | |
| SecurityFlags | mutt_is_multipart_encrypted (struct Body *b) |
| Does the message have encrypted parts? | |
| SecurityFlags | mutt_is_multipart_signed (struct Body *b) |
| Is a message signed? | |
| int | mutt_is_valid_multipart_pgp_encrypted (struct Body *b) |
| Is this a valid multi-part encrypted message? | |
| int | mutt_protected_headers_handler (struct Body *b, struct State *state) |
| Handler for protected headers - Implements handler_t -. | |
| int | mutt_protect (struct Email *e, char *keylist, bool postpone) |
| Encrypt and/or sign a message. | |
| bool | mutt_should_hide_protected_subject (struct Email *e) |
| Should NeoMutt hide the protected subject? | |
| int | mutt_signed_handler (struct Body *b, struct State *state) |
| Handler for "multipart/signed" - Implements handler_t -. | |
| void | crypt_cleanup (struct NcryptModuleData *mod_data) |
| Clean up backend. | |
| bool | crypt_has_module_backend (SecurityFlags type) |
| Is there a crypto backend for a given type? | |
| void | crypt_init (void) |
| Initialise the crypto backends. | |
| void | crypt_invoke_message (SecurityFlags type) |
| Display an informative message. | |
| int | crypt_pgp_application_handler (struct Body *b_email, struct State *state) |
| Wrapper for CryptModuleSpecs::application_handler() - Implements handler_t -. | |
| bool | crypt_pgp_check_traditional (FILE *fp, struct Body *b, bool just_one) |
| Wrapper for CryptModuleSpecs::pgp_check_traditional(). | |
| int | crypt_pgp_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec) |
| Wrapper for CryptModuleSpecs::decrypt_mime(). | |
| int | crypt_pgp_encrypted_handler (struct Body *b_email, struct State *state) |
| Wrapper for CryptModuleSpecs::encrypted_handler() - Implements handler_t -. | |
| void | crypt_pgp_extract_key_from_attachment (FILE *fp, struct Body *b) |
| Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment(). | |
| void | crypt_pgp_invoke_getkeys (struct Address *addr) |
| Wrapper for CryptModuleSpecs::pgp_invoke_getkeys(). | |
| struct Body * | crypt_pgp_make_key_attachment (void) |
| Wrapper for CryptModuleSpecs::pgp_make_key_attachment(). | |
| SecurityFlags | crypt_pgp_send_menu (struct Email *e) |
| Wrapper for CryptModuleSpecs::send_menu(). | |
| int | crypt_smime_application_handler (struct Body *b_email, struct State *state) |
| Wrapper for CryptModuleSpecs::application_handler() - Implements handler_t -. | |
| int | crypt_smime_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec) |
| Wrapper for CryptModuleSpecs::decrypt_mime(). | |
| void | crypt_smime_getkeys (struct Envelope *env) |
| Wrapper for CryptModuleSpecs::smime_getkeys(). | |
| SecurityFlags | crypt_smime_send_menu (struct Email *e) |
| Wrapper for CryptModuleSpecs::send_menu(). | |
| int | crypt_smime_verify_sender (struct Email *e, struct Message *msg) |
| Wrapper for CryptModuleSpecs::smime_verify_sender(). | |
| void | crypto_module_cleanup (struct NcryptModuleData *mod_data) |
| Clean up the crypto modules. | |
| void | pgp_gpgme_init (void) |
| Initialise the crypto module - Implements CryptModuleSpecs::init() -. | |
| int | mutt_gpgme_select_secret_key (struct Buffer *keyid) |
| Select a private Autocrypt key for a new account. | |
| const char * | mutt_gpgme_print_version (void) |
| Get version of GPGME. | |
API for encryption/signing of emails.
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 lib.h.
| #define APPLICATION_SMIME (1 << 12) |
| #define PGP_TRADITIONAL_CHECKED (1 << 13) |
| #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_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) |
| typedef uint16_t SecurityFlags |
| enum SecurityFlag |
Flags describing an email's cryptographic state.
| Enumerator | |
|---|---|
| SEC_NONE | No flags are set. |
| SEC_ENCRYPT | Email is encrypted. |
| SEC_SIGN | Email is signed. |
| SEC_GOODSIGN | Email has a valid signature. |
| SEC_BADSIGN | Email has a bad signature. |
| SEC_PARTSIGN | Not all parts of the email is signed. |
| SEC_SIGNOPAQUE | Email has an opaque signature (encrypted). |
| SEC_KEYBLOCK | Email has a key attached. |
| SEC_INLINE | Email has an inline signature. |
| SEC_OPPENCRYPT | Opportunistic encrypt mode. |
| SEC_AUTOCRYPT | (Autocrypt) Message will be, or was Autocrypt encrypt+signed |
| SEC_AUTOCRYPT_OVERRIDE | (Autocrypt) Indicates manual set/unset of encryption |
Definition at line 89 of file lib.h.
| enum KeyFlag |
Flags describing PGP/SMIME keys.
Definition at line 144 of file lib.h.
Initialise the PGP Keybindings - Implements ::init_keys_api.
Definition at line 84 of file functions.c.
| void crypt_extract_keys_from_messages | ( | struct Mailbox * | m, |
| struct EmailArray * | ea ) |
Extract keys from a message.
| m | Mailbox |
| ea | Array of Emails to process |
The extracted keys will be added to the user's keyring.
Definition at line 864 of file crypt.c.
| void crypt_forget_passphrase | ( | void | ) |
Forget a passphrase and display a message.
Definition at line 89 of file crypt.c.
| int crypt_get_keys | ( | struct Email * | e, |
| char ** | keylist, | ||
| bool | oppenc_mode ) |
Check we have all the keys we need.
| [in] | e | Email with addresses to match |
| [out] | keylist | Keys needed |
| [in] | oppenc_mode | If true, use opportunistic encryption |
| 0 | Success |
| -1 | Error |
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 968 of file crypt.c.
| void crypt_opportunistic_encrypt | ( | struct Email * | e | ) |
Can all recipients be determined.
| e |
Check if all recipients keys can be automatically determined. Enable encryption if they can, otherwise disable encryption.
Definition at line 1052 of file crypt.c.
| SecurityFlags crypt_query | ( | struct Body * | b | ) |
Check out the type of encryption used.
| b | Body of email |
| num | Flags, see SecurityFlags |
| 0 | Error (SEC_NONE) |
Set the cached status values if there are any.
Definition at line 693 of file crypt.c.
| bool crypt_valid_passphrase | ( | SecurityFlags | flags | ) |
Check that we have a usable passphrase, ask if not.
| flags | Flags, see SecurityFlags |
| true | Success |
| false | Failed |
Definition at line 131 of file crypt.c.
| SecurityFlags mutt_is_application_pgp | ( | const struct Body * | b | ) |
Does the message use PGP?
| b | Body of email |
| >0 | Message uses PGP, e.g. PGP_ENCRYPT |
| 0 | Message doesn't use PGP, (SEC_NONE) |
Definition at line 549 of file crypt.c.
| SecurityFlags mutt_is_application_smime | ( | struct Body * | b | ) |
Does the message use S/MIME?
| b | Body of email |
| >0 | Message uses S/MIME, e.g. SMIME_ENCRYPT |
| 0 | Message doesn't use S/MIME, (SEC_NONE) |
Definition at line 610 of file crypt.c.
| SecurityFlags mutt_is_malformed_multipart_pgp_encrypted | ( | struct Body * | b | ) |
Check for malformed layout.
| b | Body of email |
| num | Success, see SecurityFlags |
| 0 | Error, (SEC_NONE) |
This checks for the malformed layout caused by MS Exchange in some cases:
Definition at line 505 of file crypt.c.
| SecurityFlags mutt_is_multipart_encrypted | ( | struct Body * | b | ) |
Does the message have encrypted parts?
| b | Body of email |
| num | Message has got encrypted parts, see SecurityFlags |
| 0 | Message hasn't got encrypted parts (SEC_NONE) |
Definition at line 444 of file crypt.c.
| SecurityFlags mutt_is_multipart_signed | ( | struct Body * | b | ) |
Is a message signed?
| b | Body of email |
| num | Message is signed, see SecurityFlags |
| 0 | Message is not signed (SEC_NONE) |
Definition at line 409 of file crypt.c.
| int mutt_is_valid_multipart_pgp_encrypted | ( | struct Body * | b | ) |
Is this a valid multi-part encrypted message?
| b | Body of email |
| >0 | Message is valid, with encrypted parts, e.g. PGP_ENCRYPT |
| 0 | Message hasn't got encrypted parts |
Definition at line 468 of file crypt.c.
| int mutt_protect | ( | struct Email * | e, |
| char * | keylist, | ||
| bool | postpone ) |
Encrypt and/or sign a message.
| e | |
| keylist | List of keys to encrypt to (space-separated) |
| postpone | When true, signing is automatically disabled |
| 0 | Success |
| -1 | Error |
Definition at line 156 of file crypt.c.
| bool mutt_should_hide_protected_subject | ( | struct Email * | e | ) |
Should NeoMutt hide the protected subject?
| e | Email to test |
| true | The subject should be protected |
Definition at line 1107 of file crypt.c.
| void crypt_cleanup | ( | struct NcryptModuleData * | mod_data | ) |
Clean up backend.
| mod_data | Ncrypt module data |
Definition at line 151 of file cryptglue.c.
| bool crypt_has_module_backend | ( | SecurityFlags | type | ) |
Is there a crypto backend for a given type?
| type | Crypto type, see SecurityFlags |
| true | Backend is present |
| false | Backend is not present |
Definition at line 188 of file cryptglue.c.
| void crypt_init | ( | void | ) |
Initialise the crypto backends.
This calls CryptModuleSpecs::init()
Definition at line 99 of file cryptglue.c.
| void crypt_invoke_message | ( | SecurityFlags | type | ) |
Display an informative message.
| type | Crypto type, see SecurityFlags |
Show a message that a backend will be invoked.
Definition at line 174 of file cryptglue.c.
| bool crypt_pgp_check_traditional | ( | FILE * | fp, |
| struct Body * | b, | ||
| bool | just_one ) |
Wrapper for CryptModuleSpecs::pgp_check_traditional().
Definition at line 321 of file cryptglue.c.
Wrapper for CryptModuleSpecs::decrypt_mime().
Definition at line 237 of file cryptglue.c.
| void crypt_pgp_extract_key_from_attachment | ( | FILE * | fp, |
| struct Body * | b ) |
Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment().
Definition at line 460 of file cryptglue.c.
| void crypt_pgp_invoke_getkeys | ( | struct Address * | addr | ) |
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys().
Definition at line 309 of file cryptglue.c.
| struct Body * crypt_pgp_make_key_attachment | ( | void | ) |
Wrapper for CryptModuleSpecs::pgp_make_key_attachment().
Definition at line 349 of file cryptglue.c.
| SecurityFlags crypt_pgp_send_menu | ( | struct Email * | e | ) |
Wrapper for CryptModuleSpecs::send_menu().
Definition at line 446 of file cryptglue.c.
| int crypt_smime_decrypt_mime | ( | FILE * | fp_in, |
| FILE ** | fp_out, | ||
| struct Body * | b, | ||
| struct Body ** | b_dec ) |
Wrapper for CryptModuleSpecs::decrypt_mime().
Definition at line 510 of file cryptglue.c.
| void crypt_smime_getkeys | ( | struct Envelope * | env | ) |
Wrapper for CryptModuleSpecs::smime_getkeys().
Definition at line 538 of file cryptglue.c.
| SecurityFlags crypt_smime_send_menu | ( | struct Email * | e | ) |
Wrapper for CryptModuleSpecs::send_menu().
Definition at line 632 of file cryptglue.c.
Wrapper for CryptModuleSpecs::smime_verify_sender().
Definition at line 550 of file cryptglue.c.
| void crypto_module_cleanup | ( | struct NcryptModuleData * | mod_data | ) |
Clean up the crypto modules.
| mod_data | Ncrypt module data |
Definition at line 74 of file crypt_mod.c.
| int mutt_gpgme_select_secret_key | ( | struct Buffer * | keyid | ) |
Select a private Autocrypt key for a new account.
| keyid | Autocrypt Key id |
| 0 | Success |
| -1 | Error |
Unfortunately, the internal ncrypt/crypt_gpgme.c functions use CryptKeyInfo, and so aren't exportable.
This function queries all private keys, provides the crypt_select_keys() menu, and returns the selected key fingerprint in keyid.
Definition at line 3729 of file crypt_gpgme.c.
| const char * mutt_gpgme_print_version | ( | void | ) |
Get version of GPGME.
| ptr | GPGME version string |
Definition at line 4214 of file crypt_gpgme.c.