1 module gpgme.gpgme;
2 
3 import gpgerror.gpgerror;
4 
5 import std.bitmanip;
6 import core.stdc.stdio;
7 import core.stdc.time;
8 
9 /* gpgme.h - Public interface to GnuPG Made Easy.                   -*- c -*-
10  * Copyright (C) 2000 Werner Koch (dd9jn)
11  * Copyright (C) 2001-2015 g10 Code GmbH
12  *
13  * This file is part of GPGME.
14  *
15  * GPGME is free software; you can redistribute it and/or modify it
16  * under the terms of the GNU Lesser General Public License as
17  * published by the Free Software Foundation; either version 2.1 of
18  * the License, or (at your option) any later version.
19  *
20  * GPGME is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * Lesser General Public License for more details.
24  *
25  * You should have received a copy of the GNU Lesser General Public
26  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
27  *
28  * Generated from gpgme.h.in for x86_64-unknown-linux-gnu.
29  */
30 
31 /* The version of this header should match the one of the library.  Do
32    not use this symbol in your application, use gpgme_check_version
33    instead.  The purpose of this macro is to let autoconf (using the
34    AM_PATH_GPGME macro) check that this header matches the installed
35    library.  */
36 static const(char*) GPGME_VERSION = "1.6.0";
37 
38 /* The version number of this header.  It may be used to handle minor API incompatibilities.  */
39 enum GPGME_VERSION_NUMBER = 0x010600;
40 
41 
42 alias off_t = long;
43 alias gpgme_off_t = off_t;
44 alias gpgme_ssize_t = ptrdiff_t ;
45 /*
46  * Some opaque data types used by GPGME.
47  */
48 
49 extern(C) nothrow @nogc {
50 
51 	alias engine_status_handler_t = gpgme_error_t function(void* priv, gpgme_status_code_t code, char* args);
52 	alias engine_colon_line_handler_t = gpgme_error_t function(void* priv, char* line);
53 	alias engine_command_handler_t = gpgme_error_t function(void* priv, gpgme_status_code_t code, const(char*) keyword, int fd, int* processed);
54 	alias engine_assuan_result_cb_t = gpgme_error_t function(void* priv, gpgme_error_t result);
55 
56 }
57 
58 struct critsect_s {
59 	const(char*) name;
60 	void* priv;
61 };
62 
63 struct engine_ops {
64 	
65 	/* Static functions.  */
66 
67 	/* Return the default file name for the binary of this engine.  */
68 	const(char*) function() get_file_name;
69 
70 	/* Return the default home dir for the binary of this engine.  If
71      this function pointer is not set, the standard default home dir
72      of the engine is used. */
73 	const(char*) function() get_home_dir;
74 
75 	/* Returns a malloced string containing the version of the engine
76      with the given binary file name (or the default if FILE_NAME is
77      NULL.  */
78 	char* function(const(char*) file_name) get_version;
79 
80 	/* Returns a statically allocated string containing the required version.  */
81 	const(char*) function() get_req_version;
82 
83 	gpgme_error_t function(void** r_engine, const(char*) file_name, const(char*) home_dir) new_;
84 
85 	/* Member functions.  */
86 	void function(void* engine) release;
87 	
88 	gpgme_error_t function(void* engine) reset;
89 	
90 	void function(void* engine, engine_status_handler_t fnc, void* fnc_value) set_status_handler;
91 	
92 	gpgme_error_t function(void* engine, engine_command_handler_t fnc, void* fnc_value, gpgme_data_t data) set_command_handler;
93 	gpgme_error_t function(void* engine, engine_colon_line_handler_t fnc, void* fnc_value) set_colon_line_handler;
94 	gpgme_error_t function(void* engine, int category, const(char*) value) set_locale;
95 	gpgme_error_t function(void* engine, gpgme_protocol_t protocol) set_protocol;
96 	gpgme_error_t function(void* engine, gpgme_data_t ciph, gpgme_data_t plain) decrypt;
97 	gpgme_error_t function(void* engine, gpgme_data_t ciph, gpgme_data_t plain) decrypt_verify;
98 	gpgme_error_t function(void* engine, gpgme_key_t key, int allow_secret) delete_;
99 	gpgme_error_t function(void* engine, int type, gpgme_key_t key, gpgme_data_t out_, gpgme_ctx_t ctx /* FIXME */) edit;
100 	gpgme_error_t function(void* engine, gpgme_key_t[] recp, gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t ciph, int use_armor) encrypt;
101 	gpgme_error_t function(void* engine, gpgme_key_t[] recp, gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t ciph, int use_armor, gpgme_ctx_t ctx /* FIXME */) encrypt_sign;
102 	gpgme_error_t function(void* engine, const(char*) pattern, gpgme_export_mode_t mode, gpgme_data_t keydata, int use_armor) export_;
103 	gpgme_error_t function(void* engine, const(char*)[] pattern, gpgme_export_mode_t mode, gpgme_data_t keydata, int use_armor) export_ext;
104 	gpgme_error_t function(void* engine, gpgme_data_t help_data, int use_armor, gpgme_data_t pubkey, gpgme_data_t seckey) genkey;
105 	gpgme_error_t function(void* engine, gpgme_data_t keydata, gpgme_key_t* keyarray) import_;
106 	gpgme_error_t function(void* engine, const(char*) pattern, int secret_only, gpgme_keylist_mode_t mode, int engine_flags) keylist;
107 	gpgme_error_t function(void* engine, const(char*)[] pattern, int secret_only, int reserved, gpgme_keylist_mode_t mode, int engine_flags) keylist_ext;
108 	gpgme_error_t function(void* engine, gpgme_data_t in_, gpgme_data_t out_, gpgme_sig_mode_t mode, int use_armor, int use_textmode, int include_certs, gpgme_ctx_t ctx /* FIXME */) sign;
109 	gpgme_error_t function(void* engine, const(char*) pattern) trustlist;
110 	gpgme_error_t function(void* engine, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext) verify;
111 	gpgme_error_t function(void* engine, gpgme_data_t output, uint flags) getauditlog;
112 	gpgme_error_t function(void* engine, const(char*) command, gpgme_assuan_data_cb_t data_cb, void* data_cb_value, gpgme_assuan_inquire_cb_t inq_cb, void* inq_cb_value, gpgme_assuan_status_cb_t status_cb, void* status_cb_value) opassuan_transact;
113 
114 	gpgme_error_t function(void* engine, gpgme_conf_comp_t* conf_p) conf_load;
115 	gpgme_error_t function(void* engine, gpgme_conf_comp_t conf) conf_save;
116 
117 	void function(void* engine, gpgme_io_cbs_t io_cbs) set_io_cbs;
118 	void function(void* engine, gpgme_event_io_t type, void* type_data) io_event;
119 
120 	/* Cancel the whole engine session.  */
121 	gpgme_error_t function(void* engine) cancel;
122 
123 	/* Cancel only the current operation, not the whole session.  */
124 	gpgme_error_t function(void* engine) cancel_op;
125 
126 	/* Change the passphrase for KEY. */
127 	gpgme_error_t function(void* engine, gpgme_key_t key, uint flags) passwd;
128 
129 	/* Set the pinentry mode.  */
130 	gpgme_error_t function(void* engine, gpgme_pinentry_mode_t mode) set_pinentry_mode;
131 
132 	/* The spawn command.  */
133 	gpgme_error_t function(void* engine, const(char*) file, const(char*)[] argv, gpgme_data_t datain, gpgme_data_t dataout, gpgme_data_t dataerr, uint flags) opspawn;
134 
135 }
136 
137 struct engine {
138 	engine_ops* ops;
139 	void* engine;
140 }
141 
142 alias engine_t = engine*;
143 
144 enum ctx_op_data_id_t {
145 	OPDATA_DECRYPT, 
146 	OPDATA_SIGN, 
147 	OPDATA_ENCRYPT, 
148 	OPDATA_PASSPHRASE,
149  	OPDATA_IMPORT, 
150 	OPDATA_GENKEY, 
151 	OPDATA_KEYLIST, 
152 	OPDATA_EDIT,
153 	OPDATA_VERIFY, 
154 	OPDATA_TRUSTLIST, 
155 	OPDATA_ASSUAN, 
156 	OPDATA_VFS_MOUNT
157 }
158 
159 struct ctx_op_data {
160 	/* A magic word just to make sure people don't deallocate something
161      that ain't a result structure.  */
162 	ulong magic;
163 
164 	/* The next element in the linked list, or NULL if this is the last
165      element.  Used by op data structures linked into a context.  */
166 	ctx_op_data* next;
167 
168 	/* The type of the hook data, which can be used by a routine to
169      lookup the hook data.  */
170 	ctx_op_data_id_t type;
171 
172 	/* The function to release HOOK and all its associated resources.
173      Can be NULL if no special deallocation routine is necessary.  */
174 	void function(void* hook) cleanup;
175 
176 	/* The hook that points to the operation data.  */
177 	void* hook;
178 
179 	/* The number of outstanding references.  */
180 	int references;
181 }
182 
183 alias ctx_op_data_t = ctx_op_data*;
184 
185 struct spawn_fd_item_s {
186 	int fd;
187 	int dup_to;
188 	int peer_name;
189 	int arg_loc;
190 }
191 
192 struct io_select_fd_s {
193 	int fd;
194 	int for_read;
195 	int for_write;
196 	int signaled;
197 	void* opaque;
198 }
199 
200 struct fd_table {
201 	io_select_fd_s* fds;
202 	size_t size;
203 }
204 
205 alias fd_table_t = fd_table*;
206 
207 /* The context holds some global state and configuration options, as well as the results of a crypto operation.  */
208 struct gpgme_context {
209 	
210   	critsect_s lock;
211 
212 	/* True if the context was canceled asynchronously.  */
213 	int canceled;
214 	
215 	/* The engine info for this context.  */
216 	gpgme_engine_info_t engine_info;
217 	
218 	/* The protocol used by this context.  */
219 	gpgme_protocol_t protocol;
220 	
221 	/* The running engine process.  */
222 	engine_t engine;
223 	
224 	/* Engine's sub protocol.  */
225 	gpgme_protocol_t sub_protocol;
226 	
227 	mixin(bitfields!(
228         uint, "use_armor",    1, /* True if armor mode should be used.  */
229         uint,  "use_textmode",    1, /* True if text mode should be used.  */
230         uint,  "offline",    1, /* True if offline mode should be used.  */
231         uint, "_unused",    29
232     ));
233 	
234 	 /* Flags for keylist mode.  */
235 	gpgme_keylist_mode_t keylist_mode;
236 	
237 	/* The current pinnetry mode.  */
238 	gpgme_pinentry_mode_t pinentry_mode;
239 	
240 	/* Number of certs to be included.  */
241 	uint include_certs;
242 	
243 	/* The number of keys in signers.  */
244 	uint signers_len;
245 	
246 	/* Size of the following array.  */
247 	uint signers_size;
248 	gpgme_key_t *signers;
249 	
250 	/* The signature notations for this context.  */
251 	gpgme_sig_notation_t sig_notations;
252 	
253 	/* The locale for the pinentry.  */
254 	char* lc_ctype;
255 	char* lc_messages;
256 	
257 	/* The operation data hooked into the context.  */
258 	ctx_op_data_t op_data;
259 	
260 	/* The user provided passphrase callback and its hook value.  */
261 	gpgme_passphrase_cb_t passphrase_cb;
262 	void* passphrase_cb_value;
263 	
264 	/* The user provided progress callback and its hook value.  */
265 	gpgme_progress_cb_t progress_cb;
266 	void* progress_cb_value;
267 	
268 	/* The user provided status callback and its hook value.  */
269 	gpgme_status_cb_t status_cb;
270 	void* status_cb_value;
271 	
272 	/* A list of file descriptors in active use by the current operation.  */
273 	fd_table fdt;
274 	gpgme_io_cbs io_cbs;
275 }
276 
277 alias gpgme_ctx_t = gpgme_context*;
278 	
279 extern(C) nothrow @nogc {
280 
281 	/* Read up to SIZE bytes into buffer BUFFER from the data object with
282 	   the handle DH.  Return the number of characters read, 0 on EOF and
283 	   -1 on error.  If an error occurs, errno is set.  */
284 	alias gpgme_data_read_cb = ptrdiff_t function(gpgme_data_t dh, void* buffer, size_t size);
285 	
286 	/* Write up to SIZE bytes from buffer BUFFER to the data object with
287 	   the handle DH.  Return the number of characters written, or -1 on
288 	   error.  If an error occurs, errno is set.  */
289 	alias gpgme_data_write_cb = ptrdiff_t function(gpgme_data_t dh, const(void*) buffer, size_t size);
290 	
291 	/* Set the current position from where the next read or write starts
292 	   in the data object with the handle DH to OFFSET, relativ to
293 	   WHENCE.  */
294 	alias gpgme_data_seek_cb = off_t function(gpgme_data_t dh, off_t offset, int whence);
295 	
296 	/* Release the data object with the handle DH.  */
297 	alias gpgme_data_release_cb = void function(gpgme_data_t dh);
298 	
299 	/* Get the FD associated with the handle DH, or -1.  */
300 	alias gpgme_data_get_fd_cb = int function(gpgme_data_t dh);
301 	
302 }	
303 	
304 struct _gpgme_data_cbs {
305 	gpgme_data_read_cb read;
306 	gpgme_data_write_cb write;
307 	gpgme_data_seek_cb seek;
308 	gpgme_data_release_cb release;
309 	gpgme_data_get_fd_cb get_fd;
310 }
311 	
312 /* The data object is used by GPGME to exchange arbitrary data.  */
313 enum BUFFER_SIZE = 512;
314 
315 struct gpgme_data {
316 	_gpgme_data_cbs* cbs;
317 	gpgme_data_encoding_t encoding;
318 
319 	char[BUFFER_SIZE] pending;
320 	int pending_len;
321 
322 	/* File name of the data object.  */
323 	char* file_name;
324 
325 	union data_uni {
326 		/* For gpgme_data_new_from_fd.  */
327 		int fd;
328 
329 		/* For gpgme_data_new_from_stream.  */
330 		FILE* stream;
331 
332 		/* For gpgme_data_new_from_cbs.  */
333 		struct user_str {
334 			gpgme_data_cbs_t cbs;
335 			void* handle;
336 		}
337     
338 		user_str user;
339 
340 		/* For gpgme_data_new_from_mem.  */
341 		struct mem_str {
342 			char* buffer;
343 			const(char*) orig_buffer;
344 			/* Allocated size of BUFFER.  */
345 			size_t size;
346 			size_t length;
347 			gpgme_off_t offset;
348 		}
349 
350 		mem_str mem;
351 	
352 		/* For gpgme_data_new_from_read_cb.  */
353 		struct old_user_str {
354 			int function(void*, char*, size_t, size_t*) cb;
355 			void* handle;
356 		}
357 		
358 		old_user_str old_user;
359 		
360 	}
361 	
362 	data_uni data;
363 }
364 
365 alias gpgme_data_t = gpgme_data*;
366 
367 /*
368  * Wrappers for the libgpg-error library.
369  */
370 
371 alias gpgme_error_t = gpg_error_t;
372 alias gpgme_err_code_t = gpg_err_code_t;
373 alias gpgme_err_source_t = gpg_err_source_t;
374 
375 extern(C) nothrow @nogc {
376 	
377 	static gpgme_error_t gpgme_err_make(gpgme_err_source_t source, gpgme_err_code_t code) {
378 		return gpg_err_make(source, code);
379 	}
380 
381 	/* The user can define GPGME_ERR_SOURCE_DEFAULT before including this file to specify a default source for gpgme_error.  */
382 	enum GPGME_ERR_SOURCE_DEFAULT = gpg_err_source_t.GPG_ERR_SOURCE_USER_1;
383 	
384 	static gpgme_error_t gpgme_error(gpgme_err_code_t code) {
385 		return gpgme_err_make(GPGME_ERR_SOURCE_DEFAULT, code);
386 	}
387 	
388 	static gpgme_err_code_t gpgme_err_code(gpgme_error_t err) {
389 		return gpg_err_code(err);
390 	}
391 	
392 	static gpgme_err_source_t gpgme_err_source(gpgme_error_t err) {
393 		return gpg_err_source(err);
394 	}
395 	/* Return a pointer to a string containing a description of the error code in the error value ERR.  This function is not thread safe.  */
396 	const(char*) gpgme_strerror(gpgme_error_t err);
397 	
398 	/* Return the error string for ERR in the user-supplied buffer BUF of
399 	   size BUFLEN.  This function is, in contrast to gpg_strerror,
400 	   thread-safe if a thread-safe strerror_r() function is provided by
401 	   the system.  If the function succeeds, 0 is returned and BUF
402 	   contains the string describing the error.  If the buffer was not
403 	   large enough, ERANGE is returned and BUF contains as much of the
404 	   beginning of the error string as fits into the buffer.  */
405 	int gpgme_strerror_r(gpg_error_t err, char *buf, size_t buflen);
406 	
407 	/* Return a pointer to a string containing a description of the error source in the error value ERR.  */
408 	const(char*) gpgme_strsource(gpgme_error_t err);
409 	
410 	/* Retrieve the error code for the system error ERR.  This returns
411 	   GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
412 	   this).  */
413 	gpgme_err_code_t gpgme_err_code_from_errno(int err);
414 	
415 	/* Retrieve the system error for the error code CODE.  This returns 0 if CODE is not a system error code.  */
416 	int gpgme_err_code_to_errno(gpgme_err_code_t code);
417 	
418 	/* Retrieve the error code directly from the ERRNO variable.  This
419 	   returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
420 	   (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
421 	gpgme_err_code_t gpgme_err_code_from_syserror();
422 	
423 	/* Set the ERRNO variable.  This function is the preferred way to set ERRNO due to peculiarities on WindowsCE.  */
424 	void gpgme_err_set_errno(int err);
425 	
426 	/* Return an error value with the error source SOURCE and the system error ERR.  FIXME: Should be inline.  */
427 	gpgme_error_t gpgme_err_make_from_errno(gpgme_err_source_t source, int err);
428 	
429 	/* Return an error value with the system error ERR.  FIXME: Should be inline.  */
430 	gpgme_error_t gpgme_error_from_errno(int err);
431 	
432 	static gpgme_error_t gpgme_error_from_syserror() {
433 		return gpgme_error(gpgme_err_code_from_syserror());
434 	}
435 
436 }
437 
438 /*
439  * Various constants and types
440  */
441 
442 /* The possible encoding mode of gpgme_data_t objects.  */
443 enum gpgme_data_encoding_t  {
444 	GPGME_DATA_ENCODING_NONE   = 0,	/* Not specified.  */
445 	GPGME_DATA_ENCODING_BINARY = 1,
446 	GPGME_DATA_ENCODING_BASE64 = 2,
447 	GPGME_DATA_ENCODING_ARMOR  = 3,	/* Either PEM or OpenPGP Armor.  */
448 	GPGME_DATA_ENCODING_URL    = 4,     /* LF delimited URL list.        */
449 	GPGME_DATA_ENCODING_URLESC = 5,     /* Ditto, but percent escaped.   */
450 	GPGME_DATA_ENCODING_URL0   = 6      /* Nul delimited URL list.       */
451 }
452 
453 /* Known data types.  */
454 enum gpgme_data_type_t {
455 	GPGME_DATA_TYPE_INVALID      = 0,   /* Not detected.  */
456 	GPGME_DATA_TYPE_UNKNOWN      = 1,
457 	GPGME_DATA_TYPE_PGP_SIGNED   = 0x10,
458 	GPGME_DATA_TYPE_PGP_OTHER    = 0x12,
459 	GPGME_DATA_TYPE_PGP_KEY      = 0x13,
460 	GPGME_DATA_TYPE_CMS_SIGNED   = 0x20,
461 	GPGME_DATA_TYPE_CMS_ENCRYPTED= 0x21,
462 	GPGME_DATA_TYPE_CMS_OTHER    = 0x22,
463 	GPGME_DATA_TYPE_X509_CERT    = 0x23,
464 	GPGME_DATA_TYPE_PKCS12       = 0x24,
465 }
466 
467 /* Public key algorithms.  */
468 enum gpgme_pubkey_algo_t {
469 	GPGME_PK_RSA   = 1,
470 	GPGME_PK_RSA_E = 2,
471 	GPGME_PK_RSA_S = 3,
472 	GPGME_PK_ELG_E = 16,
473 	GPGME_PK_DSA   = 17,
474 	GPGME_PK_ECC   = 18,
475 	GPGME_PK_ELG   = 20,
476 	GPGME_PK_ECDSA = 301,
477 	GPGME_PK_ECDH  = 302
478 }
479 
480 /* Hash algorithms (the values match those from libgcrypt).  */
481 enum gpgme_hash_algo_t {
482 	GPGME_MD_NONE          = 0,
483 	GPGME_MD_MD5           = 1,
484 	GPGME_MD_SHA1          = 2,
485 	GPGME_MD_RMD160        = 3,
486 	GPGME_MD_MD2           = 5,
487 	GPGME_MD_TIGER         = 6,   /* TIGER/192. */
488 	GPGME_MD_HAVAL         = 7,   /* HAVAL, 5 pass, 160 bit. */
489 	GPGME_MD_SHA256        = 8,
490 	GPGME_MD_SHA384        = 9,
491 	GPGME_MD_SHA512        = 10,
492 	GPGME_MD_SHA224        = 11,
493 	GPGME_MD_MD4           = 301,
494 	GPGME_MD_CRC32	   = 302,
495 	GPGME_MD_CRC32_RFC1510 = 303,
496 	GPGME_MD_CRC24_RFC2440 = 304
497 }
498 
499 /* The possible signature stati.  Deprecated, use error value in sig status.  */
500 deprecated enum _gpgme_sig_stat_t {
501 	GPGME_SIG_STAT_NONE  = 0,
502 	GPGME_SIG_STAT_GOOD  = 1,
503 	GPGME_SIG_STAT_BAD   = 2,
504 	GPGME_SIG_STAT_NOKEY = 3,
505 	GPGME_SIG_STAT_NOSIG = 4,
506 	GPGME_SIG_STAT_ERROR = 5,
507 	GPGME_SIG_STAT_DIFF  = 6,
508 	GPGME_SIG_STAT_GOOD_EXP = 7,
509 	GPGME_SIG_STAT_GOOD_EXPKEY = 8
510 }
511 
512 deprecated alias gpgme_sig_stat_t = _gpgme_sig_stat_t;
513 
514 /* The available signature modes.  */
515 enum gpgme_sig_mode_t { 
516 	GPGME_SIG_MODE_NORMAL = 0,
517 	GPGME_SIG_MODE_DETACH = 1,
518 	GPGME_SIG_MODE_CLEAR  = 2
519 }
520 
521 /* The available key and signature attributes.  Deprecated, use the
522    individual result structures instead.  */
523 deprecated enum _gpgme_attr_t {
524 	GPGME_ATTR_KEYID        = 1,
525 	GPGME_ATTR_FPR          = 2,
526 	GPGME_ATTR_ALGO         = 3,
527 	GPGME_ATTR_LEN          = 4,
528 	GPGME_ATTR_CREATED      = 5,
529 	GPGME_ATTR_EXPIRE       = 6,
530 	GPGME_ATTR_OTRUST       = 7,
531 	GPGME_ATTR_USERID       = 8,
532 	GPGME_ATTR_NAME         = 9,
533 	GPGME_ATTR_EMAIL        = 10,
534 	GPGME_ATTR_COMMENT      = 11,
535 	GPGME_ATTR_VALIDITY     = 12,
536 	GPGME_ATTR_LEVEL        = 13,
537 	GPGME_ATTR_TYPE         = 14,
538 	GPGME_ATTR_IS_SECRET    = 15,
539 	GPGME_ATTR_KEY_REVOKED  = 16,
540 	GPGME_ATTR_KEY_INVALID  = 17,
541 	GPGME_ATTR_UID_REVOKED  = 18,
542 	GPGME_ATTR_UID_INVALID  = 19,
543 	GPGME_ATTR_KEY_CAPS     = 20,
544 	GPGME_ATTR_CAN_ENCRYPT  = 21,
545 	GPGME_ATTR_CAN_SIGN     = 22,
546 	GPGME_ATTR_CAN_CERTIFY  = 23,
547 	GPGME_ATTR_KEY_EXPIRED  = 24,
548 	GPGME_ATTR_KEY_DISABLED = 25,
549 	GPGME_ATTR_SERIAL       = 26,
550 	GPGME_ATTR_ISSUER       = 27,
551 	GPGME_ATTR_CHAINID      = 28,
552 	GPGME_ATTR_SIG_STATUS   = 29,
553 	GPGME_ATTR_ERRTOK       = 30,
554 	GPGME_ATTR_SIG_SUMMARY  = 31,
555 	GPGME_ATTR_SIG_CLASS    = 32
556 }
557 
558 deprecated alias gpgme_attr_t = _gpgme_attr_t;
559 
560 /* The available validities for a trust item or key.  */
561 enum gpgme_validity_t {
562 	GPGME_VALIDITY_UNKNOWN   = 0,
563 	GPGME_VALIDITY_UNDEFINED = 1,
564 	GPGME_VALIDITY_NEVER     = 2,
565 	GPGME_VALIDITY_MARGINAL  = 3,
566 	GPGME_VALIDITY_FULL      = 4,
567 	GPGME_VALIDITY_ULTIMATE  = 5
568 }
569 
570 /* The available protocols.  */
571 enum gpgme_protocol_t {
572 	GPGME_PROTOCOL_OpenPGP = 0,  /* The default mode.  */
573 	GPGME_PROTOCOL_OPENPGP = 0,  /* Convenience macro for the surprisingly mixed spelling.  */
574 	GPGME_PROTOCOL_CMS     = 1,
575 	GPGME_PROTOCOL_GPGCONF = 2,  /* Special code for gpgconf.  */
576 	GPGME_PROTOCOL_ASSUAN  = 3,  /* Low-level access to an Assuan server.  */
577 	GPGME_PROTOCOL_G13     = 4,
578 	GPGME_PROTOCOL_UISERVER= 5,
579 	GPGME_PROTOCOL_SPAWN   = 6,  /* Direct access to any program.  */
580 	GPGME_PROTOCOL_DEFAULT = 254,
581 	GPGME_PROTOCOL_UNKNOWN = 255
582 }
583 
584 /* The available keylist mode flags.  */
585 enum gpgme_keylist_mode_t : uint {
586 	GPGME_KEYLIST_MODE_LOCAL 		= 1,
587 	GPGME_KEYLIST_MODE_EXTERN 		= 2,
588 	GPGME_KEYLIST_MODE_SIGS			= 4,
589 	GPGME_KEYLIST_MODE_SIG_NOTATIONS= 8,
590 	GPGME_KEYLIST_MODE_WITH_SECRET 	= 16,
591 	GPGME_KEYLIST_MODE_EPHEMERAL 	= 128,
592 	GPGME_KEYLIST_MODE_VALIDATE		= 256
593 }
594 
595 /* The pinentry modes. */
596 enum gpgme_pinentry_mode_t {
597 	GPGME_PINENTRY_MODE_DEFAULT  = 0,
598 	GPGME_PINENTRY_MODE_ASK      = 1,
599 	GPGME_PINENTRY_MODE_CANCEL   = 2,
600 	GPGME_PINENTRY_MODE_ERROR    = 3,
601 	GPGME_PINENTRY_MODE_LOOPBACK = 4
602 }
603 
604 /* The available export mode flags.  */
605 enum gpgme_export_mode_t : uint {
606 	GPGME_EXPORT_MODE_EXTERN 	= 2,
607 	GPGME_EXPORT_MODE_MINIMAL 	= 4,
608 	GPGME_EXPORT_MODE_SECRET 	= 16,
609 	GPGME_EXPORT_MODE_RAW 		= 32,
610 	GPGME_EXPORT_MODE_PKCS12 	= 64
611 }
612 
613 /* Flags for the audit log functions.  */
614 enum {
615 	GPGME_AUDITLOG_HTML 	= 1,
616 	GPGME_AUDITLOG_WITH_HELP= 128
617 }
618 
619 /* The possible stati for the edit operation.  */
620 enum gpgme_status_code_t {
621 	GPGME_STATUS_EOF = 0,
622 	/* mkstatus processing starts here */
623 	GPGME_STATUS_ENTER = 1,
624 	GPGME_STATUS_LEAVE = 2,
625 	GPGME_STATUS_ABORT = 3,
626 
627 	GPGME_STATUS_GOODSIG = 4,
628 	GPGME_STATUS_BADSIG = 5,
629 	GPGME_STATUS_ERRSIG = 6,
630 
631 	GPGME_STATUS_BADARMOR = 7,
632 
633 	GPGME_STATUS_RSA_OR_IDEA = 8,      /* (legacy) */
634 	GPGME_STATUS_KEYEXPIRED = 9,
635 	GPGME_STATUS_KEYREVOKED = 10,
636 
637 	GPGME_STATUS_TRUST_UNDEFINED = 11,
638 	GPGME_STATUS_TRUST_NEVER = 12,
639 	GPGME_STATUS_TRUST_MARGINAL = 13,
640 	GPGME_STATUS_TRUST_FULLY = 14,
641 	GPGME_STATUS_TRUST_ULTIMATE = 15,
642 
643 	GPGME_STATUS_SHM_INFO = 16,        /* (legacy) */
644 	GPGME_STATUS_SHM_GET = 17,         /* (legacy) */
645 	GPGME_STATUS_SHM_GET_BOOL = 18,    /* (legacy) */
646 	GPGME_STATUS_SHM_GET_HIDDEN = 19,  /* (legacy) */
647 
648 	GPGME_STATUS_NEED_PASSPHRASE = 20,
649 	GPGME_STATUS_VALIDSIG = 21,
650 	GPGME_STATUS_SIG_ID = 22,
651 	GPGME_STATUS_ENC_TO = 23,
652 	GPGME_STATUS_NODATA = 24,
653 	GPGME_STATUS_BAD_PASSPHRASE = 25,
654 	GPGME_STATUS_NO_PUBKEY = 26,
655 	GPGME_STATUS_NO_SECKEY = 27,
656 	GPGME_STATUS_NEED_PASSPHRASE_SYM = 28,
657 	GPGME_STATUS_DECRYPTION_FAILED = 29,
658 	GPGME_STATUS_DECRYPTION_OKAY = 30,
659 	GPGME_STATUS_MISSING_PASSPHRASE = 31,
660 	GPGME_STATUS_GOOD_PASSPHRASE = 32,
661 	GPGME_STATUS_GOODMDC = 33,
662 	GPGME_STATUS_BADMDC = 34,
663 	GPGME_STATUS_ERRMDC = 35,
664 	GPGME_STATUS_IMPORTED = 36,
665 	GPGME_STATUS_IMPORT_OK = 37,
666 	GPGME_STATUS_IMPORT_PROBLEM = 38,
667 	GPGME_STATUS_IMPORT_RES = 39,
668 	GPGME_STATUS_FILE_START = 40,
669 	GPGME_STATUS_FILE_DONE = 41,
670 	GPGME_STATUS_FILE_ERROR = 42,
671 
672 	GPGME_STATUS_BEGIN_DECRYPTION = 43,
673 	GPGME_STATUS_END_DECRYPTION = 44,
674 	GPGME_STATUS_BEGIN_ENCRYPTION = 45,
675 	GPGME_STATUS_END_ENCRYPTION = 46,
676 
677 	GPGME_STATUS_DELETE_PROBLEM = 47,
678 	GPGME_STATUS_GET_BOOL = 48,
679 	GPGME_STATUS_GET_LINE = 49,
680 	GPGME_STATUS_GET_HIDDEN = 50,
681 	GPGME_STATUS_GOT_IT = 51,
682 	GPGME_STATUS_PROGRESS = 52,
683 	GPGME_STATUS_SIG_CREATED = 53,
684 	GPGME_STATUS_SESSION_KEY = 54,
685 	GPGME_STATUS_NOTATION_NAME = 55,
686 	GPGME_STATUS_NOTATION_DATA = 56,
687 	GPGME_STATUS_POLICY_URL = 57,
688 	GPGME_STATUS_BEGIN_STREAM = 58,    /* (legacy) */
689 	GPGME_STATUS_END_STREAM = 59,      /* (legacy) */
690 	GPGME_STATUS_KEY_CREATED = 60,
691 	GPGME_STATUS_USERID_HINT = 61,
692 	GPGME_STATUS_UNEXPECTED = 62,
693 	GPGME_STATUS_INV_RECP = 63,
694 	GPGME_STATUS_NO_RECP = 64,
695 	GPGME_STATUS_ALREADY_SIGNED = 65,
696 	GPGME_STATUS_SIGEXPIRED = 66,      /* (legacy) */
697 	GPGME_STATUS_EXPSIG = 67,
698 	GPGME_STATUS_EXPKEYSIG = 68,
699 	GPGME_STATUS_TRUNCATED = 69,
700 	GPGME_STATUS_ERROR = 70,
701 	GPGME_STATUS_NEWSIG = 71,
702 	GPGME_STATUS_REVKEYSIG = 72,
703 	GPGME_STATUS_SIG_SUBPACKET = 73,
704 	GPGME_STATUS_NEED_PASSPHRASE_PIN = 74,
705 	GPGME_STATUS_SC_OP_FAILURE = 75,
706 	GPGME_STATUS_SC_OP_SUCCESS = 76,
707 	GPGME_STATUS_CARDCTRL = 77,
708 	GPGME_STATUS_BACKUP_KEY_CREATED = 78,
709 	GPGME_STATUS_PKA_TRUST_BAD = 79,
710 	GPGME_STATUS_PKA_TRUST_GOOD = 80,
711 	GPGME_STATUS_PLAINTEXT = 81,
712 	GPGME_STATUS_INV_SGNR = 82,
713 	GPGME_STATUS_NO_SGNR = 83,
714 	GPGME_STATUS_SUCCESS = 84,
715 	GPGME_STATUS_DECRYPTION_INFO = 85,
716 	GPGME_STATUS_PLAINTEXT_LENGTH = 86,
717 	GPGME_STATUS_MOUNTPOINT = 87,
718 	GPGME_STATUS_PINENTRY_LAUNCHED = 88,
719 	GPGME_STATUS_ATTRIBUTE = 89,
720 	GPGME_STATUS_BEGIN_SIGNING = 90,
721 	GPGME_STATUS_KEY_NOT_CREATED = 91,
722 	GPGME_STATUS_INQUIRE_MAXLEN = 92,
723 	GPGME_STATUS_FAILURE = 93
724 }
725 
726 /* The available signature notation flags.  */
727 enum gpgme_sig_notation_flags_t : uint {
728 	GPGME_SIG_NOTATION_HUMAN_READABLE 	= 1,
729 	GPGME_SIG_NOTATION_CRITICAL 		= 2
730 }
731 
732 struct _gpgme_sig_notation {
733 	_gpgme_sig_notation* next;
734 
735 	/* If NAME is a null pointer, then VALUE contains a policy URL
736 		rather than a notation.  */
737 	char* name;
738 
739 	/* The value of the notation data.  */
740 	char* value;
741 
742 	/* The length of the name of the notation data.  */
743 	int name_len;
744 
745 	/* The length of the value of the notation data.  */
746 	int value_len;
747 
748 	/* The accumulated flags.  */
749 	gpgme_sig_notation_flags_t flags;
750 	
751 	mixin(bitfields!(
752         uint, "human_readable",    1, /* The accumulated flags.  */
753         uint,  "critical",    1, /* Notation data is human-readable.  */
754         int, "_unused",    30 /* Internal to GPGME, do not use.  */
755     ));
756 }
757 
758 alias gpgme_sig_notation_t = _gpgme_sig_notation*;
759 
760 
761 /*
762  * Public structures.
763  */
764 
765 
766 /* The engine information structure.  */
767 struct _gpgme_engine_info {
768 	_gpgme_engine_info* next;
769 
770 	/* The protocol ID.  */
771 	gpgme_protocol_t protocol;
772 
773 	/* The file name of the engine binary.  */
774 	char* file_name;
775 
776 	/* The version string of the installed engine.  */
777 	char* version_;
778 
779 	/* The minimum version required for GPGME.  */
780 	const char *req_version;
781 
782 	/* The home directory used, or NULL if default.  */
783 	char *home_dir;
784 }
785 
786 alias gpgme_engine_info_t = _gpgme_engine_info*;
787 
788 /* A subkey from a key.  */
789 struct _gpgme_subkey {
790 	_gpgme_subkey* next;
791 	
792 	mixin(bitfields!(
793         uint, "revoked",	1, /* True if subkey is revoked.  */
794         uint,  "expired",	1, /* True if subkey is expired.  */
795         uint, "disabled",	1, /* True if subkey is disabled.  */
796         uint, "invalid",	1, /* True if subkey is invalid.  */
797         uint, "can_encrypt",	1, /* True if subkey can be used for encryption.  */
798         uint, "can_sign",		1, /* True if subkey can be used for signing.  */
799         uint, "can_certify",	1, /* True if subkey can be used for certification.  */
800         uint, "secret",		1, /* True if subkey is secret.  */
801         uint, "can_authenticate",	1, /* True if subkey can be used for authentication.  */
802         uint, "is_qualified",	1, /* True if subkey is qualified for signatures according to German law.  */
803         uint, "is_cardkey",	1, /* True if the secret key is stored on a smart card.  */
804         uint, "_unused",	21 /* Internal to GPGME, do not use.  */
805     ));
806 
807 	/* Public key algorithm supported by this subkey.  */
808 	gpgme_pubkey_algo_t pubkey_algo;
809 
810 	/* Length of the subkey.  */
811 	uint length;
812 
813 	/* The key ID of the subkey.  */
814 	char* keyid;
815 
816 	/* Internal to GPGME, do not use.  */
817 	char[16 + 1] _keyid;
818 
819 	/* The fingerprint of the subkey in hex digit form.  */
820 	char* fpr;
821 
822 	/* The creation timestamp, -1 if invalid, 0 if not available.  */
823 	long timestamp;
824 
825 	/* The expiration timestamp, 0 if the subkey does not expire.  */
826 	long expires;
827 
828 	/* The serial number of a smart card holding this key or NULL.  */
829 	char* card_number;
830 
831 	/* The name of the curve for ECC algorithms or NULL.  */
832 	char* curve;
833 }
834 
835 alias gpgme_subkey_t = _gpgme_subkey*;
836 
837 /* A signature on a user ID.  */
838 struct _gpgme_key_sig {
839 	_gpgme_key_sig* next;
840 	
841 	mixin(bitfields!(
842         uint, "revoked",	1, /* True if the signature is a revocation signature.  */
843         uint, "expired",	1, /* True if the signature is expired.  */
844         uint, "invalid",	1, /* True if the signature is invalid.  */
845         uint, "exportable",	1, /* True if the signature should be exported.  */
846         uint, "_unused",	28, /* Internal to GPGME, do not use.  */
847     ));
848 
849 	/* The public key algorithm used to create the signature.  */
850 	gpgme_pubkey_algo_t pubkey_algo;
851 
852 	/* The key ID of key used to create the signature.  */
853 	char* keyid;
854 
855 	/* Internal to GPGME, do not use.  */
856 	char[16 + 1] _keyid;
857 
858 	/* The creation timestamp, -1 if invalid, 0 if not available.  */
859 	long timestamp;
860 
861 	/* The expiration timestamp, 0 if the subkey does not expire.  */
862 	long expires;
863 
864 	/* Same as in gpgme_signature_t.  */
865 	gpgme_error_t status;
866 	
867 	deprecated uint _obsolete_class; // ???
868 
869 	/* The user ID string.  */
870 	char* uid;
871 
872 	/* The name part of the user ID.  */
873 	char* name;
874 
875 	/* The email part of the user ID.  */
876 	char* email;
877 
878 	/* The comment part of the user ID.  */
879 	char* comment;
880 
881 	/* Crypto backend specific signature class.  */
882 	uint sig_class;
883 
884 	/* Notation data and policy URLs.  */
885 	gpgme_sig_notation_t notations;
886 
887 	/* Internal to GPGME, do not use.  */
888 	gpgme_sig_notation_t _last_notation;
889 }
890 
891 alias gpgme_key_sig_t = _gpgme_key_sig*;
892 
893 /* An user ID from a key.  */
894 struct _gpgme_user_id {
895 	_gpgme_user_id* next;
896 
897 	mixin(bitfields!(
898         uint, "revoked",	1, /* True if the user ID is revoked.  */
899         uint, "invalid",	1, /* True if the user ID is invalid.  */
900         uint, "_unused",	30, /* Internal to GPGME, do not use.  */
901     ));
902 	
903 	/* The validity of the user ID.  */
904 	gpgme_validity_t validity;
905 
906 	/* The user ID string.  */
907 	char* uid;
908 
909 	/* The name part of the user ID.  */
910 	char* name;
911 
912 	/* The email part of the user ID.  */
913 	char* email;
914 
915 	/* The comment part of the user ID.  */
916 	char* comment;
917 
918 	/* The signatures of the user ID.  */
919 	gpgme_key_sig_t signatures;
920 
921 	/* Internal to GPGME, do not use.  */
922 	gpgme_key_sig_t _last_keysig;
923 }
924 
925 alias gpgme_user_id_t = _gpgme_user_id*;
926 
927 /* A key from the keyring.  */
928 struct _gpgme_key {
929 	/* Internal to GPGME, do not use.  */
930 	uint _refs;
931 	
932 	mixin(bitfields!(
933         uint, "revoked",	1, /* True if key is revoked.  */
934         uint, "expired",	1, /* True if key is expired.  */
935         uint, "disabled",	1, /* True if key is invalid.  */
936         uint, "invalid",	1, /* True if key is invalid.  */
937         uint, "can_encrypt",	1, /* True if key can be used for encryption.  */
938         uint, "can_sign",	1, /* True if key can be used for signing.  */
939         uint, "can_certify",	1, /* True if key can be used for certification.  */
940         uint, "secret",		1, /* True if key is secret.  */
941         uint, "can_authenticate",	1, /* True if key can be used for authentication.  */
942         uint, "is_qualified",	1, /* True if subkey is qualified for signatures according to German law.  */
943         uint, "_unused",	22, /* Internal to GPGME, do not use.  */
944     ));
945 
946 	/* This is the protocol supported by this key.  */
947 	gpgme_protocol_t protocol;
948 
949 	/* If protocol is GPGME_PROTOCOL_CMS, this string contains the
950 		issuer serial.  */
951 	char* issuer_serial;
952 
953 	/* If protocol is GPGME_PROTOCOL_CMS, this string contains the
954 		issuer name.  */
955 	char* issuer_name;
956 
957 	/* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
958 		ID.  */
959 	char* chain_id;
960 
961 	/* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
962 		owner trust.  */
963 	gpgme_validity_t owner_trust;
964 
965 	/* The subkeys of the key.  */
966 	gpgme_subkey_t subkeys;
967 
968 	/* The user IDs of the key.  */
969 	gpgme_user_id_t uids;
970 
971 	/* Internal to GPGME, do not use.  */
972 	gpgme_subkey_t _last_subkey;
973 
974 	/* Internal to GPGME, do not use.  */
975 	gpgme_user_id_t _last_uid;
976 
977 	/* The keylist mode that was active when listing the key.  */
978 	gpgme_keylist_mode_t keylist_mode;
979 }
980 
981 alias gpgme_key_t = _gpgme_key*;
982 
983 /* An invalid key object.  */
984 struct _gpgme_invalid_key {
985 	_gpgme_invalid_key* next;
986 	char* fpr;
987 	gpgme_error_t reason;
988 }
989 
990 alias gpgme_invalid_key_t = _gpgme_invalid_key*;
991 
992 
993 /*
994  * Types for callback functions.
995  */
996 
997 extern(C) nothrow @nogc {
998 	
999 	/* Request a passphrase from the user.  */
1000 	alias gpgme_passphrase_cb_t = gpgme_error_t function(void* hook, const(char*) uid_hint,	const(char*) passphrase_info, int prev_was_bad, int fd);
1001 
1002 	/* Inform the user about progress made.  */
1003 	alias gpgme_progress_cb_t = void function(void* opaque, const(char*) what, int type, int current, int total);
1004 
1005 	/* Status messages from gpg. */
1006 	alias gpgme_status_cb_t = gpgme_error_t function(void* opaque, const(char*) keyword, const(char*) args);
1007 
1008 	/* Interact with the user about an edit operation.  */
1009 	alias gpgme_edit_cb_t = gpgme_error_t function(void* opaque, gpgme_status_code_t status, const(char*) args, int fd);
1010 
1011 }
1012 
1013 
1014 /*
1015  * Context management functions.
1016  */
1017 
1018 
1019 extern(C) nothrow @nogc {
1020 	
1021 	/* Create a new context and return it in CTX.  */
1022 	gpgme_error_t gpgme_new(gpgme_ctx_t* ctx);
1023 	
1024 	/* Release the context CTX.  */
1025 	void gpgme_release(gpgme_ctx_t ctx);
1026 	
1027 	/* Set the protocol to be used by CTX to PROTO.  */
1028 	gpgme_error_t gpgme_set_protocol(gpgme_ctx_t ctx, gpgme_protocol_t proto);
1029 	
1030 	/* Get the protocol used with CTX */
1031 	gpgme_protocol_t gpgme_get_protocol(gpgme_ctx_t ctx);
1032 	
1033 	/* Set the crypto protocol to be used by CTX to PROTO.
1034 	   gpgme_set_protocol actually sets the backend engine.  This sets the
1035 	   crypto protocol used in engines that support more than one crypto
1036 	   prococol (for example, an UISERVER can support OpenPGP and CMS).
1037 	   This is reset to the default with gpgme_set_protocol.  */
1038 	gpgme_error_t gpgme_set_sub_protocol(gpgme_ctx_t ctx, gpgme_protocol_t proto);
1039 	
1040 	/* Get the sub protocol.  */
1041 	gpgme_protocol_t gpgme_get_sub_protocol(gpgme_ctx_t ctx);
1042 	
1043 	/* Get the string describing protocol PROTO, or NULL if invalid.  */
1044 	const(char*) gpgme_get_protocol_name(gpgme_protocol_t proto);
1045 	
1046 	/* If YES is non-zero, enable armor mode in CTX, disable it otherwise.  */
1047 	void gpgme_set_armor(gpgme_ctx_t ctx, int yes);
1048 	
1049 	/* Return non-zero if armor mode is set in CTX.  */
1050 	int gpgme_get_armor(gpgme_ctx_t ctx);
1051 	
1052 	/* If YES is non-zero, enable text mode in CTX, disable it otherwise.  */
1053 	void gpgme_set_textmode(gpgme_ctx_t ctx, int yes);
1054 	
1055 	/* Return non-zero if text mode is set in CTX.  */
1056 	int gpgme_get_textmode(gpgme_ctx_t ctx);
1057 	
1058 	/* If YES is non-zero, enable offline mode in CTX, disable it otherwise.  */
1059 	void gpgme_set_offline(gpgme_ctx_t ctx, int yes);
1060 	
1061 	/* Return non-zero if offline mode is set in CTX.  */
1062 	int gpgme_get_offline(gpgme_ctx_t ctx);
1063 	
1064 	/* Use whatever the default of the backend crypto engine is.  */
1065 	enum GPGME_INCLUDE_CERTS_DEFAULT = -256;
1066 	
1067 	/* Include up to NR_OF_CERTS certificates in an S/MIME message.  */
1068 	void gpgme_set_include_certs(gpgme_ctx_t ctx, int nr_of_certs);
1069 	
1070 	/* Return the number of certs to include in an S/MIME message.  */
1071 	int gpgme_get_include_certs(gpgme_ctx_t ctx);
1072 	
1073 	/* Set keylist mode in CTX to MODE.  */
1074 	gpgme_error_t gpgme_set_keylist_mode(gpgme_ctx_t ctx, gpgme_keylist_mode_t mode);
1075 	
1076 	/* Get keylist mode in CTX.  */
1077 	gpgme_keylist_mode_t gpgme_get_keylist_mode(gpgme_ctx_t ctx);
1078 	
1079 	/* Set the pinentry mode for CTX to MODE. */
1080 	gpgme_error_t gpgme_set_pinentry_mode(gpgme_ctx_t ctx, gpgme_pinentry_mode_t mode);
1081 	
1082 	/* Get the pinentry mode of CTX.  */
1083 	gpgme_pinentry_mode_t gpgme_get_pinentry_mode(gpgme_ctx_t ctx);
1084 	
1085 	/* Set the passphrase callback function in CTX to CB.  HOOK_VALUE is passed as first argument to the passphrase callback function.  */
1086 	void gpgme_set_passphrase_cb(gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, void* hook_value);
1087 	
1088 	/* Get the current passphrase callback function in *CB and the current hook value in *HOOK_VALUE.  */
1089 	void gpgme_get_passphrase_cb(gpgme_ctx_t ctx, gpgme_passphrase_cb_t* cb, void** hook_value);
1090 	
1091 	/* Set the progress callback function in CTX to CB.  HOOK_VALUE is passed as first argument to the progress callback function.  */
1092 	void gpgme_set_progress_cb(gpgme_ctx_t c, gpgme_progress_cb_t cb, void* hook_value);
1093 	
1094 	/* Get the current progress callback function in *CB and the current hook value in *HOOK_VALUE.  */
1095 	void gpgme_get_progress_cb(gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
1096 				    void **hook_value);
1097 	
1098 	/* Set the status callback function in CTX to CB.  HOOK_VALUE is passed as first argument to thes status callback function.  */
1099 	void gpgme_set_status_cb(gpgme_ctx_t c, gpgme_status_cb_t cb, void* hook_value);
1100 	
1101 	/* Get the current status callback function in *CB and the current hook value in *HOOK_VALUE.  */
1102 	void gpgme_get_status_cb(gpgme_ctx_t ctx, gpgme_status_cb_t *cb, void** hook_value);
1103 	
1104 	/* This function sets the locale for the context CTX, or the default locale if CTX is a null pointer.  */
1105 	gpgme_error_t gpgme_set_locale(gpgme_ctx_t ctx, int category, const(char*) value);
1106 	
1107 	/* Get the information about the configured engines.  A pointer to the
1108 	   first engine in the statically allocated linked list is returned.
1109 	   The returned data is valid until the next gpgme_ctx_set_engine_info.  */
1110 	gpgme_engine_info_t gpgme_ctx_get_engine_info(gpgme_ctx_t ctx);
1111 	
1112 	/* Set the engine info for the context CTX, protocol PROTO, to the file name FILE_NAME and the home directory HOME_DIR.  */
1113 	gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx, gpgme_protocol_t proto, const(char*) file_name, const(char*) home_dir);
1114 	
1115 	/* Delete all signers from CTX.  */
1116 	void gpgme_signers_clear(gpgme_ctx_t ctx);
1117 	
1118 	/* Add KEY to list of signers in CTX.  */
1119 	gpgme_error_t gpgme_signers_add(gpgme_ctx_t ctx, const gpgme_key_t key);
1120 	
1121 	/* Return the number of signers in CTX.  */
1122 	uint gpgme_signers_count(const gpgme_ctx_t ctx);
1123 	
1124 	/* Return the SEQth signer's key in CTX.  */
1125 	gpgme_key_t gpgme_signers_enum(const gpgme_ctx_t ctx, int seq);
1126 	
1127 	/* Retrieve the signature status of signature IDX in CTX after a
1128 	   successful verify operation in R_STAT (if non-null).  The creation
1129 	   time stamp of the signature is returned in R_CREATED (if non-null).
1130 	   The function returns a string containing the fingerprint.
1131 	   Deprecated, use verify result directly.  */
1132 	deprecated const(char*) gpgme_get_sig_status(gpgme_ctx_t ctx, int idx, _gpgme_sig_stat_t* r_stat, time_t* r_created);
1133 	
1134 	/* Retrieve certain attributes of a signature.  IDX is the index
1135 	   number of the signature after a successful verify operation.  WHAT
1136 	   is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
1137 	   one.  WHATIDX is to be passed as 0 for most attributes . */
1138 	deprecated ulong gpgme_get_sig_ulong_attr(gpgme_ctx_t c, int idx, _gpgme_attr_t what, int whatidx);
1139 	
1140 	deprecated const(char*) gpgme_get_sig_string_attr(gpgme_ctx_t c, int idx, _gpgme_attr_t what, int whatidx);
1141 	
1142 	/* Get the key used to create signature IDX in CTX and return it in R_KEY.  */
1143 	deprecated gpgme_error_t gpgme_get_sig_key(gpgme_ctx_t ctx, int idx, gpgme_key_t* r_key);
1144 	
1145 	/* Clear all notation data from the context.  */
1146 	void gpgme_sig_notation_clear(gpgme_ctx_t ctx);
1147 	
1148 	/* Add the human-readable notation data with name NAME and value VALUE
1149 	   to the context CTX, using the flags FLAGS.  If NAME is NULL, then
1150 	   VALUE should be a policy URL.  The flag
1151 	   GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
1152 	   data, and false for policy URLs.  */
1153 	gpgme_error_t gpgme_sig_notation_add(gpgme_ctx_t ctx, const(char*) name, const(char*) value, gpgme_sig_notation_flags_t flags);
1154 	
1155 	/* Get the sig notations for this context.  */
1156 	gpgme_sig_notation_t gpgme_sig_notation_get(gpgme_ctx_t ctx);
1157 
1158 }
1159 
1160 
1161 /*
1162  * Run control.
1163  */
1164 
1165 enum gpgme_event_io_t {
1166 	GPGME_EVENT_START,
1167 	GPGME_EVENT_DONE,
1168 	GPGME_EVENT_NEXT_KEY,
1169 	GPGME_EVENT_NEXT_TRUSTITEM
1170 }
1171 
1172 struct gpgme_io_event_done_data {
1173 	/* A fatal IPC error or an operational error in state-less protocols.  */
1174 	gpgme_error_t err;
1175 
1176 	/* An operational errors in session-based protocols.  */
1177 	gpgme_error_t op_err;
1178 }
1179 
1180 alias gpgme_io_event_done_data_t = gpgme_io_event_done_data*;
1181 
1182 struct gpgme_io_cbs {
1183 	gpgme_register_io_cb_t add;
1184 	void* add_priv;
1185 	gpgme_remove_io_cb_t remove;
1186 	gpgme_event_io_cb_t event;
1187 	void* event_priv;
1188 }
1189 
1190 alias gpgme_io_cbs_t = gpgme_io_cbs*;
1191 
1192 extern(C) nothrow @nogc {
1193 	
1194 	/* The type of an I/O callback function.  */
1195 	alias gpgme_io_cb_t = gpgme_error_t function(void* data, int fd);
1196 
1197 	/* The type of a function that can register FNC as the I/O callback
1198 	   function for the file descriptor FD with direction dir (0: for writing,
1199 	   1: for reading).  FNC_DATA should be passed as DATA to FNC.  The
1200 	   function should return a TAG suitable for the corresponding
1201 	   gpgme_remove_io_cb_t, and an error value.  */
1202 	alias gpgme_register_io_cb_t = gpgme_error_t function(void* data, int fd, int dir, gpgme_io_cb_t fnc, void* fnc_data, void** tag);
1203 	
1204 	/* The type of a function that can remove a previously registered I/O
1205 	   callback function given TAG as returned by the register
1206 	   function.  */
1207 	alias gpgme_remove_io_cb_t = void function(void* tag);
1208 	
1209 	/* The type of a function that is called when a context finished an peration.  */
1210 	alias gpgme_event_io_cb_t = void function(void* data, gpgme_event_io_t type, void* type_data);
1211 	
1212 	/* Set the I/O callback functions in CTX to IO_CBS.  */
1213 	void gpgme_set_io_cbs(gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
1214 	
1215 	/* Get the current I/O callback functions.  */
1216 	void gpgme_get_io_cbs(gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
1217 	
1218 	/* Wrappers around the internal I/O functions for use with gpgme_passphrase_cb_t and gpgme_edit_cb_t.  */
1219 	ptrdiff_t gpgme_io_read(int fd, void* buffer, size_t count);
1220 	
1221 	ptrdiff_t gpgme_io_write(int fd, const(void*) buffer, size_t count);
1222 	
1223 	int gpgme_io_writen(int fd, const(void*) buffer, size_t count);
1224 	
1225 	/* Process the pending operation and, if HANG is non-zero, wait for the pending operation to finish.  */
1226 	gpgme_ctx_t gpgme_wait(gpgme_ctx_t ctx, gpgme_error_t* status, int hang);
1227 	
1228 	gpgme_ctx_t gpgme_wait_ext(gpgme_ctx_t ctx, gpgme_error_t* status, gpgme_error_t* op_err, int hang);
1229 	
1230 	/* Cancel a pending asynchronous operation.  */
1231 	gpgme_error_t gpgme_cancel(gpgme_ctx_t ctx);
1232 	
1233 	/* Cancel a pending operation asynchronously.  */
1234 	gpgme_error_t gpgme_cancel_async(gpgme_ctx_t ctx);
1235 
1236 }
1237 
1238 
1239 /*
1240  * Functions to handle data objects.
1241  */
1242 
1243 
1244 struct gpgme_data_cbs {
1245 	gpgme_data_read_cb_t read;
1246 	gpgme_data_write_cb_t write;
1247 	gpgme_data_seek_cb_t seek;
1248 	gpgme_data_release_cb_t release;
1249 }
1250 
1251 alias gpgme_data_cbs_t = gpgme_data_cbs*;
1252 
1253 extern(C) nothrow @nogc {
1254 	
1255 	/* Read up to SIZE bytes into buffer BUFFER from the data object with
1256    		the handle HANDLE.  Return the number of characters read, 0 on EOF
1257    		and -1 on error.  If an error occurs, errno is set.  */
1258 	alias gpgme_data_read_cb_t = ptrdiff_t function(void* handle, void* buffer, size_t size);
1259 	
1260 	/* Write up to SIZE bytes from buffer BUFFER to the data object with
1261 	   the handle HANDLE.  Return the number of characters written, or -1
1262 	   on error.  If an error occurs, errno is set.  */
1263 	alias gpgme_data_write_cb_t = ptrdiff_t function(void* handle, const(void*) buffer, size_t size);
1264 	
1265 	/* Set the current position from where the next read or write starts
1266 	   in the data object with the handle HANDLE to OFFSET, relativ to
1267 	   WHENCE.  */
1268 	alias gpgme_data_seek_cb_t = off_t function(void* handle, off_t offset, int whence);
1269 	
1270 	/* Close the data object with the handle DL.  */
1271 	alias gpgme_data_release_cb_t = void function(void* handle);
1272 
1273 	/* Read up to SIZE bytes into buffer BUFFER from the data object with
1274 	   the handle DH.  Return the number of characters read, 0 on EOF and
1275 	   -1 on error.  If an error occurs, errno is set.  */
1276 	ptrdiff_t gpgme_data_read(gpgme_data_t dh, void* buffer, size_t size);
1277 	
1278 	/* Write up to SIZE bytes from buffer BUFFER to the data object with
1279 	   the handle DH.  Return the number of characters written, or -1 on
1280 	   error.  If an error occurs, errno is set.  */
1281 	ptrdiff_t gpgme_data_write(gpgme_data_t dh, const(void*) buffer, size_t size);
1282 	
1283 	/* Set the current position from where the next read or write starts
1284 	   in the data object with the handle DH to OFFSET, relativ to
1285 	   WHENCE.  */
1286 	off_t gpgme_data_seek(gpgme_data_t dh, off_t offset, int whence);
1287 	
1288 	/* Create a new data buffer and return it in R_DH.  */
1289 	gpgme_error_t gpgme_data_new(gpgme_data_t* r_dh);
1290 	
1291 	/* Destroy the data buffer DH.  */
1292 	void gpgme_data_release(gpgme_data_t dh);
1293 	
1294 	/* Create a new data buffer filled with SIZE bytes starting from
1295 	   BUFFER.  If COPY is zero, copying is delayed until necessary, and
1296 	   the data is taken from the original location when needed.  */
1297 	gpgme_error_t gpgme_data_new_from_mem(gpgme_data_t* r_dh, const(char*) buffer, size_t size, int copy);
1298 	
1299 	/* Destroy the data buffer DH and return a pointer to its content.
1300 	   The memory has be to released with gpgme_free() by the user.  It's
1301 	   size is returned in R_LEN.  */
1302 	char* gpgme_data_release_and_get_mem(gpgme_data_t dh, size_t* r_len);
1303 	
1304 	/* Release the memory returned by gpgme_data_release_and_get_mem().  */
1305 	void gpgme_free(void* buffer);
1306 	
1307 	gpgme_error_t gpgme_data_new_from_cbs(gpgme_data_t* dh, gpgme_data_cbs_t cbs, void* handle);
1308 	
1309 	gpgme_error_t gpgme_data_new_from_fd(gpgme_data_t* dh, int fd);
1310 	
1311 	gpgme_error_t gpgme_data_new_from_stream(gpgme_data_t* dh, FILE* stream);
1312 	
1313 	/* Return the encoding attribute of the data buffer DH */
1314 	gpgme_data_encoding_t gpgme_data_get_encoding(gpgme_data_t dh);
1315 	
1316 	/* Set the encoding attribute of data buffer DH to ENC */
1317 	gpgme_error_t gpgme_data_set_encoding(gpgme_data_t dh, gpgme_data_encoding_t enc);
1318 	
1319 	/* Get the file name associated with the data object with handle DH, or NULL if there is none.  */
1320 	char* gpgme_data_get_file_name(gpgme_data_t dh);
1321 	
1322 	/* Set the file name associated with the data object with handle DH to FILE_NAME.  */
1323 	gpgme_error_t gpgme_data_set_file_name(gpgme_data_t dh, const(char*) file_name);
1324 	
1325 	/* Try to identify the type of the data in DH.  */
1326 	gpgme_data_type_t gpgme_data_identify(gpgme_data_t dh, int reserved);
1327 	
1328 	/* Create a new data buffer which retrieves the data from the callback
1329 	   function READ_CB.  Deprecated, please use gpgme_data_new_from_cbs
1330 	   instead.  */
1331 	gpgme_error_t gpgme_data_new_with_read_cb(gpgme_data_t* r_dh, int function(void*, char*, size_t, size_t*) read_cb, void* read_cb_value);
1332 	
1333 	/* Create a new data buffer filled with the content of file FNAME.
1334 	   COPY must be non-zero.  For delayed read, please use
1335 	   gpgme_data_new_from_fd or gpgme_data_new_from stream instead.  */
1336 	gpgme_error_t gpgme_data_new_from_file(gpgme_data_t* r_dh, const(char*) fname, int copy);
1337 	
1338 	/* Create a new data buffer filled with LENGTH bytes starting from
1339 	   OFFSET within the file FNAME or stream FP (exactly one must be
1340 	   non-zero).  */
1341 	gpgme_error_t gpgme_data_new_from_filepart(gpgme_data_t* r_dh, const(char*) fname, FILE* fp, off_t offset, size_t length);
1342 	
1343 	/* Reset the read pointer in DH.  Deprecated, please use gpgme_data_seek instead.  */
1344 	deprecated gpgme_error_t gpgme_data_rewind(gpgme_data_t dh);
1345 
1346 }
1347 
1348 /*
1349  * Key and trust functions.
1350  */
1351 
1352 
1353 extern(C) nothrow @nogc {
1354 	
1355 	/* Get the key with the fingerprint FPR from the crypto backend.  If
1356 	   SECRET is true, get the secret key.  */
1357 	gpgme_error_t gpgme_get_key(gpgme_ctx_t ctx, const(char*) fpr, gpgme_key_t* r_key, int secret);
1358 	
1359 	/* Create a dummy key to specify an email address.  */
1360 	gpgme_error_t gpgme_key_from_uid(gpgme_key_t* key, const(char*) name);
1361 	
1362 	/* Acquire a reference to KEY.  */
1363 	void gpgme_key_ref(gpgme_key_t key);
1364 	
1365 	/* Release a reference to KEY.  If this was the last one the key is destroyed.  */
1366 	void gpgme_key_unref(gpgme_key_t key);
1367 	void gpgme_key_release(gpgme_key_t key);
1368 	
1369 	/* Return the value of the attribute WHAT of KEY, which has to be
1370 	   representable by a string.  IDX specifies the sub key or user ID
1371 	   for attributes related to sub keys or user IDs.  Deprecated, use
1372 	   key structure directly instead. */
1373 	deprecated const(char*) gpgme_key_get_string_attr(gpgme_key_t key, _gpgme_attr_t what, const(void*) reserved, int idx);
1374 	
1375 	/* Return the value of the attribute WHAT of KEY, which has to be
1376 	   representable by an unsigned integer.  IDX specifies the sub key or
1377 	   user ID for attributes related to sub keys or user IDs.
1378 	   Deprecated, use key structure directly instead.  */
1379 	deprecated ulong gpgme_key_get_ulong_attr(gpgme_key_t key, _gpgme_attr_t what, const(void*) reserved, int idx);
1380 	
1381 	/* Return the value of the attribute WHAT of a signature on user ID
1382 	   UID_IDX in KEY, which has to be representable by a string.  IDX
1383 	   specifies the signature.  Deprecated, use key structure directly
1384 	   instead.  */
1385 	deprecated const(char*) gpgme_key_sig_get_string_attr(gpgme_key_t key, int uid_idx, _gpgme_attr_t what, const(void*) reserved, int idx);
1386 	
1387 	/* Return the value of the attribute WHAT of a signature on user ID
1388 	   UID_IDX in KEY, which has to be representable by an unsigned
1389 	   integer string.  IDX specifies the signature.  Deprecated, use key
1390 	   structure directly instead.  */
1391 	deprecated ulong gpgme_key_sig_get_ulong_attr(gpgme_key_t key, int uid_idx, _gpgme_attr_t what, const(void*) reserved, int idx);
1392 
1393 }
1394 
1395 
1396 /*
1397  * Encryption.
1398  */
1399 
1400 
1401 struct _gpgme_op_encrypt_result {
1402 	/* The list of invalid recipients.  */
1403 	gpgme_invalid_key_t invalid_recipients;
1404 }
1405 
1406 alias gpgme_encrypt_result_t = _gpgme_op_encrypt_result*;
1407 
1408 /* The valid encryption flags.  */
1409 enum gpgme_encrypt_flags_t {
1410 	GPGME_ENCRYPT_ALWAYS_TRUST = 1,
1411 	GPGME_ENCRYPT_NO_ENCRYPT_TO = 2,
1412 	GPGME_ENCRYPT_PREPARE = 4,
1413 	GPGME_ENCRYPT_EXPECT_SIGN = 8,
1414 	GPGME_ENCRYPT_NO_COMPRESS = 16
1415 }
1416 
1417 extern(C) nothrow @nogc {
1418 	
1419 	/* Retrieve a pointer to the result of the encrypt operation.  */
1420 	gpgme_encrypt_result_t gpgme_op_encrypt_result(gpgme_ctx_t ctx);
1421 	
1422 	/* Encrypt plaintext PLAIN within CTX for the recipients RECP and store the resulting ciphertext in CIPHER.  */
1423 	gpgme_error_t gpgme_op_encrypt_start(gpgme_ctx_t ctx, gpgme_key_t[] recp, gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher);
1424 	
1425 	gpgme_error_t gpgme_op_encrypt(gpgme_ctx_t ctx, gpgme_key_t[] recp, gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher);
1426 	
1427 	/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1428 	   store the resulting ciphertext in CIPHER.  Also sign the ciphertext
1429 	   with the signers in CTX.  */
1430 	gpgme_error_t gpgme_op_encrypt_sign_start(gpgme_ctx_t ctx, gpgme_key_t[] recp, gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher);
1431 	
1432 	gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t[] recp, gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher);
1433 
1434 }
1435 
1436 
1437 /*
1438  * Decryption.
1439  */
1440 
1441 struct _gpgme_recipient {
1442 	
1443 	_gpgme_recipient* next;
1444 
1445 	/* The key ID of key for which the text was encrypted.  */
1446 	char* keyid;
1447 
1448 	/* Internal to GPGME, do not use.  */
1449 	char[16 + 1] _keyid;
1450 
1451 	/* The public key algorithm of the recipient key.  */
1452 	gpgme_pubkey_algo_t pubkey_algo;
1453 
1454 	/* The status of the recipient.  */
1455 	gpgme_error_t status;
1456 }
1457 
1458 alias gpgme_recipient_t = _gpgme_recipient*;
1459 
1460 struct _gpgme_op_decrypt_result {
1461 	
1462 	char* unsupported_algorithm;
1463 
1464 	mixin(bitfields!(
1465         uint, "wrong_key_usage",	1, /* Key should not have been used for encryption.  */
1466         int, "_unused",	31, /* Internal to GPGME, do not use.  */
1467     ));
1468 
1469 	gpgme_recipient_t recipients;
1470 
1471 	/* The original file name of the plaintext message, if available.  */
1472 	char* file_name;
1473 }
1474 
1475 alias gpgme_decrypt_result_t = _gpgme_op_decrypt_result*;
1476 
1477 extern(C) nothrow @nogc {
1478 	
1479 	/* Retrieve a pointer to the result of the decrypt operation.  */
1480 	gpgme_decrypt_result_t gpgme_op_decrypt_result(gpgme_ctx_t ctx);
1481 	
1482 	/* Decrypt ciphertext CIPHER within CTX and store the resulting plaintext in PLAIN.  */
1483 	gpgme_error_t gpgme_op_decrypt_start(gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain);
1484 	
1485 	gpgme_error_t gpgme_op_decrypt(gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain);
1486 	
1487 	/* Decrypt ciphertext CIPHER and make a signature verification within CTX and store the resulting plaintext in PLAIN.  */
1488 	gpgme_error_t gpgme_op_decrypt_verify_start(gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain);
1489 	
1490 	gpgme_error_t gpgme_op_decrypt_verify(gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain);
1491 	
1492 }
1493 
1494 
1495 /*
1496  * Signing.
1497  */
1498 
1499 
1500 struct _gpgme_new_signature {
1501 	
1502 	_gpgme_new_signature* next;
1503 
1504 	/* The type of the signature.  */
1505 	gpgme_sig_mode_t type;
1506 
1507 	/* The public key algorithm used to create the signature.  */
1508 	gpgme_pubkey_algo_t pubkey_algo;
1509 
1510 	/* The hash algorithm used to create the signature.  */
1511 	gpgme_hash_algo_t hash_algo;
1512 
1513 	/* Internal to GPGME, do not use.  Must be set to the same value as CLASS below.  */
1514 	ulong _obsolete_class;
1515 
1516 	/* Signature creation time.  */
1517 	long timestamp;
1518 
1519 	/* The fingerprint of the signature.  */
1520 	char* fpr;
1521 
1522 	uint _obsolete_class_2;
1523 
1524 	/* Crypto backend specific signature class.  */
1525 	uint sig_class;
1526 }
1527 
1528 alias gpgme_new_signature_t = _gpgme_new_signature*;
1529 
1530 struct _gpgme_op_sign_result {
1531 	/* The list of invalid signers.  */
1532 	gpgme_invalid_key_t invalid_signers;
1533 	gpgme_new_signature_t signatures;
1534 }
1535 
1536 alias gpgme_sign_result_t = _gpgme_op_sign_result*;
1537 
1538 extern(C) nothrow @nogc {
1539 	
1540 	/* Retrieve a pointer to the result of the signing operation.  */
1541 	gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1542 	
1543 	/* Sign the plaintext PLAIN and store the signature in SIG.  */
1544 	gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig, gpgme_sig_mode_t mode);
1545 	
1546 	gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig, gpgme_sig_mode_t mode);
1547 
1548 }
1549 
1550 
1551 /*
1552  * Verify.
1553  */
1554 
1555 
1556 /* Flags used for the SUMMARY field in a gpgme_signature_t.  */
1557 enum gpgme_sigsum_t {
1558 	GPGME_SIGSUM_VALID       = 0x0001,  /* The signature is fully valid.  */
1559 	GPGME_SIGSUM_GREEN       = 0x0002,  /* The signature is good.  */
1560 	GPGME_SIGSUM_RED         = 0x0004,  /* The signature is bad.  */
1561 	GPGME_SIGSUM_KEY_REVOKED = 0x0010,  /* One key has been revoked.  */
1562 	GPGME_SIGSUM_KEY_EXPIRED = 0x0020,  /* One key has expired.  */
1563 	GPGME_SIGSUM_SIG_EXPIRED = 0x0040,  /* The signature has expired.  */
1564 	GPGME_SIGSUM_KEY_MISSING = 0x0080,  /* Can't verify: key missing.  */
1565 	GPGME_SIGSUM_CRL_MISSING = 0x0100,  /* CRL not available.  */
1566 	GPGME_SIGSUM_CRL_TOO_OLD = 0x0200,  /* Available CRL is too old.  */
1567 	GPGME_SIGSUM_BAD_POLICY  = 0x0400,  /* A policy was not met.  */
1568 	GPGME_SIGSUM_SYS_ERROR   = 0x0800   /* A system error occured.  */
1569 }
1570 
1571 struct _gpgme_signature {
1572 	
1573 	_gpgme_signature* next;
1574 
1575 	/* A summary of the signature status.  */
1576 	gpgme_sigsum_t summary;
1577 
1578 	/* The fingerprint or key ID of the signature.  */
1579 	char* fpr;
1580 
1581 	/* The status of the signature.  */
1582 	gpgme_error_t status;
1583 
1584 	/* Notation data and policy URLs.  */
1585 	gpgme_sig_notation_t notations;
1586 
1587 	/* Signature creation time.  */
1588 	ulong timestamp;
1589 
1590 	/* Signature exipration time or 0.  */
1591 	ulong exp_timestamp;
1592 	
1593 	mixin(bitfields!(
1594         uint, "wrong_key_usage",	1, /* Key should not have been used for signing.  */
1595         uint, "pka_trust",	2, /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1596         uint, "chain_model",	1, /* Validity has been verified using the chain model. */
1597         int, "_unused",	28, /* Internal to GPGME, do not use.  */
1598     ));
1599 
1600 	gpgme_validity_t validity;
1601 	gpgme_error_t validity_reason;
1602 
1603 	/* The public key algorithm used to create the signature.  */
1604 	gpgme_pubkey_algo_t pubkey_algo;
1605 
1606 	/* The hash algorithm used to create the signature.  */
1607 	gpgme_hash_algo_t hash_algo;
1608 
1609 	/* The mailbox from the PKA information or NULL. */
1610 	char* pka_address;
1611 }
1612 
1613 alias gpgme_signature_t = _gpgme_signature*;
1614 
1615 struct _gpgme_op_verify_result {
1616 	gpgme_signature_t signatures;
1617 
1618 	/* The original file name of the plaintext message, if available.  */
1619 	char* file_name;
1620 }
1621 
1622 alias gpgme_verify_result_t = _gpgme_op_verify_result*;
1623 
1624 extern(C) nothrow @nogc {
1625 	
1626 	/* Retrieve a pointer to the result of the verify operation.  */
1627 	gpgme_verify_result_t gpgme_op_verify_result(gpgme_ctx_t ctx);
1628 	
1629 	/* Verify within CTX that SIG is a valid signature for TEXT.  */
1630 	gpgme_error_t gpgme_op_verify_start(gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext);
1631 	
1632 	gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext);
1633 
1634 }
1635 
1636 
1637 /*
1638  * Import/Export
1639  */
1640 
1641 enum {
1642 	GPGME_IMPORT_NEW = 1,  /* The key was new.  */
1643 	GPGME_IMPORT_UID = 2,  /* The key contained new user IDs.  */
1644 	GPGME_IMPORT_SIG = 4,  /* The key contained new signatures.  */
1645 	GPGME_IMPORT_SUBKEY = 8,  /* The key contained new sub keys.  */
1646 	GPGME_IMPORT_SECRET = 16  /* The key contained a secret key.  */
1647 }
1648 
1649 struct _gpgme_import_status {
1650 
1651 	_gpgme_import_status* next;
1652 
1653 	/* Fingerprint.  */
1654 	char* fpr;
1655 
1656 	/* If a problem occured, the reason why the key could not be
1657 		imported.  Otherwise GPGME_No_Error.  */
1658 	gpgme_error_t result;
1659 
1660 	/* The result of the import, the GPGME_IMPORT_* values bit-wise
1661      ORed.  0 means the key was already known and no new components
1662      have been added.  */
1663 	uint status;
1664 }
1665 
1666 alias gpgme_import_status_t = _gpgme_import_status*;
1667 
1668 /* Import result object.  */
1669 struct _gpgme_op_import_result {
1670 	
1671 	/* Number of considered keys.  */
1672 	int considered;
1673 
1674 	/* Keys without user ID.  */
1675 	int no_user_id;
1676 
1677 	/* Imported keys.  */
1678 	int imported;
1679 
1680 	/* Imported RSA keys.  */
1681 	int imported_rsa;
1682 
1683 	/* Unchanged keys.  */
1684 	int unchanged;
1685 
1686 	/* Number of new user ids.  */
1687 	int new_user_ids;
1688 
1689 	/* Number of new sub keys.  */
1690 	int new_sub_keys;
1691 
1692 	/* Number of new signatures.  */
1693 	int new_signatures;
1694 
1695 	/* Number of new revocations.  */
1696 	int new_revocations;
1697 
1698 	/* Number of secret keys read.  */
1699 	int secret_read;
1700 
1701 	/* Number of secret keys imported.  */
1702 	int secret_imported;
1703 
1704 	/* Number of secret keys unchanged.  */
1705 	int secret_unchanged;
1706 
1707 	/* Number of new keys skipped.  */
1708 	int skipped_new_keys;
1709 
1710 	/* Number of keys not imported.  */
1711 	int not_imported;
1712 
1713 	/* List of keys for which an import was attempted.  */
1714 	gpgme_import_status_t imports;
1715 }
1716 
1717 alias gpgme_import_result_t = _gpgme_op_import_result*;
1718 
1719 extern(C) nothrow @nogc {
1720 	
1721 	/* Retrieve a pointer to the result of the import operation.  */
1722 	gpgme_import_result_t gpgme_op_import_result(gpgme_ctx_t ctx);
1723 	
1724 	/* Import the key in KEYDATA into the keyring.  */
1725 	gpgme_error_t gpgme_op_import_start(gpgme_ctx_t ctx, gpgme_data_t keydata);
1726 	
1727 	gpgme_error_t gpgme_op_import(gpgme_ctx_t ctx, gpgme_data_t keydata);
1728 	
1729 	deprecated gpgme_error_t gpgme_op_import_ext(gpgme_ctx_t ctx, gpgme_data_t keydata, int* nr);
1730 	
1731 	/* Import the keys from the array KEYS into the keyring.  */
1732 	gpgme_error_t gpgme_op_import_keys_start(gpgme_ctx_t ctx, gpgme_key_t[] keys);
1733 	
1734 	gpgme_error_t gpgme_op_import_keys(gpgme_ctx_t ctx, gpgme_key_t[] keys);
1735 	
1736 	/* Export the keys found by PATTERN into KEYDATA.  */
1737 	gpgme_error_t gpgme_op_export_start(gpgme_ctx_t ctx, const(char*) pattern, gpgme_export_mode_t mode, gpgme_data_t keydata);
1738 	
1739 	gpgme_error_t gpgme_op_export(gpgme_ctx_t ctx, const(char*) pattern, gpgme_export_mode_t mode, gpgme_data_t keydata);
1740 	
1741 	gpgme_error_t gpgme_op_export_ext_start(gpgme_ctx_t ctx, const(char*)[] pattern, gpgme_export_mode_t mode, gpgme_data_t keydata);
1742 	
1743 	gpgme_error_t gpgme_op_export_ext(gpgme_ctx_t ctx, const(char*)[] pattern, gpgme_export_mode_t mode, gpgme_data_t keydata);
1744 	
1745 	/* Export the keys from the array KEYS into KEYDATA.  */
1746 	gpgme_error_t gpgme_op_export_keys_start(gpgme_ctx_t ctx, gpgme_key_t[] keys, gpgme_export_mode_t mode, gpgme_data_t keydata);
1747 	
1748 	gpgme_error_t gpgme_op_export_keys(gpgme_ctx_t ctx, gpgme_key_t[] keys, gpgme_export_mode_t mode, gpgme_data_t keydata);
1749 
1750 }
1751 
1752 
1753 /*
1754  * Key generation.
1755  */
1756 
1757 
1758 struct _gpgme_op_genkey_result {
1759 	
1760 	mixin(bitfields!(
1761         uint, "primary",	1, /* A primary key was generated.  */
1762         uint, "sub",	1, /* A sub key was generated.  */
1763         int, "_unused",	30, /* Internal to GPGME, do not use.  */
1764     ));
1765 	
1766 	/* The fingerprint of the generated key.  */
1767 	char* fpr;
1768 }
1769 
1770 alias gpgme_genkey_result_t = _gpgme_op_genkey_result*;
1771 
1772 extern(C) nothrow @nogc {
1773 
1774 	/* Generate a new keypair and add it to the keyring.  PUBKEY and
1775 	   SECKEY should be null for now.  PARMS specifies what keys should be
1776 	   generated.  */
1777 	gpgme_error_t gpgme_op_genkey_start(gpgme_ctx_t ctx, const(char*) parms, gpgme_data_t pubkey, gpgme_data_t seckey);
1778 	
1779 	gpgme_error_t gpgme_op_genkey(gpgme_ctx_t ctx, const(char*) parms, gpgme_data_t pubkey, gpgme_data_t seckey);
1780 	
1781 	/* Retrieve a pointer to the result of the genkey operation.  */
1782 	gpgme_genkey_result_t gpgme_op_genkey_result(gpgme_ctx_t ctx);
1783 	
1784 	/* Delete KEY from the keyring.  If ALLOW_SECRET is non-zero, secret keys are also deleted.  */
1785 	gpgme_error_t gpgme_op_delete_start(gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret);
1786 	
1787 	gpgme_error_t gpgme_op_delete(gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret);
1788 
1789 }
1790 
1791 
1792 /*
1793  * Key Edit interface
1794  */
1795 
1796 
1797 extern(C) nothrow @nogc {
1798 	
1799 	/* Edit the key KEY.  Send status and command requests to FNC and output of edit commands to OUT.  */
1800 	gpgme_error_t gpgme_op_edit_start(gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void* fnc_value, gpgme_data_t out_);
1801 	
1802 	gpgme_error_t gpgme_op_edit(gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void* fnc_value, gpgme_data_t out_);
1803 	
1804 	/* Edit the card for the key KEY.  Send status and command requests to FNC and output of edit commands to OUT.  */
1805 	gpgme_error_t gpgme_op_card_edit_start(gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void* fnc_value, gpgme_data_t out_);
1806 	
1807 	gpgme_error_t gpgme_op_card_edit(gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void* fnc_value, gpgme_data_t out_);
1808 
1809 }
1810 
1811 /*
1812  * Key listing
1813  */
1814 
1815 struct _gpgme_op_keylist_result {
1816 	mixin(bitfields!(
1817         uint, "truncated",	1,
1818         uint, "_unused",	31, /* Internal to GPGME, do not use.  */
1819     ));
1820 }
1821 
1822 alias gpgme_keylist_result_t = _gpgme_op_keylist_result*;
1823 
1824 extern(C) nothrow @nogc {
1825 	
1826 	/* Retrieve a pointer to the result of the key listing operation.  */
1827 	gpgme_keylist_result_t gpgme_op_keylist_result(gpgme_ctx_t ctx);
1828 	
1829 	/* Start a keylist operation within CTX, searching for keys which
1830 	   match PATTERN.  If SECRET_ONLY is true, only secret keys are
1831 	   returned.  */
1832 	gpgme_error_t gpgme_op_keylist_start(gpgme_ctx_t ctx, const(char*) pattern, int secret_only);
1833 	
1834 	gpgme_error_t gpgme_op_keylist_ext_start(gpgme_ctx_t ctx, const(char*)[] pattern, int secret_only, int reserved);
1835 	
1836 	/* Return the next key from the keylist in R_KEY.  */
1837 	gpgme_error_t gpgme_op_keylist_next(gpgme_ctx_t ctx, gpgme_key_t* r_key);
1838 	
1839 	/* Terminate a pending keylist operation within CTX.  */
1840 	gpgme_error_t gpgme_op_keylist_end(gpgme_ctx_t ctx);
1841 	
1842 	/* Change the passphrase for KEY.  FLAGS is reserved for future use and must be passed as 0.  */
1843 	gpgme_error_t gpgme_op_passwd_start(gpgme_ctx_t ctx, gpgme_key_t key, uint flags);
1844 	
1845 	gpgme_error_t gpgme_op_passwd(gpgme_ctx_t ctx, gpgme_key_t key, uint flags);
1846 
1847 }
1848 
1849 
1850 /*
1851  * Trust items and operations.
1852  */
1853 
1854 
1855 struct _gpgme_trust_item {
1856 	/* Internal to GPGME, do not use.  */
1857 	uint _refs;
1858 
1859 	/* The key ID to which the trust item belongs.  */
1860 	char* keyid;
1861 
1862 	/* Internal to GPGME, do not use.  */
1863 	char[16 + 1] _keyid;
1864 
1865 	/* The type of the trust item, 1 refers to a key, 2 to a user ID.  */
1866 	int type;
1867 
1868 	/* The trust level.  */
1869 	int level;
1870 
1871 	/* The owner trust if TYPE is 1.  */
1872 	char* owner_trust;
1873 
1874 	/* Internal to GPGME, do not use.  */
1875 	char[2] _owner_trust;
1876 
1877 	/* The calculated validity.  */
1878 	char* validity;
1879 
1880 	/* Internal to GPGME, do not use.  */
1881 	char[2] _validity;
1882 
1883 	/* The user name if TYPE is 2.  */
1884 	char* name;
1885 }
1886 
1887 alias gpgme_trust_item_t = _gpgme_trust_item*;
1888 
1889 extern(C) nothrow @nogc {
1890 	
1891 	/* Start a trustlist operation within CTX, searching for trust items which match PATTERN.  */
1892 	gpgme_error_t gpgme_op_trustlist_start(gpgme_ctx_t ctx, const(char*) pattern, int max_level);
1893 	
1894 	/* Return the next trust item from the trustlist in R_ITEM.  */
1895 	gpgme_error_t gpgme_op_trustlist_next(gpgme_ctx_t ctx, gpgme_trust_item_t* r_item);
1896 	
1897 	/* Terminate a pending trustlist operation within CTX.  */
1898 	gpgme_error_t gpgme_op_trustlist_end(gpgme_ctx_t ctx);
1899 	
1900 	/* Acquire a reference to ITEM.  */
1901 	void gpgme_trust_item_ref(gpgme_trust_item_t item);
1902 	
1903 	/* Release a reference to ITEM.  If this was the last one the trust item is destroyed.  */
1904 	void gpgme_trust_item_unref(gpgme_trust_item_t item);
1905 	
1906 	/* Release the trust item ITEM.  Deprecated, use gpgme_trust_item_unref.  */
1907 	deprecated void gpgme_trust_item_release(gpgme_trust_item_t item);
1908 	
1909 	/* Return the value of the attribute WHAT of ITEM, which has to be
1910 	   representable by a string.  Deprecated, use trust item structure
1911 	   directly.  */
1912 	deprecated const(char*) gpgme_trust_item_get_string_attr(gpgme_trust_item_t item, _gpgme_attr_t what, const(void*) reserved, int idx);
1913 	
1914 	/* Return the value of the attribute WHAT of KEY, which has to be
1915 	   representable by an integer.  IDX specifies a running index if the
1916 	   attribute appears more than once in the key.  Deprecated, use trust
1917 	   item structure directly.  */
1918 	deprecated int gpgme_trust_item_get_int_attr(gpgme_trust_item_t item, _gpgme_attr_t what, const(void*) reserved, int idx);
1919 
1920 }
1921 
1922 
1923 /*
1924  * Audit log
1925  */
1926 
1927 
1928 extern(C) nothrow @nogc {
1929 
1930 	/* Return the auditlog for the current session.  This may be called
1931 	   after a successful or failed operation.  If no audit log is
1932 	   available GPG_ERR_NO_DATA is returned.  */
1933 	gpgme_error_t gpgme_op_getauditlog_start(gpgme_ctx_t ctx, gpgme_data_t output, uint flags);
1934 	
1935 	gpgme_error_t gpgme_op_getauditlog(gpgme_ctx_t ctx, gpgme_data_t output, uint flags);
1936 
1937 }
1938 
1939 
1940 /*
1941  * Spawn interface
1942  */
1943 
1944 
1945 /* Flags for the spawn operations.  */
1946 enum {
1947 	GPGME_SPAWN_DETACHED = 1,
1948 	GPGME_SPAWN_ALLOW_SET_FG = 2
1949 }
1950 
1951 extern(C) nothrow @nogc {
1952 	
1953 	/* Run the command FILE with the arguments in ARGV.  Connect stdin to
1954 	   DATAIN, stdout to DATAOUT, and STDERR to DATAERR.  If one the data
1955 	   streams is NULL, connect to /dev/null instead.  */
1956 	gpgme_error_t gpgme_op_spawn_start(gpgme_ctx_t ctx, const(char*) file, const(char*)[] argv, gpgme_data_t datain, gpgme_data_t dataout, gpgme_data_t dataerr, uint flags);
1957 	
1958 	gpgme_error_t gpgme_op_spawn(gpgme_ctx_t ctx, const(char*) file, const(char*)[] argv, gpgme_data_t datain, gpgme_data_t dataout, gpgme_data_t dataerr, uint flags);
1959 
1960 }
1961 
1962 
1963 /*
1964  * Low-level Assuan protocol access.
1965  */
1966 
1967 /* Compat.  */
1968 struct _gpgme_op_assuan_result {
1969 	/* Deprecated.  Use the second value in a DONE event or the
1970      synchronous variant gpgme_op_assuan_transact_ext.  */
1971 	deprecated gpgme_error_t err;
1972 }
1973 
1974 alias gpgme_assuan_result_t = _gpgme_op_assuan_result*;
1975 	
1976 extern(C) nothrow @nogc {
1977 
1978 	alias gpgme_assuan_data_cb_t = gpgme_error_t function(void* opaque, const(void*) data, size_t datalen);
1979 	
1980 	alias gpgme_assuan_inquire_cb_t = gpgme_error_t function(void* opaque, const(char*) name, const(char*) args, gpgme_data_t* r_data);
1981 	
1982 	alias gpgme_assuan_status_cb_t = gpgme_error_t function(void* opaque, const(char*) status, const(char*) args);
1983 	
1984 	/* Send the Assuan COMMAND and return results via the callbacks. Asynchronous variant. */
1985 	gpgme_error_t gpgme_op_assuan_transact_start(gpgme_ctx_t ctx, const(char*) command, gpgme_assuan_data_cb_t data_cb, void* data_cb_value, gpgme_assuan_inquire_cb_t inq_cb, void* inq_cb_value, gpgme_assuan_status_cb_t stat_cb, void* stat_cb_value);
1986 	
1987 	/* Send the Assuan COMMAND and return results via the callbacks. Synchronous variant. */
1988 	gpgme_error_t gpgme_op_assuan_transact_ext(gpgme_ctx_t ctx, const(char*) command, gpgme_assuan_data_cb_t data_cb, void* data_cb_value, gpgme_assuan_inquire_cb_t inq_cb, void* inq_cb_value, gpgme_assuan_status_cb_t stat_cb, void* stat_cb_value, gpgme_error_t* op_err);
1989 	
1990 	/* Return the result of the last Assuan command. */
1991 	deprecated gpgme_assuan_result_t gpgme_op_assuan_result(gpgme_ctx_t ctx);
1992 	
1993 	deprecated gpgme_error_t gpgme_op_assuan_transact(gpgme_ctx_t ctx, const(char*) command, gpgme_assuan_data_cb_t data_cb, void* data_cb_value, gpgme_assuan_inquire_cb_t inq_cb, void* inq_cb_value, gpgme_assuan_status_cb_t status_cb, void* status_cb_value);
1994 
1995 }
1996 
1997 /*
1998  * Crypto container support.
1999  */
2000 
2001 struct _gpgme_op_vfs_mount_result {
2002 	char* mount_dir;
2003 }
2004 
2005 alias gpgme_vfs_mount_result_t = _gpgme_op_vfs_mount_result*;
2006 
2007 extern(C) nothrow @nogc {
2008 	
2009 	gpgme_vfs_mount_result_t gpgme_op_vfs_mount_result(gpgme_ctx_t ctx);
2010 	
2011 	/* The container is automatically unmounted when the context is reset
2012 	   or destroyed.  Transmission errors are returned directly,
2013 	   operational errors are returned in OP_ERR.  */
2014 	gpgme_error_t gpgme_op_vfs_mount(gpgme_ctx_t ctx, const(char*) container_file, const(char*) mount_dir, uint flags, gpgme_error_t* op_err);
2015 	
2016 	gpgme_error_t gpgme_op_vfs_create(gpgme_ctx_t ctx, gpgme_key_t[] recp, const(char*) container_file, uint flags, gpgme_error_t* op_err);
2017 
2018 }
2019 
2020 
2021 /*
2022  * Interface to gpgconf(1).
2023  */
2024 
2025 
2026 /* The expert level at which a configuration option or group of
2027    options should be displayed.  See the gpgconf(1) documentation for
2028    more details.  */
2029  enum gpgme_conf_level_t {
2030 	GPGME_CONF_BASIC = 0,
2031 	GPGME_CONF_ADVANCED = 1,
2032 	GPGME_CONF_EXPERT = 2,
2033 	GPGME_CONF_INVISIBLE = 3,
2034 	GPGME_CONF_INTERNAL = 4
2035 }
2036 
2037 /* The data type of a configuration option argument.  See the gpgconf(1) documentation for more details.  */
2038 enum gpgme_conf_type_t {
2039 	/* Basic types.  */
2040 	GPGME_CONF_NONE = 0,
2041 	GPGME_CONF_STRING = 1,
2042 	GPGME_CONF_INT32 = 2,
2043 	GPGME_CONF_UINT32 = 3,
2044 
2045 	/* Complex types.  */
2046 	GPGME_CONF_FILENAME = 32,
2047 	GPGME_CONF_LDAP_SERVER = 33,
2048 	GPGME_CONF_KEY_FPR = 34,
2049 	GPGME_CONF_PUB_KEY = 35,
2050 	GPGME_CONF_SEC_KEY = 36,
2051 	GPGME_CONF_ALIAS_LIST = 37
2052 }
2053 
2054 /* For now, compatibility.  */
2055 enum GPGME_CONF_PATHNAME = gpgme_conf_type_t.GPGME_CONF_FILENAME;
2056 
2057 /* This represents a single argument for a configuration option. Which of the members of value is used depends on the ALT_TYPE.  */
2058 struct gpgme_conf_arg {
2059 	
2060 	gpgme_conf_arg* next;
2061 	
2062 	/* True if the option appears without an (optional) argument.  */
2063 	uint no_arg;
2064 	
2065 	union value_uni {
2066     	uint count;
2067     	uint uint32;
2068     	int int32;
2069     	char* string;
2070 	} 
2071 	value_uni value;
2072 }
2073 
2074 alias gpgme_conf_arg_t = gpgme_conf_arg*;
2075 
2076 /* The flags of a configuration option.  See the gpg-conf  documentation for details.  */
2077 enum {
2078 	GPGME_CONF_GROUP = (1 << 0),
2079 	GPGME_CONF_OPTIONAL = (1 << 1),
2080 	GPGME_CONF_LIST = (1 << 2),
2081 	GPGME_CONF_RUNTIME = (1 << 3),
2082 	GPGME_CONF_DEFAULT = (1 << 4),
2083 	GPGME_CONF_DEFAULT_DESC = (1 << 5),
2084 	GPGME_CONF_NO_ARG_DESC = (1 << 6),
2085 	GPGME_CONF_NO_CHANGE = (1 << 7)
2086 }
2087 
2088 /* The representation of a single configuration option.  See the gpg-conf documentation for details.  */
2089 struct gpgme_conf_opt {
2090 	
2091 	gpgme_conf_opt* next;
2092 
2093 	/* The option name.  */
2094 	char* name;
2095 
2096 	/* The flags for this option.  */
2097 	uint flags;
2098 
2099 	/* The level of this option.  */
2100 	gpgme_conf_level_t level;
2101 
2102 	/* The localized description of this option.  */
2103 	char* description;
2104 
2105 	/* The type and alternate type of this option.  */
2106 	gpgme_conf_type_t type;
2107 	gpgme_conf_type_t alt_type;
2108 
2109 	/* The localized (short) name of the argument, if any.  */
2110 	char* argname;
2111 
2112 	/* The default value.  */
2113 	gpgme_conf_arg_t default_value;
2114 	char* default_description;
2115 
2116 	/* The default value if the option is not set.  */
2117 	gpgme_conf_arg_t no_arg_value;
2118 	char* no_arg_description;
2119 
2120 	/* The current value if the option is set.  */
2121 	gpgme_conf_arg_t value;
2122 
2123 	/* The new value, if any.  NULL means reset to default.  */
2124 	int change_value;
2125 	gpgme_conf_arg_t new_value;
2126 
2127 	/* Free for application use.  */
2128 	void* user_data;
2129 }
2130 
2131 alias gpgme_conf_opt_t = gpgme_conf_opt*;
2132 
2133 /* The representation of a component that can be configured.  See the gpg-conf documentation for details.  */
2134 struct gpgme_conf_comp {
2135 	
2136 	gpgme_conf_comp* next;
2137 
2138 	/* Internal to GPGME, do not use!  */
2139 	gpgme_conf_opt_t* _last_opt_p;
2140 
2141 	/* The component name.  */
2142 	char* name;
2143 
2144 	/* A human-readable description for the component.  */
2145 	char* description;
2146 
2147 	/* The program name (an absolute path to the program).  */
2148 	char* program_name;
2149 
2150 	/* A linked list of options for this component.  */
2151 	gpgme_conf_opt* options;
2152 }
2153 
2154 alias gpgme_conf_comp_t = gpgme_conf_comp*;
2155 
2156 extern(C) nothrow @nogc {
2157 
2158 	/* Allocate a new gpgme_conf_arg_t.  If VALUE is NULL, a "no arg
2159 	   default" is prepared.  If type is a string type, VALUE should point
2160 	   to the string.  Else, it should point to an unsigned or signed
2161 	   integer respectively.  */
2162 	gpgme_error_t gpgme_conf_arg_new(gpgme_conf_arg_t* arg_p, gpgme_conf_type_t type, const(void*) value);
2163 	
2164 	/* This also releases all chained argument structures!  */
2165 	void gpgme_conf_arg_release(gpgme_conf_arg_t arg, gpgme_conf_type_t type);
2166 	
2167 	/* Register a change for the value of OPT to ARG.  If RESET is 1 (do
2168 	   not use any values but 0 or 1), ARG is ignored and the option is
2169 	   not changed (reverting a previous change).  Otherwise, if ARG is
2170 	   NULL, the option is cleared or reset to its default.  */
2171 	gpgme_error_t gpgme_conf_opt_change(gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg);
2172 	
2173 	/* Release a set of configurations.  */
2174 	void gpgme_conf_release(gpgme_conf_comp_t conf);
2175 	
2176 	/* Retrieve the current configurations.  */
2177 	gpgme_error_t gpgme_op_conf_load(gpgme_ctx_t ctx, gpgme_conf_comp_t* conf_p);
2178 	
2179 	/* Save the configuration of component comp.  This function does not follow chained components!  */
2180 	gpgme_error_t gpgme_op_conf_save(gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
2181 
2182 }
2183 
2184 
2185 /*
2186  * Various functions.
2187  */
2188 
2189 extern(C) nothrow @nogc {
2190 	
2191 	/* Set special global flags; consult the manual before use.  */
2192 	int gpgme_set_global_flag(const(char*) name, const(char*) value);
2193 	
2194 	/* Check that the library fulfills the version requirement.  Note:
2195 	   This is here only for the case where a user takes a pointer from
2196 	   the old version of this function.  The new version and macro for
2197 	   run-time checks are below.  */
2198 	const(char*) gpgme_check_version(const(char*) req_version);
2199 	
2200 	/* Check that the library fulfills the version requirement and check for struct layout mismatch involving bitfields.  */
2201 	const(char*) gpgme_check_version_internal(const(char*) req_version, size_t offset_sig_validity);
2202 	
2203 	const(char*) gpgme_check_version_new(const(char*) req_version) {
2204 		return gpgme_check_version_internal(req_version, _gpgme_signature.validity.offsetof);
2205 	}
2206 		
2207 	/* Return the default values for various directories.  */
2208 	const(char*) gpgme_get_dirinfo(const(char*) what);
2209 	
2210 	/* Get the information about the configured and installed engines.  A
2211 	   pointer to the first engine in the statically allocated linked list
2212 	   is returned in *INFO.  If an error occurs, it is returned.  The
2213 	   returned data is valid until the next gpgme_set_engine_info.  */
2214 	gpgme_error_t gpgme_get_engine_info(gpgme_engine_info_t* engine_info);
2215 	
2216 	/* Set the default engine info for the protocol PROTO to the file name FILE_NAME and the home directory HOME_DIR.  */
2217 	gpgme_error_t gpgme_set_engine_info(gpgme_protocol_t proto, const(char*) file_name, const(char*) home_dir);
2218 	
2219 	/* Verify that the engine implementing PROTO is installed and available.  */
2220 	gpgme_error_t gpgme_engine_check_version(gpgme_protocol_t proto);
2221 	
2222 	/* Reference counting for result objects.  */
2223 	void gpgme_result_ref(void* result);
2224 	
2225 	void gpgme_result_unref(void* result);
2226 	
2227 	/* Return a statically allocated string with the name of the public key algorithm ALGO, or NULL if that name is not known.  */
2228 	const(char*) gpgme_pubkey_algo_name(gpgme_pubkey_algo_t algo);
2229 	
2230 	/* Return a statically allocated string with the name of the hash algorithm ALGO, or NULL if that name is not known.  */
2231 	const(char*) gpgme_hash_algo_name(gpgme_hash_algo_t algo);
2232 
2233 }
2234 
2235 
2236 /*
2237  * Deprecated types.
2238  */
2239 
2240 deprecated {
2241 	alias GpgmeCtx = gpgme_ctx_t;
2242 	alias GpgmeData = gpgme_data_t;
2243 	alias GpgmeError = gpgme_error_t;
2244 	alias GpgmeDataEncoding = gpgme_data_encoding_t;
2245 	alias GpgmePubKeyAlgo = gpgme_pubkey_algo_t;
2246 	alias GpgmeHashAlgo = gpgme_hash_algo_t;
2247 	alias GpgmeSigStat = gpgme_sig_stat_t;
2248 	alias GpgmeSigMode = gpgme_sig_mode_t;
2249 	alias GpgmeAttr = gpgme_attr_t;
2250 	alias GpgmeValidity = gpgme_validity_t;
2251 	alias GpgmeProtocol = gpgme_protocol_t;
2252 	alias GpgmeEngineInfo = gpgme_engine_info_t;
2253 	alias GpgmeSubkey = gpgme_subkey_t;
2254 	alias GpgmeKeySig = gpgme_key_sig_t;
2255 	alias GpgmeUserID = gpgme_user_id_t;
2256 	alias GpgmeKey = gpgme_key_t;
2257 	alias GpgmePassphraseCb = gpgme_passphrase_cb_t;
2258 	alias GpgmeProgressCb = gpgme_progress_cb_t;
2259 	alias GpgmeIOCb = gpgme_io_cb_t;
2260 	alias GpgmeRegisterIOCb = gpgme_register_io_cb_t;
2261 	alias GpgmeRemoveIOCb = gpgme_remove_io_cb_t;
2262 	alias GpgmeEventIO = gpgme_event_io_t;
2263 	alias GpgmeEventIOCb = gpgme_event_io_cb_t;
2264 	alias GpgmeIOCbs = gpgme_io_cbs;
2265 	alias GpgmeDataReadCb = gpgme_data_read_cb_t;
2266 	alias GpgmeDataWriteCb = gpgme_data_write_cb_t;
2267 	alias GpgmeDataSeekCb = gpgme_data_seek_cb_t;
2268 	alias GpgmeDataReleaseCb = gpgme_data_release_cb_t;
2269 	alias GpgmeDataCbs = gpgme_data_cbs;
2270 	alias GpgmeEncryptResult = gpgme_encrypt_result_t;
2271 	alias GpgmeSigNotation = gpgme_sig_notation_t;
2272 	alias GpgmeSignature = gpgme_signature_t;
2273 	alias GpgmeVerifyResult = gpgme_verify_result_t;
2274 	alias GpgmeImportStatus = gpgme_import_status_t;
2275 	alias GpgmeImportResult = gpgme_import_result_t;
2276 	alias GpgmeGenKeyResult = gpgme_genkey_result_t;
2277 	alias GpgmeTrustItem = gpgme_trust_item_t;
2278 	alias GpgmeStatusCode = gpgme_status_code_t;
2279 }
2280 
2281 
2282 
2283 version(unittest) {
2284 	import std.stdio : printf, write, writeln;
2285 	import std.conv;
2286 	import core.stdc.string : strcmp, strchr;
2287 	import core.stdc.locale;
2288 	import core.stdc.stdlib : getenv;
2289 	import core.stdc.stdio : SEEK_SET;
2290 	
2291 	void check_result_verify(gpgme_verify_result_t result, uint summary, string fpr, gpgme_error_t status, int notation) {
2292 		gpgme_signature_t sig;
2293 		
2294 		sig = result.signatures;
2295 		
2296 		assert(sig && !sig.next); // Unexpected number of signatures
2297 		assert(sig.summary == summary); // Unexpected signature summary
2298 		assert(!strcmp(sig.fpr, fpr.ptr)); // Unexpected fingerprint
2299 		assert(gpgme_err_code(sig.status) == status); // Unexpected signature status
2300 		
2301 		if(notation) {
2302 			struct expected_notations_str {
2303 				const(char*) name;
2304 				const(char*) value;
2305 				int seen = 0;
2306 			} 
2307 			
2308 			expected_notations_str[] expected_notations = [
2309 				expected_notations_str("bar", "\xc3\xb6\xc3\xa4\xc3\xbc\xc3\x9f das waren Umlaute und jetzt ein prozent%-Zeichen"),
2310 				expected_notations_str("foobar.1",  "this is a notation data with 2 lines"),
2311 				expected_notations_str(null, "http://www.gu.org/policy/")
2312 			];
2313 			
2314 			int i;
2315 			gpgme_sig_notation_t r;
2316 
2317 			for(r = sig.notations; r; r = r.next) {
2318 				int any = 0;
2319 				for(i=0; i < expected_notations.length; i++) {
2320 					if(((r.name && expected_notations[i].name && !strcmp(r.name, expected_notations[i].name) && r.name_len == to!string(expected_notations[i].name).length) || (!r.name && !expected_notations[i].name && r.name_len == 0)) && r.value && !strcmp(r.value, expected_notations[i].value) && r.value_len == to!string(expected_notations[i].value).length) {
2321 						expected_notations[i].seen++;
2322 						any++;
2323 					}
2324 				}
2325 				assert(any); // Unexpected notation data
2326 			}
2327 			
2328 			for(i=0; i < expected_notations.length; i++) {
2329 				assert(expected_notations[i].seen == 1); // Missing or duplicate notation data
2330 			}
2331 		}
2332 
2333 		assert(!sig.wrong_key_usage); // Unexpectedly wrong key usage
2334 		assert(sig.validity == gpgme_validity_t.GPGME_VALIDITY_UNKNOWN); // Unexpected validity
2335 		assert(gpgme_err_code(sig.validity_reason) == gpg_err_code_t.GPG_ERR_NO_ERROR); // Unexpected validity reason
2336 	}
2337 	
2338 	void check_result_sign(gpgme_sign_result_t result, gpgme_sig_mode_t type) {
2339 		
2340 		assert(!result.invalid_signers); // Invalid signer found
2341 		assert(result.signatures && !result.signatures.next); // Unexpected number of signatures created
2342 		assert(result.signatures.type == type); // Wrong type of signature created
2343 		assert(result.signatures.pubkey_algo == gpgme_pubkey_algo_t.GPGME_PK_DSA); // Wrong pubkey algorithm reported
2344 		
2345 		assert(result.signatures.hash_algo == gpgme_hash_algo_t.GPGME_MD_SHA1); // Wrong hash algorithm reported
2346 		assert(result.signatures.sig_class == 1); // Wrong signature class reported
2347 		assert(!strcmp("A0FF4590BB6122EDEF6E3C542D727CC768697734", result.signatures.fpr)); // Wrong fingerprint reported
2348 	}
2349 }
2350 
2351 unittest {
2352 	
2353 	// ----------------- GPGME basic
2354 	
2355 	// version test
2356 	
2357 	printf("Version from header: %s (0x%06x)\n", GPGME_VERSION, GPGME_VERSION_NUMBER);
2358     printf("Version from binary: %s\n", gpgme_check_version_new(null));
2359 	
2360 	write("Test: version ... ");
2361 	
2362 	assert(gpgme_check_version_new(GPGME_VERSION) != null);
2363 	assert(gpgme_check_version_new("15") == null);
2364 	
2365 	writeln("SUCCESS"); 
2366 	
2367 	// engine info test
2368 	
2369 	write("Test: engine info ... ");
2370 	
2371 	gpgme_engine_info_t info;
2372 	gpgme_error_t err;
2373 	err = gpgme_get_engine_info(&info);
2374 	
2375 	assert(err == 0);
2376 	
2377 	writeln("SUCCESS"); 
2378 	
2379 	// data test
2380 	
2381 	// TODO: add data test
2382 	
2383 }
2384 
2385 
2386 unittest {
2387 	
2388 	// ----------------- GPG
2389 	
2390 	// verify test
2391 	
2392 	write("Test: verify ... ");
2393 	
2394 	string test_text1 = "Just GNU it!\n";
2395 	string test_text1f = "Just GNU it?\n";
2396 	string test_sig1 = q"EOS
2397 -----BEGIN PGP SIGNATURE-----
2398 
2399 iN0EABECAJ0FAjoS+i9FFIAAAAAAAwA5YmFyw7bDpMO8w58gZGFzIHdhcmVuIFVt
2400 bGF1dGUgdW5kIGpldHp0IGVpbiBwcm96ZW50JS1aZWljaGVuNRSAAAAAAAgAJGZv
2401 b2Jhci4xdGhpcyBpcyBhIG5vdGF0aW9uIGRhdGEgd2l0aCAyIGxpbmVzGhpodHRw
2402 Oi8vd3d3Lmd1Lm9yZy9wb2xpY3kvAAoJEC1yfMdoaXc0JBIAoIiLlUsvpMDOyGEc
2403 dADGKXF/Hcb+AKCJWPphZCphduxSvrzH0hgzHdeQaA==
2404 =nts1
2405 -----END PGP SIGNATURE-----
2406 EOS";
2407 
2408 	string test_sig2 = q"EOS
2409 -----BEGIN PGP MESSAGE-----
2410 
2411 owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH
2412 GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf
2413 y1kvP4y+8D5a11ang0udywsA
2414 =Crq6
2415 -----END PGP MESSAGE-----
2416 EOS";
2417 	/* A message with a prepended but unsigned plaintext packet. */
2418 	string double_plaintext_sig = q"EOS
2419 -----BEGIN PGP MESSAGE-----
2420 
2421 rDRiCmZvb2Jhci50eHRF4pxNVGhpcyBpcyBteSBzbmVha3kgcGxhaW50ZXh0IG1l
2422 c3NhZ2UKowGbwMvMwCSoW1RzPCOz3IRxTWISa6JebnG666MFD1wzSzJSixQ81XMV
2423 UlITUxTyixRyKxXKE0uSMxQyEosVikvyCwpSU/S4FNCArq6Ce1F+aXJGvoJvYlGF
2424 erFCTmJxiUJ5flFKMVeHGwuDIBMDGysTyA4GLk4BmO036xgWzMgzt9V85jCtfDFn
2425 UqVooWlGXHwNw/xg/fVzt9VNbtjtJ/fhUqYo0/LyCGEA
2426 =6+AK
2427 -----END PGP MESSAGE-----
2428 EOS";
2429 
2430 	
2431 	gpgme_ctx_t ctx;
2432 	gpgme_error_t err;
2433 	gpgme_data_t sig, text;
2434 	gpgme_verify_result_t result;
2435 	
2436 	setlocale(LC_ALL, "");
2437 	
2438 	gpgme_set_locale(null, LC_CTYPE, setlocale(LC_CTYPE, null));
2439 	
2440 	err = gpgme_engine_check_version(gpgme_protocol_t.GPGME_PROTOCOL_OpenPGP);
2441 	assert(err == 0);
2442 	
2443 	err = gpgme_new(&ctx);
2444 	assert(err == 0);
2445 	
2446 	/* Checking a valid message.  */
2447 	err = gpgme_data_new_from_mem(&text, test_text1.ptr, test_text1.length, 0);
2448 	assert(err == 0);
2449 	err = gpgme_data_new_from_mem(&sig, test_sig1.ptr, test_sig1.length, 0);
2450 	assert(err == 0);
2451 	err = gpgme_op_verify(ctx, sig, text, null);
2452 	assert(err == 0);
2453 	result = gpgme_op_verify_result(ctx);
2454 	check_result_verify(result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734", gpg_err_code_t.GPG_ERR_NO_ERROR, 1);
2455 	
2456 	write("1 ... ");
2457 	
2458 	/* Checking a manipulated message.  */
2459 	gpgme_data_release(text);
2460 	err = gpgme_data_new_from_mem (&text, test_text1f.ptr, test_text1f.length, 0);
2461 	assert(err == 0);
2462 	gpgme_data_seek(sig, 0, SEEK_SET);
2463 	err = gpgme_op_verify(ctx, sig, text, null);
2464 	assert(err == 0);
2465 	result = gpgme_op_verify_result(ctx);
2466 	check_result_verify(result, gpgme_sigsum_t.GPGME_SIGSUM_RED, "2D727CC768697734", gpg_err_code_t.GPG_ERR_BAD_SIGNATURE, 0);
2467 	
2468 	write("2 ... ");
2469 	
2470 	/* Checking a normal signature.  */
2471 	gpgme_data_release(sig);
2472 	gpgme_data_release(text);
2473 	err = gpgme_data_new_from_mem(&sig, test_sig2.ptr, test_sig2.length, 0);
2474 	assert(err == 0);
2475 	err = gpgme_data_new(&text);
2476 	assert(err == 0);
2477 	err = gpgme_op_verify(ctx, sig, null, text);
2478 	assert(err == 0);
2479 	result = gpgme_op_verify_result(ctx);
2480 	check_result_verify(result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734", gpg_err_code_t.GPG_ERR_NO_ERROR, 0);
2481 	
2482 	write("3 ... ");
2483 	
2484 	/* Checking an invalid message.  */
2485 	gpgme_data_release(sig);
2486 	gpgme_data_release(text);
2487 	err = gpgme_data_new_from_mem(&sig, double_plaintext_sig.ptr, double_plaintext_sig.length, 0);
2488 	assert(err == 0);
2489 	err = gpgme_data_new(&text);
2490 	assert(err == 0);
2491 	err = gpgme_op_verify(ctx, sig, null, text);
2492 	assert(gpgme_err_code(err) == gpg_err_code_t.GPG_ERR_BAD_DATA); // Double plaintext message not detected
2493 
2494 	write("4 ... ");
2495 
2496 	gpgme_data_release(sig);
2497 	gpgme_data_release(text);
2498 	gpgme_release(ctx);
2499 	
2500 	writeln("SUCCESS");
2501 	
2502 	// sign test
2503 	
2504 	write("Test: sign ... ");
2505 	
2506 	gpgme_sign_result_t result2;
2507 	gpgme_data_t in_, out_;
2508 	char* agent_info;
2509 	
2510 	err = gpgme_new(&ctx);
2511 	assert(err == 0);
2512 	
2513 	agent_info = getenv("GPG_AGENT_INFO");
2514 	assert(agent_info && strchr(agent_info, ':'));
2515 
2516 	gpgme_set_textmode(ctx, 1);
2517 	gpgme_set_armor(ctx, 1);
2518 	
2519 	gpgme_key_t akey;
2520     err = gpgme_get_key(ctx, "0x68697734", &akey, 0);
2521     assert(err == 0);
2522     gpgme_signers_clear(ctx);
2523     err = gpgme_signers_add(ctx, akey);
2524     assert(err == 0);
2525     gpgme_key_unref(akey);
2526 	
2527 	err = gpgme_data_new_from_mem(&in_, "Hallo Leute\n", 12, 0);
2528 	assert(err == 0);
2529 	
2530 	/* First a normal signature.  */
2531 	err = gpgme_data_new(&out_);
2532 	assert(err == 0);
2533 	err = gpgme_op_sign(ctx, in_, out_, gpgme_sig_mode_t.GPGME_SIG_MODE_NORMAL);
2534 	assert(err == 0);
2535 	result2 = gpgme_op_sign_result(ctx);
2536 	check_result_sign(result2, gpgme_sig_mode_t.GPGME_SIG_MODE_NORMAL);
2537 	gpgme_data_release(out_);
2538 	
2539 	write("1 ... ");
2540 	
2541 	/* Now a detached signature.  */ 
2542 	gpgme_data_seek(in_, 0, SEEK_SET);
2543 	err = gpgme_data_new(&out_);
2544 	assert(err == 0);
2545 	err = gpgme_op_sign(ctx, in_, out_, gpgme_sig_mode_t.GPGME_SIG_MODE_DETACH);
2546 	assert(err == 0);
2547 	result2 = gpgme_op_sign_result(ctx);
2548 	check_result_sign(result2, gpgme_sig_mode_t.GPGME_SIG_MODE_DETACH);
2549 	gpgme_data_release (out_);
2550 	
2551 	write("2 ... ");
2552 
2553 	/* And finally a cleartext signature.  */
2554 	gpgme_data_seek(in_, 0, SEEK_SET);
2555 	err = gpgme_data_new(&out_);
2556 	assert(err == 0);
2557 	err = gpgme_op_sign(ctx, in_, out_, gpgme_sig_mode_t.GPGME_SIG_MODE_CLEAR);
2558 	assert(err == 0);
2559 	result2 = gpgme_op_sign_result(ctx);
2560 	check_result_sign(result2, gpgme_sig_mode_t.GPGME_SIG_MODE_CLEAR);
2561 	gpgme_data_release(out_);
2562 
2563 	write("3 ... ");
2564 
2565 	gpgme_data_release(in_);
2566 	gpgme_release(ctx);
2567 	
2568 	
2569 	
2570 	writeln("SUCCESS");
2571 	
2572 }