API for encryption/signing of emails. More...
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | SEC_NO_FLAGS 0 |
No flags are set. | |
#define | SEC_ENCRYPT (1 << 0) |
Email is encrypted. | |
#define | SEC_SIGN (1 << 1) |
Email is signed. | |
#define | SEC_GOODSIGN (1 << 2) |
Email has a valid signature. | |
#define | SEC_BADSIGN (1 << 3) |
Email has a bad signature. | |
#define | SEC_PARTSIGN (1 << 4) |
Not all parts of the email is signed. | |
#define | SEC_SIGNOPAQUE (1 << 5) |
Email has an opaque signature (encrypted) | |
#define | SEC_KEYBLOCK (1 << 6) |
Email has a key attached. | |
#define | SEC_INLINE (1 << 7) |
Email has an inline signature. | |
#define | SEC_OPPENCRYPT (1 << 8) |
Opportunistic encrypt mode. | |
#define | SEC_AUTOCRYPT (1 << 9) |
(Autocrypt) Message will be, or was Autocrypt encrypt+signed | |
#define | SEC_AUTOCRYPT_OVERRIDE (1 << 10) |
(Autocrypt) Indicates manual set/unset of encryption | |
#define | APPLICATION_PGP (1 << 11) |
Use PGP to encrypt/sign. | |
#define | APPLICATION_SMIME (1 << 12) |
Use SMIME to encrypt/sign. | |
#define | PGP_TRADITIONAL_CHECKED (1 << 13) |
Email has a traditional (inline) signature. | |
#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. | |
#define | KEYFLAG_CANSIGN (1 << 0) |
Key is suitable for signing. | |
#define | KEYFLAG_CANENCRYPT (1 << 1) |
Key is suitable for encryption. | |
#define | KEYFLAG_ISX509 (1 << 2) |
Key is an X.509 key. | |
#define | KEYFLAG_SECRET (1 << 7) |
Key is a secret key. | |
#define | KEYFLAG_EXPIRED (1 << 8) |
Key is expired. | |
#define | KEYFLAG_REVOKED (1 << 9) |
Key is revoked. | |
#define | KEYFLAG_DISABLED (1 << 10) |
Key is marked disabled. | |
#define | KEYFLAG_SUBKEY (1 << 11) |
Key is a subkey. | |
#define | KEYFLAG_CRITICAL (1 << 12) |
Key is marked critical. | |
#define | KEYFLAG_PREFER_ENCRYPTION (1 << 13) |
Key's owner prefers encryption. | |
#define | KEYFLAG_PREFER_SIGNING (1 << 14) |
Key's owner prefers signing. | |
#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. | |
typedef uint16_t | KeyFlags |
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN. | |
Functions | |
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 (void) |
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 (void) |
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 SEC_PARTSIGN (1 << 4) |
#define SEC_SIGNOPAQUE (1 << 5) |
#define SEC_AUTOCRYPT (1 << 9) |
#define SEC_AUTOCRYPT_OVERRIDE (1 << 10) |
#define PGP_TRADITIONAL_CHECKED (1 << 13) |
#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_CANENCRYPT (1 << 1) |
#define KEYFLAG_PREFER_ENCRYPTION (1 << 13) |
#define KEYFLAG_PREFER_SIGNING (1 << 14) |
#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 |
Flags, e.g. SEC_ENCRYPT.
typedef uint16_t KeyFlags |
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
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 858 of file crypt.c.
void crypt_forget_passphrase | ( | void | ) |
Forget a passphrase and display a message.
Definition at line 90 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 961 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 1045 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_NO_FLAGS) |
Set the cached status values if there are any.
Definition at line 687 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 132 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_NO_FLAGS) |
Definition at line 548 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_NO_FLAGS) |
Definition at line 609 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_NO_FLAGS) |
This checks for the malformed layout caused by MS Exchange in some cases:
Definition at line 504 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_NO_FLAGS) |
Definition at line 443 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_NO_FLAGS) |
Definition at line 408 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 467 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 157 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 1100 of file crypt.c.
void crypt_cleanup | ( | void | ) |
Clean up backend.
Definition at line 141 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 170 of file cryptglue.c.
void crypt_init | ( | void | ) |
Initialise the crypto backends.
This calls CryptModuleSpecs::init()
Definition at line 93 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 156 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 282 of file cryptglue.c.
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition at line 210 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 394 of file cryptglue.c.
void crypt_pgp_invoke_getkeys | ( | struct Address * | addr | ) |
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition at line 273 of file cryptglue.c.
struct Body * crypt_pgp_make_key_attachment | ( | void | ) |
Wrapper for CryptModuleSpecs::pgp_make_key_attachment()
Definition at line 304 of file cryptglue.c.
SecurityFlags crypt_pgp_send_menu | ( | struct Email * | e | ) |
Wrapper for CryptModuleSpecs::send_menu()
Definition at line 383 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 432 of file cryptglue.c.
void crypt_smime_getkeys | ( | struct Envelope * | env | ) |
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition at line 454 of file cryptglue.c.
SecurityFlags crypt_smime_send_menu | ( | struct Email * | e | ) |
Wrapper for CryptModuleSpecs::send_menu()
Definition at line 527 of file cryptglue.c.
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition at line 463 of file cryptglue.c.
void crypto_module_cleanup | ( | void | ) |
Clean up the crypto modules.
Definition at line 84 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 3685 of file crypt_gpgme.c.
const char * mutt_gpgme_print_version | ( | void | ) |
Get version of GPGME.
ptr | GPGME version string |
Definition at line 4163 of file crypt_gpgme.c.