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 /* Flags for keylist mode. */
122 gpgme_keylist_mode_t keylist_mode;
124 /* The current pinentry mode. */
125 gpgme_pinentry_mode_t pinentry_mode;
127 /* Number of certs to be included. */
128 unsigned int include_certs;
130 /* The actual number of keys in SIGNERS, the allocated size of the
131 * array, and the array with the signing keys. */
132 unsigned int signers_len;
133 unsigned int signers_size;
134 gpgme_key_t *signers;
136 /* The signature notations for this context. */
137 gpgme_sig_notation_t sig_notations;
139 /* The sender's addr-spec or NULL. */
142 /* The gpg specific override session key or NULL. */
143 char *override_session_key;
145 /* The locale for the pinentry. */
149 /* The operation data hooked into the context. */
150 ctx_op_data_t op_data;
152 /* The user provided passphrase callback and its hook value. */
153 gpgme_passphrase_cb_t passphrase_cb;
154 void *passphrase_cb_value;
156 /* The user provided progress callback and its hook value. */
157 gpgme_progress_cb_t progress_cb;
158 void *progress_cb_value;
160 /* The user provided status callback and its hook value. */
161 gpgme_status_cb_t status_cb;
162 void *status_cb_value;
164 /* A list of file descriptors in active use by the current
167 struct gpgme_io_cbs io_cbs;
170 #endif /* CONTEXT_H */