NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
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 "lib.h"
31 
32 struct AddressList;
33 struct Body;
34 struct Email;
35 struct Mailbox;
36 struct Message;
37 struct 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 {
46  struct CryptKeyInfo *next;
47  gpgme_key_t kobj;
48  int idx;
49  const char *uid;
51  gpgme_validity_t validity;
52 };
53 
57 enum KeyInfo
58 {
59  KIP_NAME = 0,
70 };
71 
75 enum KeyCap
76 {
80 };
81 
82 void pgp_gpgme_set_sender(const char *sender);
83 
84 int pgp_gpgme_application_handler(struct Body *m, struct State *s);
85 bool pgp_gpgme_check_traditional(FILE *fp, struct Body *b, bool just_one);
86 int pgp_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
87 int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s);
88 struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, bool sign, const struct AddressList *from);
89 char * pgp_gpgme_find_keys(struct AddressList *addrlist, bool oppenc_mode);
90 void pgp_gpgme_invoke_import(const char *fname);
92 SecurityFlags pgp_gpgme_send_menu(struct Mailbox *m, struct Email *e);
93 struct Body *pgp_gpgme_sign_message(struct Body *a, const struct AddressList *from);
94 int pgp_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile);
95 
96 int smime_gpgme_application_handler(struct Body *a, struct State *s);
97 struct Body *smime_gpgme_build_smime_entity(struct Body *a, char *keylist);
98 int smime_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
99 char * smime_gpgme_find_keys(struct AddressList *addrlist, bool oppenc_mode);
100 void smime_gpgme_init(void);
101 SecurityFlags smime_gpgme_send_menu(struct Mailbox *m, struct Email *e);
102 struct Body *smime_gpgme_sign_message(struct Body *a, const struct AddressList *from);
103 int smime_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile);
104 int smime_gpgme_verify_sender(struct Mailbox *m, struct Email *e, struct Message *msg);
105 
106 bool crypt_id_is_strong(struct CryptKeyInfo *key);
107 int digit(const char *s);
108 const char *crypt_fpr_or_lkeyid(struct CryptKeyInfo *k);
109 unsigned int key_check_cap(gpgme_key_t key, enum KeyCap cap);
110 gpgme_ctx_t create_gpgme_context(bool for_smime);
111 const char *crypt_keyid(struct CryptKeyInfo *k);
112 int crypt_id_is_valid(struct CryptKeyInfo *key);
113 struct CryptKeyInfo *crypt_copy_key(struct CryptKeyInfo *key);
114 
115 #endif /* MUTT_NCRYPT_CRYPT_GPGME_H */
int smime_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Implements CryptModuleSpecs::decrypt_mime() -.
Definition: crypt_gpgme.c:2302
bool crypt_id_is_strong(struct CryptKeyInfo *key)
Is the key strong.
Definition: crypt_gpgme.c:484
PGP Key field: Valid To date.
Definition: crypt_gpgme.h:62
The envelope/body of an email.
Definition: email.h:37
struct Body * smime_gpgme_sign_message(struct Body *a, const struct AddressList *from)
Implements CryptModuleSpecs::sign_message() -.
Definition: crypt_gpgme.c:1387
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:2208
PGP Key field: Serial number.
Definition: crypt_gpgme.h:66
SecurityFlags pgp_gpgme_send_menu(struct Mailbox *m, struct Email *e)
Implements CryptModuleSpecs::send_menu() -.
Definition: crypt_gpgme.c:4354
int smime_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
Implements CryptModuleSpecs::verify_one() -.
Definition: crypt_gpgme.c:2035
unsigned int key_check_cap(gpgme_key_t key, enum KeyCap cap)
Check the capabilities of a key.
Definition: crypt_gpgme.c:3256
int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s)
Implements CryptModuleSpecs::encrypted_handler() -This handler is passed the application/octet-stream...
Definition: crypt_gpgme.c:3061
struct Body * smime_gpgme_build_smime_entity(struct Body *a, char *keylist)
Implements CryptModuleSpecs::smime_build_smime_entity() -.
Definition: crypt_gpgme.c:1441
int smime_gpgme_application_handler(struct Body *a, struct State *s)
Implements CryptModuleSpecs::application_handler() -.
Definition: crypt_gpgme.c:3158
Key can be used for encryption.
Definition: crypt_gpgme.h:77
Key can be used for signing.
Definition: crypt_gpgme.h:78
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:71
PGP Key field: Key Usage.
Definition: crypt_gpgme.h:64
struct CryptKeyInfo * next
Definition: crypt_gpgme.h:46
char * pgp_gpgme_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Implements CryptModuleSpecs::find_keys() -.
Definition: crypt_gpgme.c:3950
The body of an email.
Definition: body.h:34
bool pgp_gpgme_check_traditional(FILE *fp, struct Body *b, bool just_one)
Implements CryptModuleSpecs::pgp_check_traditional() -.
Definition: crypt_gpgme.c:2640
A stored PGP key.
Definition: crypt_gpgme.h:44
int idx
and the user ID at this index
Definition: crypt_gpgme.h:48
PGP Key field: Key Type.
Definition: crypt_gpgme.h:63
PGP Key field: Valid From date.
Definition: crypt_gpgme.h:61
char * smime_gpgme_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Implements CryptModuleSpecs::find_keys() -.
Definition: crypt_gpgme.c:3958
KeyInfo
PGP Key info.
Definition: crypt_gpgme.h:57
void pgp_gpgme_invoke_import(const char *fname)
Implements CryptModuleSpecs::pgp_invoke_import() -.
Definition: crypt_gpgme.c:2665
PGP Key field: Name.
Definition: crypt_gpgme.h:59
int pgp_gpgme_application_handler(struct Body *m, struct State *s)
Implements CryptModuleSpecs::application_handler() -.
Definition: crypt_gpgme.c:2831
const char * uid
and for convenience point to this user ID
Definition: crypt_gpgme.h:49
A local copy of an email.
Definition: mxapi.h:41
A mailbox.
Definition: mailbox.h:81
struct Body * pgp_gpgme_sign_message(struct Body *a, const struct AddressList *from)
Implements CryptModuleSpecs::sign_message() -.
Definition: crypt_gpgme.c:1379
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
Definition: lib.h:122
const char * crypt_keyid(struct CryptKeyInfo *k)
Find the ID for the key.
Definition: crypt_gpgme.c:347
gpgme_key_t kobj
Definition: crypt_gpgme.h:47
int crypt_id_is_valid(struct CryptKeyInfo *key)
Is key ID valid.
Definition: crypt_gpgme.c:519
Key can be used to certify.
Definition: crypt_gpgme.h:79
struct Body * pgp_gpgme_encrypt_message(struct Body *a, char *keylist, bool sign, const struct AddressList *from)
Implements CryptModuleSpecs::pgp_encrypt_message() -.
Definition: crypt_gpgme.c:1395
API for encryption/signing of emails.
PGP Key field: Fingerprint.
Definition: crypt_gpgme.h:65
struct CryptKeyInfo * crypt_copy_key(struct CryptKeyInfo *key)
Return a copy of KEY.
Definition: crypt_gpgme.c:443
SecurityFlags smime_gpgme_send_menu(struct Mailbox *m, struct Email *e)
Implements CryptModuleSpecs::send_menu() -.
Definition: crypt_gpgme.c:4362
void smime_gpgme_init(void)
Implements CryptModuleSpecs::init() -.
Definition: crypt_gpgme.c:4173
KeyFlags flags
global and per uid flags (for convenience)
Definition: crypt_gpgme.h:50
const char * crypt_fpr_or_lkeyid(struct CryptKeyInfo *k)
Find the fingerprint of a key.
Definition: crypt_gpgme.c:423
gpgme_ctx_t create_gpgme_context(bool for_smime)
Create a new GPGME context.
Definition: crypt_gpgme.c:571
int digit(const char *s)
Keep track when processing files.
Definition: state.h:44
gpgme_validity_t validity
uid validity (cached for convenience)
Definition: crypt_gpgme.h:51
KeyCap
PGP/SMIME Key Capabilities.
Definition: crypt_gpgme.h:75
PGP Key field: aka (Also Known As)
Definition: crypt_gpgme.h:60
void pgp_gpgme_set_sender(const char *sender)
Implements CryptModuleSpecs::set_sender() -.
Definition: crypt_gpgme.c:4456
PGP Key field: Issued By.
Definition: crypt_gpgme.h:67
int smime_gpgme_verify_sender(struct Mailbox *m, struct Email *e, struct Message *msg)
Implements CryptModuleSpecs::smime_verify_sender() -.
Definition: crypt_gpgme.c:4448
int pgp_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
Implements CryptModuleSpecs::verify_one() -.
Definition: crypt_gpgme.c:2027
PGP Key field: Subkey.
Definition: crypt_gpgme.h:68
struct Body * pgp_gpgme_make_key_attachment(void)
Implements CryptModuleSpecs::pgp_make_key_attachment() -.
Definition: crypt_gpgme.c:4057