1 /* context.h - Definitions for a GPGME context.
2 Copyright (C) 2000 Werner Koch (dd9jn)
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2010 g10 Code GmbH
5 This file is part of GPGME.
7 GPGME is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of
10 the License, or (at your option) any later version.
12 GPGME is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this program; if not, see <https://www.gnu.org/licenses/>.
30 extern gpgme_error_t _gpgme_selftest;
32 /* Operations might require to remember arbitrary information and data
33 objects during invocations of the status handler. The
34 ctx_op_data structure provides a generic framework to hook in
35 such additional data. */
38 OPDATA_DECRYPT, OPDATA_SIGN, OPDATA_ENCRYPT, OPDATA_PASSPHRASE,
39 OPDATA_IMPORT, OPDATA_GENKEY, OPDATA_KEYLIST, OPDATA_EDIT,
40 OPDATA_VERIFY, OPDATA_TRUSTLIST, OPDATA_ASSUAN, OPDATA_VFS_MOUNT,
41 OPDATA_PASSWD, OPDATA_EXPORT, OPDATA_KEYSIGN, OPDATA_TOFU_POLICY,
46 /* "gpgmeres" in ASCII. */
47 #define CTX_OP_DATA_MAGIC 0x736572656d677067ULL
50 /* A magic word just to make sure people don't deallocate something
51 that ain't a result structure. */
52 unsigned long long magic;
54 /* The next element in the linked list, or NULL if this is the last
55 element. Used by op data structures linked into a context. */
56 struct ctx_op_data *next;
58 /* The type of the hook data, which can be used by a routine to
59 lookup the hook data. */
60 ctx_op_data_id_t type;
62 /* The function to release HOOK and all its associated resources.
63 Can be NULL if no special deallocation routine is necessary. */
64 void (*cleanup) (void *hook);
66 /* The hook that points to the operation data. */
69 /* The number of outstanding references. */
72 typedef struct ctx_op_data *ctx_op_data_t;
75 /* The context defines an environment in which crypto operations can
76 be performed (sequentially). */
81 /* True if the context was canceled asynchronously. */
84 /* The engine info for this context. */
85 gpgme_engine_info_t engine_info;
87 /* The protocol used by this context. */
88 gpgme_protocol_t protocol;
90 /* The running engine process. */
93 /* Engine's sub protocol. */
94 gpgme_protocol_t sub_protocol;
96 /* True if armor mode should be used. */
97 unsigned int use_armor : 1;
99 /* True if text mode should be used. */
100 unsigned int use_textmode : 1;
102 /* True if offline mode should be used. */
103 unsigned int offline : 1;
105 /* True if a status callback shall be called for nearly all status
107 unsigned int full_status : 1;
109 /* The Tofu info has a human readable string which is presented to
110 * the user in a directly usable format. By enabling this flag the
111 * unmodified string, as received form gpg, will be returned. */
112 unsigned int raw_description : 1;
114 /* True if session keys should be exported upon decryption. */
115 unsigned int export_session_keys : 1;
117 /* True if a Pinentry was launched during the last operation. This
118 * flag is cleared with each operation. */
119 unsigned int redraw_suggested : 1;
121 /* True if the option --auto-key-retrieve shall be passed to gpg. */
122 unsigned int auto_key_retrieve : 1;
124 /* Flags for keylist mode. */
125 gpgme_keylist_mode_t keylist_mode;
127 /* The current pinentry mode. */
128 gpgme_pinentry_mode_t pinentry_mode;
130 /* Number of certs to be included. */
131 unsigned int include_certs;
133 /* The actual number of keys in SIGNERS, the allocated size of the
134 * array, and the array with the signing keys. */
135 unsigned int signers_len;
136 unsigned int signers_size;
137 gpgme_key_t *signers;
139 /* The signature notations for this context. */
140 gpgme_sig_notation_t sig_notations;
142 /* The sender's addr-spec or NULL. */
145 /* The gpg specific override session key or NULL. */
146 char *override_session_key;
148 /* The locale for the pinentry. */
152 /* The operation data hooked into the context. */
153 ctx_op_data_t op_data;
155 /* The user provided passphrase callback and its hook value. */
156 gpgme_passphrase_cb_t passphrase_cb;
157 void *passphrase_cb_value;
159 /* The user provided progress callback and its hook value. */
160 gpgme_progress_cb_t progress_cb;
161 void *progress_cb_value;
163 /* The user provided status callback and its hook value. */
164 gpgme_status_cb_t status_cb;
165 void *status_cb_value;
167 /* A list of file descriptors in active use by the current
170 struct gpgme_io_cbs io_cbs;
173 #endif /* CONTEXT_H */