NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
crypt_gpgme.h
Go to the documentation of this file.
1
24#ifndef MUTT_NCRYPT_CRYPT_GPGME_H
25#define MUTT_NCRYPT_CRYPT_GPGME_H
26
27#include <gpgme.h>
28#include <stdbool.h>
29#include <stdio.h>
30#include "mutt/lib.h"
31#include "lib.h"
32
33struct AddressList;
34struct Body;
35struct Email;
36struct Message;
37struct State;
38
39/* We work based on user IDs, getting from a user ID to the key is
40 * check and does not need any memory (GPGME uses reference counting). */
45{
47 gpgme_key_t kobj;
48 int idx;
49 const char *uid;
51 gpgme_validity_t validity;
52};
53ARRAY_HEAD(CryptKeyInfoArray, struct CryptKeyInfo *);
54
59{
71};
72
77{
81};
82
87{
88 size_t num;
89 struct CryptKeyInfo *key;
90};
91
92void pgp_gpgme_set_sender (const char *sender);
93
94int pgp_gpgme_application_handler (struct Body *b, struct State *state);
95bool pgp_gpgme_check_traditional (FILE *fp, struct Body *b, bool just_one);
96int pgp_gpgme_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec);
97int pgp_gpgme_encrypted_handler (struct Body *b, struct State *state);
98struct Body * pgp_gpgme_encrypt_message (struct Body *b, char *keylist, bool sign, const struct AddressList *from);
99char * pgp_gpgme_find_keys (const struct AddressList *addrlist, bool oppenc_mode);
100void pgp_gpgme_invoke_import (const char *fname);
101struct Body * pgp_gpgme_make_key_attachment (void);
103struct Body * pgp_gpgme_sign_message (struct Body *b, const struct AddressList *from);
104int pgp_gpgme_verify_one (struct Body *b, struct State *state, const char *tempfile);
105
106int smime_gpgme_application_handler(struct Body *b, struct State *state);
107struct Body * smime_gpgme_build_smime_entity (struct Body *b, char *keylist);
108int smime_gpgme_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec);
109char * smime_gpgme_find_keys (const struct AddressList *addrlist, bool oppenc_mode);
110void smime_gpgme_init (void);
112struct Body * smime_gpgme_sign_message (struct Body *b, const struct AddressList *from);
113int smime_gpgme_verify_one (struct Body *b, struct State *state, const char *tempfile);
114int smime_gpgme_verify_sender (struct Email *e, struct Message *msg);
115
116gpgme_ctx_t create_gpgme_context (bool for_smime);
117struct CryptKeyInfo *crypt_copy_key (struct CryptKeyInfo *key);
118const char * crypt_fpr_or_lkeyid (struct CryptKeyInfo *k);
119bool crypt_id_is_strong (struct CryptKeyInfo *key);
120int crypt_id_is_valid (struct CryptKeyInfo *key);
121const char * crypt_keyid (struct CryptKeyInfo *k);
122int digit (const char *s);
123unsigned int key_check_cap (gpgme_key_t key, enum KeyCap cap);
124
125#endif /* MUTT_NCRYPT_CRYPT_GPGME_H */
#define ARRAY_HEAD(name, type)
Define a named struct for arrays of elements of a certain type.
Definition: array.h:47
struct CryptKeyInfo * crypt_copy_key(struct CryptKeyInfo *key)
Return a copy of KEY.
Definition: crypt_gpgme.c:234
int crypt_id_is_valid(struct CryptKeyInfo *key)
Is key ID valid.
Definition: crypt_gpgme.c:310
gpgme_ctx_t create_gpgme_context(bool for_smime)
Create a new GPGME context.
Definition: crypt_gpgme.c:361
bool crypt_id_is_strong(struct CryptKeyInfo *key)
Is the key strong.
Definition: crypt_gpgme.c:275
const char * crypt_fpr_or_lkeyid(struct CryptKeyInfo *k)
Find the fingerprint of a key.
Definition: crypt_gpgme.c:214
KeyInfo
PGP Key info.
Definition: crypt_gpgme.h:59
@ KIP_FINGERPRINT
PGP Key field: Fingerprint.
Definition: crypt_gpgme.h:66
@ KIP_SERIAL_NO
PGP Key field: Serial number.
Definition: crypt_gpgme.h:67
@ KIP_SUBKEY
PGP Key field: Subkey.
Definition: crypt_gpgme.h:69
@ KIP_AKA
PGP Key field: aka (Also Known As)
Definition: crypt_gpgme.h:61
@ KIP_VALID_FROM
PGP Key field: Valid From date.
Definition: crypt_gpgme.h:62
@ KIP_MAX
Definition: crypt_gpgme.h:70
@ KIP_KEY_TYPE
PGP Key field: Key Type.
Definition: crypt_gpgme.h:64
@ KIP_NAME
PGP Key field: Name.
Definition: crypt_gpgme.h:60
@ KIP_ISSUED_BY
PGP Key field: Issued By.
Definition: crypt_gpgme.h:68
@ KIP_KEY_USAGE
PGP Key field: Key Usage.
Definition: crypt_gpgme.h:65
@ KIP_VALID_TO
PGP Key field: Valid To date.
Definition: crypt_gpgme.h:63
int digit(const char *s)
unsigned int key_check_cap(gpgme_key_t key, enum KeyCap cap)
Check the capabilities of a key.
Definition: crypt_gpgme.c:2948
const char * crypt_keyid(struct CryptKeyInfo *k)
Find the ID for the key.
Definition: crypt_gpgme.c:138
KeyCap
PGP/SMIME Key Capabilities.
Definition: crypt_gpgme.h:77
@ KEY_CAP_CAN_CERTIFY
Key can be used to certify.
Definition: crypt_gpgme.h:80
@ KEY_CAP_CAN_ENCRYPT
Key can be used for encryption.
Definition: crypt_gpgme.h:78
@ KEY_CAP_CAN_SIGN
Key can be used for signing.
Definition: crypt_gpgme.h:79
int pgp_gpgme_application_handler(struct Body *b, struct State *state)
Manage the MIME type "application/pgp" or "application/smime" - Implements CryptModuleSpecs::applicat...
Definition: crypt_gpgme.c:2470
int smime_gpgme_application_handler(struct Body *b, struct State *state)
Manage the MIME type "application/pgp" or "application/smime" - Implements CryptModuleSpecs::applicat...
Definition: crypt_gpgme.c:2856
int smime_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Decrypt an encrypted MIME part - Implements CryptModuleSpecs::decrypt_mime() -.
Definition: crypt_gpgme.c:1993
int pgp_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Decrypt an encrypted MIME part - Implements CryptModuleSpecs::decrypt_mime() -.
Definition: crypt_gpgme.c:1896
int pgp_gpgme_encrypted_handler(struct Body *b, struct State *state)
Manage a PGP or S/MIME encrypted MIME part - Implements CryptModuleSpecs::encrypted_handler() -.
Definition: crypt_gpgme.c:2766
char * smime_gpgme_find_keys(const struct AddressList *addrlist, bool oppenc_mode)
Find the keyids of the recipients of a message - Implements CryptModuleSpecs::find_keys() -.
Definition: crypt_gpgme.c:3667
char * pgp_gpgme_find_keys(const struct AddressList *addrlist, bool oppenc_mode)
Find the keyids of the recipients of a message - Implements CryptModuleSpecs::find_keys() -.
Definition: crypt_gpgme.c:3659
void smime_gpgme_init(void)
Initialise the crypto module - Implements CryptModuleSpecs::init() -.
Definition: crypt_gpgme.c:3874
bool pgp_gpgme_check_traditional(FILE *fp, struct Body *b, bool just_one)
Look for inline (non-MIME) PGP content - Implements CryptModuleSpecs::pgp_check_traditional() -.
Definition: crypt_gpgme.c:2278
struct Body * pgp_gpgme_encrypt_message(struct Body *b, char *keylist, bool sign, const struct AddressList *from)
PGP encrypt an email - Implements CryptModuleSpecs::pgp_encrypt_message() -.
Definition: crypt_gpgme.c:1043
void pgp_gpgme_invoke_import(const char *fname)
Import a key from a message into the user's public key ring - Implements CryptModuleSpecs::pgp_invoke...
Definition: crypt_gpgme.c:2305
struct Body * pgp_gpgme_make_key_attachment(void)
Generate a public key attachment - Implements CryptModuleSpecs::pgp_make_key_attachment() -.
Definition: crypt_gpgme.c:3766
SecurityFlags pgp_gpgme_send_menu(struct Email *e)
Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.
Definition: crypt_gpgme.c:4047
SecurityFlags smime_gpgme_send_menu(struct Email *e)
Ask the user whether to sign and/or encrypt the email - Implements CryptModuleSpecs::send_menu() -.
Definition: crypt_gpgme.c:4055
void pgp_gpgme_set_sender(const char *sender)
Set the sender of the email - Implements CryptModuleSpecs::set_sender() -.
Definition: crypt_gpgme.c:4152
struct Body * smime_gpgme_sign_message(struct Body *b, const struct AddressList *from)
Cryptographically sign the Body of a message - Implements CryptModuleSpecs::sign_message() -.
Definition: crypt_gpgme.c:1035
struct Body * pgp_gpgme_sign_message(struct Body *b, const struct AddressList *from)
Cryptographically sign the Body of a message - Implements CryptModuleSpecs::sign_message() -.
Definition: crypt_gpgme.c:1027
struct Body * smime_gpgme_build_smime_entity(struct Body *b, char *keylist)
Encrypt the email body to all recipients - Implements CryptModuleSpecs::smime_build_smime_entity() -.
Definition: crypt_gpgme.c:1089
int smime_gpgme_verify_sender(struct Email *e, struct Message *msg)
Does the sender match the certificate? - Implements CryptModuleSpecs::smime_verify_sender() -.
Definition: crypt_gpgme.c:4144
int pgp_gpgme_verify_one(struct Body *b, struct State *state, const char *tempfile)
Check a signed MIME part against a signature - Implements CryptModuleSpecs::verify_one() -.
Definition: crypt_gpgme.c:1706
int smime_gpgme_verify_one(struct Body *b, struct State *state, const char *tempfile)
Check a signed MIME part against a signature - Implements CryptModuleSpecs::verify_one() -.
Definition: crypt_gpgme.c:1714
Convenience wrapper for the library headers.
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:76
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
Definition: lib.h:125
Key value store.
The body of an email.
Definition: body.h:36
An entry in the Select-Key menu.
Definition: crypt_gpgme.h:87
struct CryptKeyInfo * key
Key.
Definition: crypt_gpgme.h:89
size_t num
Index number.
Definition: crypt_gpgme.h:88
A stored PGP key.
Definition: crypt_gpgme.h:45
gpgme_validity_t validity
uid validity (cached for convenience)
Definition: crypt_gpgme.h:51
KeyFlags flags
global and per uid flags (for convenience)
Definition: crypt_gpgme.h:50
int idx
and the user ID at this index
Definition: crypt_gpgme.h:48
struct CryptKeyInfo * next
Linked list.
Definition: crypt_gpgme.h:46
const char * uid
and for convenience point to this user ID
Definition: crypt_gpgme.h:49
gpgme_key_t kobj
Definition: crypt_gpgme.h:47
The envelope/body of an email.
Definition: email.h:39
A local copy of an email.
Definition: message.h:34
Keep track when processing files.
Definition: state.h:48