1 /* gpgme.h - Public interface to GnuPG Made Easy. -*- c -*-
2 Copyright (C) 2000 Werner Koch (dd9jn)
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH
5 This file is part of GPGME.
7 GPGME is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of
10 the License, or (at your option) any later version.
12 GPGME is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 File: @configure_input@ */
26 #define _GPGME_INLINE __inline__
27 #elif __STDC_VERSION__ >= 199901L
28 #define _GPGME_INLINE inline
33 /* Include stdio.h for the FILE type definition. */
40 # include <sys/types.h>
43 #include <gpg-error.h>
47 #if 0 /* just to make Emacs auto-indent happy */
50 #endif /* __cplusplus */
54 /* Check for compiler features. */
56 #define _GPGME_GCC_VERSION (__GNUC__ * 10000 \
57 + __GNUC_MINOR__ * 100 \
58 + __GNUC_PATCHLEVEL__)
60 #if _GPGME_GCC_VERSION > 30100
61 #define _GPGME_DEPRECATED __attribute__ ((__deprecated__))
65 #ifndef _GPGME_DEPRECATED
66 #define _GPGME_DEPRECATED
70 /* The version of this header should match the one of the library. Do
71 not use this symbol in your application, use gpgme_check_version
72 instead. The purpose of this macro is to let autoconf (using the
73 AM_PATH_GPGME macro) check that this header matches the installed
75 #define GPGME_VERSION "@PACKAGE_VERSION@"
77 /* Check for a matching _FILE_OFFSET_BITS definition. */
78 #if @NEED__FILE_OFFSET_BITS@
79 #ifndef _FILE_OFFSET_BITS
80 #error GPGME was compiled with _FILE_OFFSET_BITS = @NEED__FILE_OFFSET_BITS@, please see the section "Largefile support (LFS)" in the GPGME manual.
82 #if (_FILE_OFFSET_BITS) != (@NEED__FILE_OFFSET_BITS@)
83 #error GPGME was compiled with a different value for _FILE_OFFSET_BITS, namely @NEED__FILE_OFFSET_BITS@, please see the section "Largefile support (LFS)" in the GPGME manual.
90 /* Some opaque data types used by GPGME. */
92 /* The context holds some global state and configration options, as
93 well as the results of a crypto operation. */
95 typedef struct gpgme_context *gpgme_ctx_t;
97 /* The data object is used by GPGME to exchange arbitrary data. */
99 typedef struct gpgme_data *gpgme_data_t;
102 /* Wrappers for the libgpg-error library. */
104 typedef gpg_error_t gpgme_error_t;
105 typedef gpg_err_code_t gpgme_err_code_t;
106 typedef gpg_err_source_t gpgme_err_source_t;
109 static _GPGME_INLINE gpgme_error_t
110 gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code)
112 return gpg_err_make (source, code);
116 /* The user can define GPGME_ERR_SOURCE_DEFAULT before including this
117 file to specify a default source for gpgme_error. */
118 #ifndef GPGME_ERR_SOURCE_DEFAULT
119 #define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
122 static _GPGME_INLINE gpgme_error_t
123 gpgme_error (gpgme_err_code_t code)
125 return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code);
129 static _GPGME_INLINE gpgme_err_code_t
130 gpgme_err_code (gpgme_error_t err)
132 return gpg_err_code (err);
136 static _GPGME_INLINE gpgme_err_source_t
137 gpgme_err_source (gpgme_error_t err)
139 return gpg_err_source (err);
143 /* Return a pointer to a string containing a description of the error
144 code in the error value ERR. This function is not thread safe. */
145 const char *gpgme_strerror (gpgme_error_t err);
147 /* Return the error string for ERR in the user-supplied buffer BUF of
148 size BUFLEN. This function is, in contrast to gpg_strerror,
149 thread-safe if a thread-safe strerror_r() function is provided by
150 the system. If the function succeeds, 0 is returned and BUF
151 contains the string describing the error. If the buffer was not
152 large enough, ERANGE is returned and BUF contains as much of the
153 beginning of the error string as fits into the buffer. */
154 int gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen);
157 /* Return a pointer to a string containing a description of the error
158 source in the error value ERR. */
159 const char *gpgme_strsource (gpgme_error_t err);
162 /* Retrieve the error code for the system error ERR. This returns
163 GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
165 gpgme_err_code_t gpgme_err_code_from_errno (int err);
168 /* Retrieve the system error for the error code CODE. This returns 0
169 if CODE is not a system error code. */
170 int gpgme_err_code_to_errno (gpgme_err_code_t code);
173 /* Return an error value with the error source SOURCE and the system
175 gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err);
178 /* Return an error value with the system error ERR. */
179 gpgme_err_code_t gpgme_error_from_errno (int err);
182 /* The possible encoding mode of gpgme_data_t objects. */
185 GPGME_DATA_ENCODING_NONE = 0, /* Not specified. */
186 GPGME_DATA_ENCODING_BINARY = 1,
187 GPGME_DATA_ENCODING_BASE64 = 2,
188 GPGME_DATA_ENCODING_ARMOR = 3 /* Either PEM or OpenPGP Armor. */
190 gpgme_data_encoding_t;
193 /* Public key algorithms from libgcrypt. */
206 /* Hash algorithms from libgcrypt. */
214 GPGME_MD_TIGER = 6, /* TIGER/192. */
215 GPGME_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */
218 GPGME_MD_SHA512 = 10,
220 GPGME_MD_CRC32 = 302,
221 GPGME_MD_CRC32_RFC1510 = 303,
222 GPGME_MD_CRC24_RFC2440 = 304
227 /* The possible signature stati. Deprecated, use error value in sig
231 GPGME_SIG_STAT_NONE = 0,
232 GPGME_SIG_STAT_GOOD = 1,
233 GPGME_SIG_STAT_BAD = 2,
234 GPGME_SIG_STAT_NOKEY = 3,
235 GPGME_SIG_STAT_NOSIG = 4,
236 GPGME_SIG_STAT_ERROR = 5,
237 GPGME_SIG_STAT_DIFF = 6,
238 GPGME_SIG_STAT_GOOD_EXP = 7,
239 GPGME_SIG_STAT_GOOD_EXPKEY = 8
242 typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED;
245 /* The available signature modes. */
248 GPGME_SIG_MODE_NORMAL = 0,
249 GPGME_SIG_MODE_DETACH = 1,
250 GPGME_SIG_MODE_CLEAR = 2
255 /* The available key and signature attributes. Deprecated, use the
256 individual result structures instead. */
259 GPGME_ATTR_KEYID = 1,
263 GPGME_ATTR_CREATED = 5,
264 GPGME_ATTR_EXPIRE = 6,
265 GPGME_ATTR_OTRUST = 7,
266 GPGME_ATTR_USERID = 8,
268 GPGME_ATTR_EMAIL = 10,
269 GPGME_ATTR_COMMENT = 11,
270 GPGME_ATTR_VALIDITY = 12,
271 GPGME_ATTR_LEVEL = 13,
272 GPGME_ATTR_TYPE = 14,
273 GPGME_ATTR_IS_SECRET = 15,
274 GPGME_ATTR_KEY_REVOKED = 16,
275 GPGME_ATTR_KEY_INVALID = 17,
276 GPGME_ATTR_UID_REVOKED = 18,
277 GPGME_ATTR_UID_INVALID = 19,
278 GPGME_ATTR_KEY_CAPS = 20,
279 GPGME_ATTR_CAN_ENCRYPT = 21,
280 GPGME_ATTR_CAN_SIGN = 22,
281 GPGME_ATTR_CAN_CERTIFY = 23,
282 GPGME_ATTR_KEY_EXPIRED = 24,
283 GPGME_ATTR_KEY_DISABLED = 25,
284 GPGME_ATTR_SERIAL = 26,
285 GPGME_ATTR_ISSUER = 27,
286 GPGME_ATTR_CHAINID = 28,
287 GPGME_ATTR_SIG_STATUS = 29,
288 GPGME_ATTR_ERRTOK = 30,
289 GPGME_ATTR_SIG_SUMMARY = 31,
290 GPGME_ATTR_SIG_CLASS = 32
293 typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED;
296 /* The available validities for a trust item or key. */
299 GPGME_VALIDITY_UNKNOWN = 0,
300 GPGME_VALIDITY_UNDEFINED = 1,
301 GPGME_VALIDITY_NEVER = 2,
302 GPGME_VALIDITY_MARGINAL = 3,
303 GPGME_VALIDITY_FULL = 4,
304 GPGME_VALIDITY_ULTIMATE = 5
309 /* The available protocols. */
312 GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
313 GPGME_PROTOCOL_CMS = 1,
314 GPGME_PROTOCOL_GPGCONF = 2, /* Special code for gpgconf. */
315 GPGME_PROTOCOL_ASSUAN = 3, /* Low-level access to an Assuan server. */
316 GPGME_PROTOCOL_UNKNOWN = 255
321 /* The available keylist mode flags. */
322 #define GPGME_KEYLIST_MODE_LOCAL 1
323 #define GPGME_KEYLIST_MODE_EXTERN 2
324 #define GPGME_KEYLIST_MODE_SIGS 4
325 #define GPGME_KEYLIST_MODE_SIG_NOTATIONS 8
326 #define GPGME_KEYLIST_MODE_EPHEMERAL 128
327 #define GPGME_KEYLIST_MODE_VALIDATE 256
329 typedef unsigned int gpgme_keylist_mode_t;
332 /* The available export mode flags. */
333 #define GPGME_EXPORT_MODE_EXTERN 2
335 typedef unsigned int gpgme_export_mode_t;
338 /* Flags for the audit log functions. */
339 #define GPGME_AUDITLOG_HTML 1
340 #define GPGME_AUDITLOG_WITH_HELP 128
343 /* Signature notations. */
345 /* The available signature notation flags. */
346 #define GPGME_SIG_NOTATION_HUMAN_READABLE 1
347 #define GPGME_SIG_NOTATION_CRITICAL 2
349 typedef unsigned int gpgme_sig_notation_flags_t;
351 struct _gpgme_sig_notation
353 struct _gpgme_sig_notation *next;
355 /* If NAME is a null pointer, then VALUE contains a policy URL
356 rather than a notation. */
359 /* The value of the notation data. */
362 /* The length of the name of the notation data. */
365 /* The length of the value of the notation data. */
368 /* The accumulated flags. */
369 gpgme_sig_notation_flags_t flags;
371 /* Notation data is human-readable. */
372 unsigned int human_readable : 1;
374 /* Notation data is critical. */
375 unsigned int critical : 1;
377 /* Internal to GPGME, do not use. */
380 typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
383 /* The possible stati for the edit operation. */
386 GPGME_STATUS_EOF = 0,
387 /* mkstatus processing starts here */
388 GPGME_STATUS_ENTER = 1,
389 GPGME_STATUS_LEAVE = 2,
390 GPGME_STATUS_ABORT = 3,
392 GPGME_STATUS_GOODSIG = 4,
393 GPGME_STATUS_BADSIG = 5,
394 GPGME_STATUS_ERRSIG = 6,
396 GPGME_STATUS_BADARMOR = 7,
398 GPGME_STATUS_RSA_OR_IDEA = 8,
399 GPGME_STATUS_KEYEXPIRED = 9,
400 GPGME_STATUS_KEYREVOKED = 10,
402 GPGME_STATUS_TRUST_UNDEFINED = 11,
403 GPGME_STATUS_TRUST_NEVER = 12,
404 GPGME_STATUS_TRUST_MARGINAL = 13,
405 GPGME_STATUS_TRUST_FULLY = 14,
406 GPGME_STATUS_TRUST_ULTIMATE = 15,
408 GPGME_STATUS_SHM_INFO = 16,
409 GPGME_STATUS_SHM_GET = 17,
410 GPGME_STATUS_SHM_GET_BOOL = 18,
411 GPGME_STATUS_SHM_GET_HIDDEN = 19,
413 GPGME_STATUS_NEED_PASSPHRASE = 20,
414 GPGME_STATUS_VALIDSIG = 21,
415 GPGME_STATUS_SIG_ID = 22,
416 GPGME_STATUS_ENC_TO = 23,
417 GPGME_STATUS_NODATA = 24,
418 GPGME_STATUS_BAD_PASSPHRASE = 25,
419 GPGME_STATUS_NO_PUBKEY = 26,
420 GPGME_STATUS_NO_SECKEY = 27,
421 GPGME_STATUS_NEED_PASSPHRASE_SYM = 28,
422 GPGME_STATUS_DECRYPTION_FAILED = 29,
423 GPGME_STATUS_DECRYPTION_OKAY = 30,
424 GPGME_STATUS_MISSING_PASSPHRASE = 31,
425 GPGME_STATUS_GOOD_PASSPHRASE = 32,
426 GPGME_STATUS_GOODMDC = 33,
427 GPGME_STATUS_BADMDC = 34,
428 GPGME_STATUS_ERRMDC = 35,
429 GPGME_STATUS_IMPORTED = 36,
430 GPGME_STATUS_IMPORT_OK = 37,
431 GPGME_STATUS_IMPORT_PROBLEM = 38,
432 GPGME_STATUS_IMPORT_RES = 39,
433 GPGME_STATUS_FILE_START = 40,
434 GPGME_STATUS_FILE_DONE = 41,
435 GPGME_STATUS_FILE_ERROR = 42,
437 GPGME_STATUS_BEGIN_DECRYPTION = 43,
438 GPGME_STATUS_END_DECRYPTION = 44,
439 GPGME_STATUS_BEGIN_ENCRYPTION = 45,
440 GPGME_STATUS_END_ENCRYPTION = 46,
442 GPGME_STATUS_DELETE_PROBLEM = 47,
443 GPGME_STATUS_GET_BOOL = 48,
444 GPGME_STATUS_GET_LINE = 49,
445 GPGME_STATUS_GET_HIDDEN = 50,
446 GPGME_STATUS_GOT_IT = 51,
447 GPGME_STATUS_PROGRESS = 52,
448 GPGME_STATUS_SIG_CREATED = 53,
449 GPGME_STATUS_SESSION_KEY = 54,
450 GPGME_STATUS_NOTATION_NAME = 55,
451 GPGME_STATUS_NOTATION_DATA = 56,
452 GPGME_STATUS_POLICY_URL = 57,
453 GPGME_STATUS_BEGIN_STREAM = 58,
454 GPGME_STATUS_END_STREAM = 59,
455 GPGME_STATUS_KEY_CREATED = 60,
456 GPGME_STATUS_USERID_HINT = 61,
457 GPGME_STATUS_UNEXPECTED = 62,
458 GPGME_STATUS_INV_RECP = 63,
459 GPGME_STATUS_NO_RECP = 64,
460 GPGME_STATUS_ALREADY_SIGNED = 65,
461 GPGME_STATUS_SIGEXPIRED = 66,
462 GPGME_STATUS_EXPSIG = 67,
463 GPGME_STATUS_EXPKEYSIG = 68,
464 GPGME_STATUS_TRUNCATED = 69,
465 GPGME_STATUS_ERROR = 70,
466 GPGME_STATUS_NEWSIG = 71,
467 GPGME_STATUS_REVKEYSIG = 72,
468 GPGME_STATUS_SIG_SUBPACKET = 73,
469 GPGME_STATUS_NEED_PASSPHRASE_PIN = 74,
470 GPGME_STATUS_SC_OP_FAILURE = 75,
471 GPGME_STATUS_SC_OP_SUCCESS = 76,
472 GPGME_STATUS_CARDCTRL = 77,
473 GPGME_STATUS_BACKUP_KEY_CREATED = 78,
474 GPGME_STATUS_PKA_TRUST_BAD = 79,
475 GPGME_STATUS_PKA_TRUST_GOOD = 80,
477 GPGME_STATUS_PLAINTEXT = 81
482 /* The engine information structure. */
483 struct _gpgme_engine_info
485 struct _gpgme_engine_info *next;
487 /* The protocol ID. */
488 gpgme_protocol_t protocol;
490 /* The file name of the engine binary. */
493 /* The version string of the installed engine. */
496 /* The minimum version required for GPGME. */
497 const char *req_version;
499 /* The home directory used, or NULL if default. */
502 typedef struct _gpgme_engine_info *gpgme_engine_info_t;
505 /* A subkey from a key. */
508 struct _gpgme_subkey *next;
510 /* True if subkey is revoked. */
511 unsigned int revoked : 1;
513 /* True if subkey is expired. */
514 unsigned int expired : 1;
516 /* True if subkey is disabled. */
517 unsigned int disabled : 1;
519 /* True if subkey is invalid. */
520 unsigned int invalid : 1;
522 /* True if subkey can be used for encryption. */
523 unsigned int can_encrypt : 1;
525 /* True if subkey can be used for signing. */
526 unsigned int can_sign : 1;
528 /* True if subkey can be used for certification. */
529 unsigned int can_certify : 1;
531 /* True if subkey is secret. */
532 unsigned int secret : 1;
534 /* True if subkey can be used for authentication. */
535 unsigned int can_authenticate : 1;
537 /* True if subkey is qualified for signatures according to German law. */
538 unsigned int is_qualified : 1;
540 /* True if the secret key is stored on a smart card. */
541 unsigned int is_cardkey : 1;
543 /* Internal to GPGME, do not use. */
544 unsigned int _unused : 21;
546 /* Public key algorithm supported by this subkey. */
547 gpgme_pubkey_algo_t pubkey_algo;
549 /* Length of the subkey. */
552 /* The key ID of the subkey. */
555 /* Internal to GPGME, do not use. */
558 /* The fingerprint of the subkey in hex digit form. */
561 /* The creation timestamp, -1 if invalid, 0 if not available. */
564 /* The expiration timestamp, 0 if the subkey does not expire. */
567 /* The serial number of a smart card holding this key or NULL. */
570 typedef struct _gpgme_subkey *gpgme_subkey_t;
573 /* A signature on a user ID. */
574 struct _gpgme_key_sig
576 struct _gpgme_key_sig *next;
578 /* True if the signature is a revocation signature. */
579 unsigned int revoked : 1;
581 /* True if the signature is expired. */
582 unsigned int expired : 1;
584 /* True if the signature is invalid. */
585 unsigned int invalid : 1;
587 /* True if the signature should be exported. */
588 unsigned int exportable : 1;
590 /* Internal to GPGME, do not use. */
591 unsigned int _unused : 28;
593 /* The public key algorithm used to create the signature. */
594 gpgme_pubkey_algo_t pubkey_algo;
596 /* The key ID of key used to create the signature. */
599 /* Internal to GPGME, do not use. */
602 /* The creation timestamp, -1 if invalid, 0 if not available. */
605 /* The expiration timestamp, 0 if the subkey does not expire. */
608 /* Same as in gpgme_signature_t. */
609 gpgme_error_t status;
612 unsigned int _obsolete_class _GPGME_DEPRECATED;
614 /* Must be set to SIG_CLASS below. */
615 unsigned int class _GPGME_DEPRECATED;
618 /* The user ID string. */
621 /* The name part of the user ID. */
624 /* The email part of the user ID. */
627 /* The comment part of the user ID. */
630 /* Crypto backend specific signature class. */
631 unsigned int sig_class;
633 /* Notation data and policy URLs. */
634 gpgme_sig_notation_t notations;
636 /* Internal to GPGME, do not use. */
637 gpgme_sig_notation_t _last_notation;
639 typedef struct _gpgme_key_sig *gpgme_key_sig_t;
642 /* An user ID from a key. */
643 struct _gpgme_user_id
645 struct _gpgme_user_id *next;
647 /* True if the user ID is revoked. */
648 unsigned int revoked : 1;
650 /* True if the user ID is invalid. */
651 unsigned int invalid : 1;
653 /* Internal to GPGME, do not use. */
654 unsigned int _unused : 30;
656 /* The validity of the user ID. */
657 gpgme_validity_t validity;
659 /* The user ID string. */
662 /* The name part of the user ID. */
665 /* The email part of the user ID. */
668 /* The comment part of the user ID. */
671 /* The signatures of the user ID. */
672 gpgme_key_sig_t signatures;
674 /* Internal to GPGME, do not use. */
675 gpgme_key_sig_t _last_keysig;
677 typedef struct _gpgme_user_id *gpgme_user_id_t;
680 /* A key from the keyring. */
683 /* Internal to GPGME, do not use. */
686 /* True if key is revoked. */
687 unsigned int revoked : 1;
689 /* True if key is expired. */
690 unsigned int expired : 1;
692 /* True if key is disabled. */
693 unsigned int disabled : 1;
695 /* True if key is invalid. */
696 unsigned int invalid : 1;
698 /* True if key can be used for encryption. */
699 unsigned int can_encrypt : 1;
701 /* True if key can be used for signing. */
702 unsigned int can_sign : 1;
704 /* True if key can be used for certification. */
705 unsigned int can_certify : 1;
707 /* True if key is secret. */
708 unsigned int secret : 1;
710 /* True if key can be used for authentication. */
711 unsigned int can_authenticate : 1;
713 /* True if subkey is qualified for signatures according to German law. */
714 unsigned int is_qualified : 1;
716 /* Internal to GPGME, do not use. */
717 unsigned int _unused : 22;
719 /* This is the protocol supported by this key. */
720 gpgme_protocol_t protocol;
722 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
726 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
730 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
734 /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
736 gpgme_validity_t owner_trust;
738 /* The subkeys of the key. */
739 gpgme_subkey_t subkeys;
741 /* The user IDs of the key. */
742 gpgme_user_id_t uids;
744 /* Internal to GPGME, do not use. */
745 gpgme_subkey_t _last_subkey;
747 /* Internal to GPGME, do not use. */
748 gpgme_user_id_t _last_uid;
750 /* The keylist mode that was active when listing the key. */
751 gpgme_keylist_mode_t keylist_mode;
753 typedef struct _gpgme_key *gpgme_key_t;
757 /* Types for callback functions. */
759 /* Request a passphrase from the user. */
760 typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
761 const char *uid_hint,
762 const char *passphrase_info,
763 int prev_was_bad, int fd);
765 /* Inform the user about progress made. */
766 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
767 int type, int current, int total);
769 /* Interact with the user about an edit operation. */
770 typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
771 gpgme_status_code_t status,
772 const char *args, int fd);
777 /* Context management functions. */
779 /* Create a new context and return it in CTX. */
780 gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
782 /* Release the context CTX. */
783 void gpgme_release (gpgme_ctx_t ctx);
785 /* Set the protocol to be used by CTX to PROTO. */
786 gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
788 /* Get the protocol used with CTX */
789 gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
791 /* Get the string describing protocol PROTO, or NULL if invalid. */
792 const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
794 /* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
795 void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
797 /* Return non-zero if armor mode is set in CTX. */
798 int gpgme_get_armor (gpgme_ctx_t ctx);
800 /* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
801 void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
803 /* Return non-zero if text mode is set in CTX. */
804 int gpgme_get_textmode (gpgme_ctx_t ctx);
806 /* Use whatever the default of the backend crypto engine is. */
807 #define GPGME_INCLUDE_CERTS_DEFAULT -256
809 /* Include up to NR_OF_CERTS certificates in an S/MIME message. */
810 void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
812 /* Return the number of certs to include in an S/MIME message. */
813 int gpgme_get_include_certs (gpgme_ctx_t ctx);
815 /* Set keylist mode in CTX to MODE. */
816 gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
817 gpgme_keylist_mode_t mode);
819 /* Get keylist mode in CTX. */
820 gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
822 /* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
823 passed as first argument to the passphrase callback function. */
824 void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
825 gpgme_passphrase_cb_t cb, void *hook_value);
827 /* Get the current passphrase callback function in *CB and the current
828 hook value in *HOOK_VALUE. */
829 void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
832 /* Set the progress callback function in CTX to CB. HOOK_VALUE is
833 passed as first argument to the progress callback function. */
834 void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
837 /* Get the current progress callback function in *CB and the current
838 hook value in *HOOK_VALUE. */
839 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
842 /* This function sets the locale for the context CTX, or the default
843 locale if CTX is a null pointer. */
844 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
847 /* Get the information about the configured engines. A pointer to the
848 first engine in the statically allocated linked list is returned.
849 The returned data is valid until the next gpgme_ctx_set_engine_info. */
850 gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
852 /* Set the engine info for the context CTX, protocol PROTO, to the
853 file name FILE_NAME and the home directory HOME_DIR. */
854 gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
855 gpgme_protocol_t proto,
856 const char *file_name,
857 const char *home_dir);
860 /* Return a statically allocated string with the name of the public
861 key algorithm ALGO, or NULL if that name is not known. */
862 const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
864 /* Return a statically allocated string with the name of the hash
865 algorithm ALGO, or NULL if that name is not known. */
866 const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
869 /* Delete all signers from CTX. */
870 void gpgme_signers_clear (gpgme_ctx_t ctx);
872 /* Add KEY to list of signers in CTX. */
873 gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
875 /* Return the SEQth signer's key in CTX. */
876 gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
878 /* Retrieve the signature status of signature IDX in CTX after a
879 successful verify operation in R_STAT (if non-null). The creation
880 time stamp of the signature is returned in R_CREATED (if non-null).
881 The function returns a string containing the fingerprint.
882 Deprecated, use verify result directly. */
883 const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
884 _gpgme_sig_stat_t *r_stat,
885 time_t *r_created) _GPGME_DEPRECATED;
887 /* Retrieve certain attributes of a signature. IDX is the index
888 number of the signature after a successful verify operation. WHAT
889 is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
890 one. WHATIDX is to be passed as 0 for most attributes . */
891 unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
892 _gpgme_attr_t what, int whatidx)
894 const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
895 _gpgme_attr_t what, int whatidx)
899 /* Get the key used to create signature IDX in CTX and return it in
901 gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
905 /* Clear all notation data from the context. */
906 void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
908 /* Add the human-readable notation data with name NAME and value VALUE
909 to the context CTX, using the flags FLAGS. If NAME is NULL, then
910 VALUE should be a policy URL. The flag
911 GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
912 data, and false for policy URLs. */
913 gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
915 gpgme_sig_notation_flags_t flags);
917 /* Get the sig notations for this context. */
918 gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
923 /* The type of an I/O callback function. */
924 typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
926 /* The type of a function that can register FNC as the I/O callback
927 function for the file descriptor FD with direction dir (0: for writing,
928 1: for reading). FNC_DATA should be passed as DATA to FNC. The
929 function should return a TAG suitable for the corresponding
930 gpgme_remove_io_cb_t, and an error value. */
931 typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
933 void *fnc_data, void **tag);
935 /* The type of a function that can remove a previously registered I/O
936 callback function given TAG as returned by the register
938 typedef void (*gpgme_remove_io_cb_t) (void *tag);
944 GPGME_EVENT_NEXT_KEY,
945 GPGME_EVENT_NEXT_TRUSTITEM
949 /* The type of a function that is called when a context finished an
951 typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
956 gpgme_register_io_cb_t add;
958 gpgme_remove_io_cb_t remove;
959 gpgme_event_io_cb_t event;
962 typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
964 /* Set the I/O callback functions in CTX to IO_CBS. */
965 void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
967 /* Get the current I/O callback functions. */
968 void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
970 /* Wrappers around the internal I/O functions for use with
971 gpgme_passphrase_cb_t and gpgme_edit_cb_t. */
972 ssize_t gpgme_io_read (int fd, void *buffer, size_t count);
973 ssize_t gpgme_io_write (int fd, const void *buffer, size_t count);
975 /* Process the pending operation and, if HANG is non-zero, wait for
976 the pending operation to finish. */
977 gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
980 /* Functions to handle data objects. */
982 /* Read up to SIZE bytes into buffer BUFFER from the data object with
983 the handle HANDLE. Return the number of characters read, 0 on EOF
984 and -1 on error. If an error occurs, errno is set. */
985 typedef ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer,
988 /* Write up to SIZE bytes from buffer BUFFER to the data object with
989 the handle HANDLE. Return the number of characters written, or -1
990 on error. If an error occurs, errno is set. */
991 typedef ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
994 /* Set the current position from where the next read or write starts
995 in the data object with the handle HANDLE to OFFSET, relativ to
997 typedef off_t (*gpgme_data_seek_cb_t) (void *handle, off_t offset, int whence);
999 /* Close the data object with the handle DL. */
1000 typedef void (*gpgme_data_release_cb_t) (void *handle);
1002 struct gpgme_data_cbs
1004 gpgme_data_read_cb_t read;
1005 gpgme_data_write_cb_t write;
1006 gpgme_data_seek_cb_t seek;
1007 gpgme_data_release_cb_t release;
1009 typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
1011 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1012 the handle DH. Return the number of characters read, 0 on EOF and
1013 -1 on error. If an error occurs, errno is set. */
1014 ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
1016 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1017 the handle DH. Return the number of characters written, or -1 on
1018 error. If an error occurs, errno is set. */
1019 ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
1021 /* Set the current position from where the next read or write starts
1022 in the data object with the handle DH to OFFSET, relativ to
1024 off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence);
1026 /* Create a new data buffer and return it in R_DH. */
1027 gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
1029 /* Destroy the data buffer DH. */
1030 void gpgme_data_release (gpgme_data_t dh);
1032 /* Create a new data buffer filled with SIZE bytes starting from
1033 BUFFER. If COPY is zero, copying is delayed until necessary, and
1034 the data is taken from the original location when needed. */
1035 gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
1036 const char *buffer, size_t size,
1039 /* Destroy the data buffer DH and return a pointer to its content.
1040 The memory has be to released with gpgme_free() by the user. It's
1041 size is returned in R_LEN. */
1042 char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
1044 /* Release the memory returned by gpgme_data_release_and_get_mem(). */
1045 void gpgme_free (void *buffer);
1047 gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
1048 gpgme_data_cbs_t cbs,
1051 gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
1053 gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
1055 /* Return the encoding attribute of the data buffer DH */
1056 gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
1058 /* Set the encoding attribute of data buffer DH to ENC */
1059 gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
1060 gpgme_data_encoding_t enc);
1062 /* Get the file name associated with the data object with handle DH, or
1063 NULL if there is none. */
1064 char *gpgme_data_get_file_name (gpgme_data_t dh);
1066 /* Set the file name associated with the data object with handle DH to
1068 gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
1069 const char *file_name);
1072 /* Create a new data buffer which retrieves the data from the callback
1073 function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
1075 gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
1076 int (*read_cb) (void*,char *,
1078 void *read_cb_value)
1081 /* Create a new data buffer filled with the content of file FNAME.
1082 COPY must be non-zero. For delayed read, please use
1083 gpgme_data_new_from_fd or gpgme_data_new_from stream instead. */
1084 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
1088 /* Create a new data buffer filled with LENGTH bytes starting from
1089 OFFSET within the file FNAME or stream FP (exactly one must be
1091 gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
1092 const char *fname, FILE *fp,
1093 off_t offset, size_t length);
1095 /* Reset the read pointer in DH. Deprecated, please use
1096 gpgme_data_seek instead. */
1097 gpgme_error_t gpgme_data_rewind (gpgme_data_t dh) _GPGME_DEPRECATED;
1100 /* Key and trust functions. */
1102 /* Get the key with the fingerprint FPR from the crypto backend. If
1103 SECRET is true, get the secret key. */
1104 gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
1105 gpgme_key_t *r_key, int secret);
1107 /* Acquire a reference to KEY. */
1108 void gpgme_key_ref (gpgme_key_t key);
1110 /* Release a reference to KEY. If this was the last one the key is
1112 void gpgme_key_unref (gpgme_key_t key);
1113 void gpgme_key_release (gpgme_key_t key);
1115 /* Return the value of the attribute WHAT of KEY, which has to be
1116 representable by a string. IDX specifies the sub key or user ID
1117 for attributes related to sub keys or user IDs. Deprecated, use
1118 key structure directly instead. */
1119 const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
1120 const void *reserved, int idx)
1123 /* Return the value of the attribute WHAT of KEY, which has to be
1124 representable by an unsigned integer. IDX specifies the sub key or
1125 user ID for attributes related to sub keys or user IDs.
1126 Deprecated, use key structure directly instead. */
1127 unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
1128 const void *reserved, int idx)
1131 /* Return the value of the attribute WHAT of a signature on user ID
1132 UID_IDX in KEY, which has to be representable by a string. IDX
1133 specifies the signature. Deprecated, use key structure directly
1135 const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
1137 const void *reserved, int idx)
1140 /* Return the value of the attribute WHAT of a signature on user ID
1141 UID_IDX in KEY, which has to be representable by an unsigned
1142 integer string. IDX specifies the signature. Deprecated, use key
1143 structure directly instead. */
1144 unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
1146 const void *reserved, int idx)
1150 /* Crypto Operations. */
1152 /* Cancel a pending asynchronous operation. */
1153 gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
1155 /* Cancel a pending operation asynchronously. */
1156 gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx);
1159 struct _gpgme_invalid_key
1161 struct _gpgme_invalid_key *next;
1163 gpgme_error_t reason;
1165 typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
1169 struct _gpgme_op_encrypt_result
1171 /* The list of invalid recipients. */
1172 gpgme_invalid_key_t invalid_recipients;
1174 typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
1176 /* Retrieve a pointer to the result of the encrypt operation. */
1177 gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
1179 /* The valid encryption flags. */
1182 GPGME_ENCRYPT_ALWAYS_TRUST = 1,
1183 GPGME_ENCRYPT_NO_ENCRYPT_TO = 2
1185 gpgme_encrypt_flags_t;
1187 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1188 store the resulting ciphertext in CIPHER. */
1189 gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
1190 gpgme_encrypt_flags_t flags,
1191 gpgme_data_t plain, gpgme_data_t cipher);
1192 gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
1193 gpgme_encrypt_flags_t flags,
1194 gpgme_data_t plain, gpgme_data_t cipher);
1196 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1197 store the resulting ciphertext in CIPHER. Also sign the ciphertext
1198 with the signers in CTX. */
1199 gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
1201 gpgme_encrypt_flags_t flags,
1203 gpgme_data_t cipher);
1204 gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
1205 gpgme_encrypt_flags_t flags,
1206 gpgme_data_t plain, gpgme_data_t cipher);
1211 struct _gpgme_recipient
1213 struct _gpgme_recipient *next;
1215 /* The key ID of key for which the text was encrypted. */
1218 /* Internal to GPGME, do not use. */
1219 char _keyid[16 + 1];
1221 /* The public key algorithm of the recipient key. */
1222 gpgme_pubkey_algo_t pubkey_algo;
1224 /* The status of the recipient. */
1225 gpgme_error_t status;
1227 typedef struct _gpgme_recipient *gpgme_recipient_t;
1229 struct _gpgme_op_decrypt_result
1231 char *unsupported_algorithm;
1233 /* Key should not have been used for encryption. */
1234 unsigned int wrong_key_usage : 1;
1236 /* Internal to GPGME, do not use. */
1239 gpgme_recipient_t recipients;
1241 /* The original file name of the plaintext message, if
1245 typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
1247 /* Retrieve a pointer to the result of the decrypt operation. */
1248 gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
1250 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1251 plaintext in PLAIN. */
1252 gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
1253 gpgme_data_t plain);
1254 gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
1255 gpgme_data_t cipher, gpgme_data_t plain);
1257 /* Decrypt ciphertext CIPHER and make a signature verification within
1258 CTX and store the resulting plaintext in PLAIN. */
1259 gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
1260 gpgme_data_t cipher,
1261 gpgme_data_t plain);
1262 gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
1263 gpgme_data_t plain);
1267 struct _gpgme_new_signature
1269 struct _gpgme_new_signature *next;
1271 /* The type of the signature. */
1272 gpgme_sig_mode_t type;
1274 /* The public key algorithm used to create the signature. */
1275 gpgme_pubkey_algo_t pubkey_algo;
1277 /* The hash algorithm used to create the signature. */
1278 gpgme_hash_algo_t hash_algo;
1280 /* Internal to GPGME, do not use. Must be set to the same value as
1282 unsigned long _obsolete_class;
1284 /* Signature creation time. */
1287 /* The fingerprint of the signature. */
1291 unsigned int _obsolete_class_2;
1293 /* Must be set to SIG_CLASS below. */
1294 unsigned int class _GPGME_DEPRECATED;
1297 /* Crypto backend specific signature class. */
1298 unsigned int sig_class;
1300 typedef struct _gpgme_new_signature *gpgme_new_signature_t;
1302 struct _gpgme_op_sign_result
1304 /* The list of invalid signers. */
1305 gpgme_invalid_key_t invalid_signers;
1306 gpgme_new_signature_t signatures;
1308 typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
1310 /* Retrieve a pointer to the result of the signing operation. */
1311 gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1313 /* Sign the plaintext PLAIN and store the signature in SIG. */
1314 gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
1315 gpgme_data_t plain, gpgme_data_t sig,
1316 gpgme_sig_mode_t mode);
1317 gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
1318 gpgme_data_t plain, gpgme_data_t sig,
1319 gpgme_sig_mode_t mode);
1324 /* Flags used for the SUMMARY field in a gpgme_signature_t. */
1327 GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
1328 GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
1329 GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
1330 GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
1331 GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
1332 GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
1333 GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
1334 GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
1335 GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
1336 GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
1337 GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */
1341 struct _gpgme_signature
1343 struct _gpgme_signature *next;
1345 /* A summary of the signature status. */
1346 gpgme_sigsum_t summary;
1348 /* The fingerprint or key ID of the signature. */
1351 /* The status of the signature. */
1352 gpgme_error_t status;
1354 /* Notation data and policy URLs. */
1355 gpgme_sig_notation_t notations;
1357 /* Signature creation time. */
1358 unsigned long timestamp;
1360 /* Signature exipration time or 0. */
1361 unsigned long exp_timestamp;
1363 /* Key should not have been used for signing. */
1364 unsigned int wrong_key_usage : 1;
1366 /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1367 unsigned int pka_trust : 2;
1369 /* Validity has been verified using the chain model. */
1370 unsigned int chain_model : 1;
1372 /* Internal to GPGME, do not use. */
1375 gpgme_validity_t validity;
1376 gpgme_error_t validity_reason;
1378 /* The public key algorithm used to create the signature. */
1379 gpgme_pubkey_algo_t pubkey_algo;
1381 /* The hash algorithm used to create the signature. */
1382 gpgme_hash_algo_t hash_algo;
1384 /* The mailbox from the PKA information or NULL. */
1387 typedef struct _gpgme_signature *gpgme_signature_t;
1389 struct _gpgme_op_verify_result
1391 gpgme_signature_t signatures;
1393 /* The original file name of the plaintext message, if
1397 typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
1399 /* Retrieve a pointer to the result of the verify operation. */
1400 gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
1402 /* Verify within CTX that SIG is a valid signature for TEXT. */
1403 gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
1404 gpgme_data_t signed_text,
1405 gpgme_data_t plaintext);
1406 gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
1407 gpgme_data_t signed_text,
1408 gpgme_data_t plaintext);
1413 /* The key was new. */
1414 #define GPGME_IMPORT_NEW 1
1416 /* The key contained new user IDs. */
1417 #define GPGME_IMPORT_UID 2
1419 /* The key contained new signatures. */
1420 #define GPGME_IMPORT_SIG 4
1422 /* The key contained new sub keys. */
1423 #define GPGME_IMPORT_SUBKEY 8
1425 /* The key contained a secret key. */
1426 #define GPGME_IMPORT_SECRET 16
1429 struct _gpgme_import_status
1431 struct _gpgme_import_status *next;
1436 /* If a problem occured, the reason why the key could not be
1437 imported. Otherwise GPGME_No_Error. */
1438 gpgme_error_t result;
1440 /* The result of the import, the GPGME_IMPORT_* values bit-wise
1441 ORed. 0 means the key was already known and no new components
1443 unsigned int status;
1445 typedef struct _gpgme_import_status *gpgme_import_status_t;
1448 struct _gpgme_op_import_result
1450 /* Number of considered keys. */
1453 /* Keys without user ID. */
1456 /* Imported keys. */
1459 /* Imported RSA keys. */
1462 /* Unchanged keys. */
1465 /* Number of new user ids. */
1468 /* Number of new sub keys. */
1471 /* Number of new signatures. */
1474 /* Number of new revocations. */
1475 int new_revocations;
1477 /* Number of secret keys read. */
1480 /* Number of secret keys imported. */
1481 int secret_imported;
1483 /* Number of secret keys unchanged. */
1484 int secret_unchanged;
1486 /* Number of new keys skipped. */
1487 int skipped_new_keys;
1489 /* Number of keys not imported. */
1492 /* List of keys for which an import was attempted. */
1493 gpgme_import_status_t imports;
1495 typedef struct _gpgme_op_import_result *gpgme_import_result_t;
1497 /* Retrieve a pointer to the result of the import operation. */
1498 gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
1500 /* Import the key in KEYDATA into the keyring. */
1501 gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
1502 gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
1503 gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
1504 int *nr) _GPGME_DEPRECATED;
1506 /* Import the keys from the array KEYS into the keyring. */
1507 gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1508 gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1512 /* Export the keys found by PATTERN into KEYDATA. */
1513 gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
1514 gpgme_export_mode_t mode,
1515 gpgme_data_t keydata);
1516 gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
1517 gpgme_export_mode_t mode,
1518 gpgme_data_t keydata);
1520 gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
1521 const char *pattern[],
1522 gpgme_export_mode_t mode,
1523 gpgme_data_t keydata);
1524 gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
1525 gpgme_export_mode_t mode,
1526 gpgme_data_t keydata);
1528 /* Export the keys from the array KEYS into KEYDATA. */
1529 gpgme_error_t gpgme_op_export_keys_start (gpgme_ctx_t ctx,
1531 gpgme_export_mode_t mode,
1532 gpgme_data_t keydata);
1533 gpgme_error_t gpgme_op_export_keys (gpgme_ctx_t ctx,
1535 gpgme_export_mode_t mode,
1536 gpgme_data_t keydata);
1540 /* Key generation. */
1541 struct _gpgme_op_genkey_result
1543 /* A primary key was generated. */
1544 unsigned int primary : 1;
1546 /* A sub key was generated. */
1547 unsigned int sub : 1;
1549 /* Internal to GPGME, do not use. */
1550 unsigned int _unused : 30;
1552 /* The fingerprint of the generated key. */
1555 typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
1557 /* Generate a new keypair and add it to the keyring. PUBKEY and
1558 SECKEY should be null for now. PARMS specifies what keys should be
1560 gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
1561 gpgme_data_t pubkey, gpgme_data_t seckey);
1562 gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
1563 gpgme_data_t pubkey, gpgme_data_t seckey);
1565 /* Retrieve a pointer to the result of the genkey operation. */
1566 gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
1569 /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
1570 keys are also deleted. */
1571 gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
1573 gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
1577 /* Edit the key KEY. Send status and command requests to FNC and
1578 output of edit commands to OUT. */
1579 gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1580 gpgme_edit_cb_t fnc, void *fnc_value,
1582 gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1583 gpgme_edit_cb_t fnc, void *fnc_value,
1586 /* Edit the card for the key KEY. Send status and command requests to
1587 FNC and output of edit commands to OUT. */
1588 gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1589 gpgme_edit_cb_t fnc, void *fnc_value,
1591 gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1592 gpgme_edit_cb_t fnc, void *fnc_value,
1596 /* Key management functions. */
1597 struct _gpgme_op_keylist_result
1599 unsigned int truncated : 1;
1601 /* Internal to GPGME, do not use. */
1602 unsigned int _unused : 31;
1604 typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
1606 /* Retrieve a pointer to the result of the key listing operation. */
1607 gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
1609 /* Start a keylist operation within CTX, searching for keys which
1610 match PATTERN. If SECRET_ONLY is true, only secret keys are
1612 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
1614 gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
1615 const char *pattern[],
1616 int secret_only, int reserved);
1618 /* Return the next key from the keylist in R_KEY. */
1619 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
1621 /* Terminate a pending keylist operation within CTX. */
1622 gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
1625 /* Trust items and operations. */
1627 struct _gpgme_trust_item
1629 /* Internal to GPGME, do not use. */
1632 /* The key ID to which the trust item belongs. */
1635 /* Internal to GPGME, do not use. */
1636 char _keyid[16 + 1];
1638 /* The type of the trust item, 1 refers to a key, 2 to a user ID. */
1641 /* The trust level. */
1644 /* The owner trust if TYPE is 1. */
1647 /* Internal to GPGME, do not use. */
1648 char _owner_trust[2];
1650 /* The calculated validity. */
1653 /* Internal to GPGME, do not use. */
1656 /* The user name if TYPE is 2. */
1659 typedef struct _gpgme_trust_item *gpgme_trust_item_t;
1661 /* Start a trustlist operation within CTX, searching for trust items
1662 which match PATTERN. */
1663 gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
1664 const char *pattern, int max_level);
1666 /* Return the next trust item from the trustlist in R_ITEM. */
1667 gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
1668 gpgme_trust_item_t *r_item);
1670 /* Terminate a pending trustlist operation within CTX. */
1671 gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
1673 /* Acquire a reference to ITEM. */
1674 void gpgme_trust_item_ref (gpgme_trust_item_t item);
1676 /* Release a reference to ITEM. If this was the last one the trust
1677 item is destroyed. */
1678 void gpgme_trust_item_unref (gpgme_trust_item_t item);
1680 /* Release the trust item ITEM. Deprecated, use
1681 gpgme_trust_item_unref. */
1682 void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED;
1684 /* Return the value of the attribute WHAT of ITEM, which has to be
1685 representable by a string. Deprecated, use trust item structure
1687 const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item,
1689 const void *reserved, int idx)
1692 /* Return the value of the attribute WHAT of KEY, which has to be
1693 representable by an integer. IDX specifies a running index if the
1694 attribute appears more than once in the key. Deprecated, use trust
1695 item structure directly. */
1696 int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what,
1697 const void *reserved, int idx)
1701 /* Return the auditlog for the current session. This may be called
1702 after a successful or failed operation. If no audit log is
1703 available GPG_ERR_NO_DATA is returned. */
1704 gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
1705 unsigned int flags);
1706 gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
1707 unsigned int flags);
1711 /* Low-level Assuan protocol access. */
1712 typedef gpgme_error_t (*gpgme_assuan_data_cb_t)
1713 (void *opaque, const void *data, size_t datalen);
1715 typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t)
1716 (void *opaque, const char *name, const char *args,
1717 gpgme_data_t *r_data);
1719 typedef gpgme_error_t (*gpgme_assuan_status_cb_t)
1720 (void *opaque, const char *status, const char *args);
1722 struct _gpgme_op_assuan_result
1724 /* The result of the actual assuan command. An OK is indicated by a
1725 value of 0 and an ERR by the respective error error value. */
1728 typedef struct _gpgme_op_assuan_result *gpgme_assuan_result_t;
1731 /* Return the result of the last Assuan command. */
1732 gpgme_assuan_result_t gpgme_op_assuan_result (gpgme_ctx_t ctx);
1734 /* Send the Assuan COMMAND and return results via the callbacks.
1735 Asynchronous variant. */
1736 gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx,
1737 const char *command,
1738 gpgme_assuan_data_cb_t data_cb,
1739 void *data_cb_value,
1740 gpgme_assuan_inquire_cb_t inq_cb,
1742 gpgme_assuan_status_cb_t stat_cb,
1743 void *stat_cb_value);
1745 /* Send the Assuan COMMAND and return results via the callbacks.
1746 Synchronous variant. */
1747 gpgme_error_t gpgme_op_assuan_transact (gpgme_ctx_t ctx,
1748 const char *command,
1749 gpgme_assuan_data_cb_t data_cb,
1750 void *data_cb_value,
1751 gpgme_assuan_inquire_cb_t inq_cb,
1753 gpgme_assuan_status_cb_t stat_cb,
1754 void *stat_cb_value);
1758 /* Interface to gpgconf(1). */
1760 /* The expert level at which a configuration option or group of
1761 options should be displayed. See the gpgconf(1) documentation for
1765 GPGME_CONF_BASIC = 0,
1766 GPGME_CONF_ADVANCED = 1,
1767 GPGME_CONF_EXPERT = 2,
1768 GPGME_CONF_INVISIBLE = 3,
1769 GPGME_CONF_INTERNAL = 4
1774 /* The data type of a configuration option argument. See the gpgconf(1)
1775 documentation for more details. */
1779 GPGME_CONF_NONE = 0,
1780 GPGME_CONF_STRING = 1,
1781 GPGME_CONF_INT32 = 2,
1782 GPGME_CONF_UINT32 = 3,
1784 /* Complex types. */
1785 GPGME_CONF_FILENAME = 32,
1786 GPGME_CONF_LDAP_SERVER = 33,
1787 GPGME_CONF_KEY_FPR = 34,
1788 GPGME_CONF_PUB_KEY = 35,
1789 GPGME_CONF_SEC_KEY = 36,
1790 GPGME_CONF_ALIAS_LIST = 37
1793 /* Macro for backward compatibility (even though it was undocumented
1794 and marked as experimental in 1.1.6 - will be removed after 1.1.7): */
1795 #define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
1798 /* This represents a single argument for a configuration option.
1799 Which of the members of value is used depends on the ALT_TYPE. */
1800 typedef struct gpgme_conf_arg
1802 struct gpgme_conf_arg *next;
1803 /* True if the option appears without an (optional) argument. */
1804 unsigned int no_arg;
1808 unsigned int uint32;
1812 } *gpgme_conf_arg_t;
1815 /* The flags of a configuration option. See the gpg-conf
1816 documentation for details. */
1817 #define GPGME_CONF_GROUP (1 << 0)
1818 #define GPGME_CONF_OPTIONAL (1 << 1)
1819 #define GPGME_CONF_LIST (1 << 2)
1820 #define GPGME_CONF_RUNTIME (1 << 3)
1821 #define GPGME_CONF_DEFAULT (1 << 4)
1822 #define GPGME_CONF_DEFAULT_DESC (1 << 5)
1823 #define GPGME_CONF_NO_ARG_DESC (1 << 6)
1824 #define GPGME_CONF_NO_CHANGE (1 << 7)
1827 /* The representation of a single configuration option. See the
1828 gpg-conf documentation for details. */
1829 typedef struct gpgme_conf_opt
1831 struct gpgme_conf_opt *next;
1833 /* The option name. */
1836 /* The flags for this option. */
1839 /* The level of this option. */
1840 gpgme_conf_level_t level;
1842 /* The localized description of this option. */
1845 /* The type and alternate type of this option. */
1846 gpgme_conf_type_t type;
1847 gpgme_conf_type_t alt_type;
1849 /* The localized (short) name of the argument, if any. */
1852 /* The default value. */
1853 gpgme_conf_arg_t default_value;
1854 char *default_description;
1856 /* The default value if the option is not set. */
1857 gpgme_conf_arg_t no_arg_value;
1858 char *no_arg_description;
1860 /* The current value if the option is set. */
1861 gpgme_conf_arg_t value;
1863 /* The new value, if any. NULL means reset to default. */
1865 gpgme_conf_arg_t new_value;
1867 /* Free for application use. */
1869 } *gpgme_conf_opt_t;
1872 /* The representation of a component that can be configured. See the
1873 gpg-conf documentation for details. */
1874 typedef struct gpgme_conf_comp
1876 struct gpgme_conf_comp *next;
1878 /* Internal to GPGME, do not use! */
1879 gpgme_conf_opt_t *_last_opt_p;
1881 /* The component name. */
1884 /* A human-readable description for the component. */
1887 /* The program name (an absolute path to the program). */
1890 /* A linked list of options for this component. */
1891 struct gpgme_conf_opt *options;
1892 } *gpgme_conf_comp_t;
1895 /* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg
1896 default" is prepared. If type is a string type, VALUE should point
1897 to the string. Else, it should point to an unsigned or signed
1898 integer respectively. */
1899 gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
1900 gpgme_conf_type_t type, void *value);
1902 /* This also releases all chained argument structures! */
1903 void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
1905 /* Register a change for the value of OPT to ARG. If RESET is 1 (do
1906 not use any values but 0 or 1), ARG is ignored and the option is
1907 not changed (reverting a previous change). Otherwise, if ARG is
1908 NULL, the option is cleared or reset to its default. */
1909 gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
1910 gpgme_conf_arg_t arg);
1912 /* Release a set of configurations. */
1913 void gpgme_conf_release (gpgme_conf_comp_t conf);
1915 /* Retrieve the current configurations. */
1916 gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
1918 /* Save the configuration of component comp. This function does not
1919 follow chained components! */
1920 gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
1923 /* Various functions. */
1925 /* Check that the library fulfills the version requirement. Note:
1926 This is here only for the case where a user takes a pointer from
1927 the old version of this function. The new version and macro for
1928 run-time checks are below. */
1929 const char *gpgme_check_version (const char *req_version);
1931 /* Check that the library fulfills the version requirement and check
1932 for struct layout mismatch involving bitfields. */
1933 const char *gpgme_check_version_internal (const char *req_version,
1934 size_t offset_sig_validity);
1936 #define gpgme_check_version(req_version) \
1937 gpgme_check_version_internal (req_version, \
1938 offsetof (struct _gpgme_signature, validity))
1940 /* Get the information about the configured and installed engines. A
1941 pointer to the first engine in the statically allocated linked list
1942 is returned in *INFO. If an error occurs, it is returned. The
1943 returned data is valid until the next gpgme_set_engine_info. */
1944 gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
1946 /* Set the default engine info for the protocol PROTO to the file name
1947 FILE_NAME and the home directory HOME_DIR. */
1948 gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
1949 const char *file_name,
1950 const char *home_dir);
1953 /* Engine support functions. */
1955 /* Verify that the engine implementing PROTO is installed and
1957 gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
1960 void gpgme_result_ref (void *result);
1961 void gpgme_result_unref (void *result);
1964 /* Deprecated types. */
1965 typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED;
1966 typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED;
1967 typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED;
1968 typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED;
1969 typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED;
1970 typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED;
1971 typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED;
1972 typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED;
1973 typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED;
1974 typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED;
1975 typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED;
1976 typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED;
1977 typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED;
1978 typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED;
1979 typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED;
1980 typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED;
1981 typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED;
1982 typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED;
1983 typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED;
1984 typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED;
1985 typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED;
1986 typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED;
1987 typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED;
1988 #define GpgmeIOCbs gpgme_io_cbs
1989 typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED;
1990 typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED;
1991 typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED;
1992 typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED;
1993 #define GpgmeDataCbs gpgme_data_cbs
1994 typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED;
1995 typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED;
1996 typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED;
1997 typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED;
1998 typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED;
1999 typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED;
2000 typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED;
2001 typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED;
2002 typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED;
2007 #endif /* GPGME_H */