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 /* Flags for the audit log functions. */
333 #define GPGME_AUDITLOG_HTML 1
334 #define GPGME_AUDITLOG_WITH_HELP 128
337 /* Signature notations. */
339 /* The available signature notation flags. */
340 #define GPGME_SIG_NOTATION_HUMAN_READABLE 1
341 #define GPGME_SIG_NOTATION_CRITICAL 2
343 typedef unsigned int gpgme_sig_notation_flags_t;
345 struct _gpgme_sig_notation
347 struct _gpgme_sig_notation *next;
349 /* If NAME is a null pointer, then VALUE contains a policy URL
350 rather than a notation. */
353 /* The value of the notation data. */
356 /* The length of the name of the notation data. */
359 /* The length of the value of the notation data. */
362 /* The accumulated flags. */
363 gpgme_sig_notation_flags_t flags;
365 /* Notation data is human-readable. */
366 unsigned int human_readable : 1;
368 /* Notation data is critical. */
369 unsigned int critical : 1;
371 /* Internal to GPGME, do not use. */
374 typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
377 /* The possible stati for the edit operation. */
381 /* mkstatus processing starts here */
386 GPGME_STATUS_GOODSIG,
390 GPGME_STATUS_BADARMOR,
392 GPGME_STATUS_RSA_OR_IDEA,
393 GPGME_STATUS_KEYEXPIRED,
394 GPGME_STATUS_KEYREVOKED,
396 GPGME_STATUS_TRUST_UNDEFINED,
397 GPGME_STATUS_TRUST_NEVER,
398 GPGME_STATUS_TRUST_MARGINAL,
399 GPGME_STATUS_TRUST_FULLY,
400 GPGME_STATUS_TRUST_ULTIMATE,
402 GPGME_STATUS_SHM_INFO,
403 GPGME_STATUS_SHM_GET,
404 GPGME_STATUS_SHM_GET_BOOL,
405 GPGME_STATUS_SHM_GET_HIDDEN,
407 GPGME_STATUS_NEED_PASSPHRASE,
408 GPGME_STATUS_VALIDSIG,
412 GPGME_STATUS_BAD_PASSPHRASE,
413 GPGME_STATUS_NO_PUBKEY,
414 GPGME_STATUS_NO_SECKEY,
415 GPGME_STATUS_NEED_PASSPHRASE_SYM,
416 GPGME_STATUS_DECRYPTION_FAILED,
417 GPGME_STATUS_DECRYPTION_OKAY,
418 GPGME_STATUS_MISSING_PASSPHRASE,
419 GPGME_STATUS_GOOD_PASSPHRASE,
420 GPGME_STATUS_GOODMDC,
423 GPGME_STATUS_IMPORTED,
424 GPGME_STATUS_IMPORT_OK,
425 GPGME_STATUS_IMPORT_PROBLEM,
426 GPGME_STATUS_IMPORT_RES,
427 GPGME_STATUS_FILE_START,
428 GPGME_STATUS_FILE_DONE,
429 GPGME_STATUS_FILE_ERROR,
431 GPGME_STATUS_BEGIN_DECRYPTION,
432 GPGME_STATUS_END_DECRYPTION,
433 GPGME_STATUS_BEGIN_ENCRYPTION,
434 GPGME_STATUS_END_ENCRYPTION,
436 GPGME_STATUS_DELETE_PROBLEM,
437 GPGME_STATUS_GET_BOOL,
438 GPGME_STATUS_GET_LINE,
439 GPGME_STATUS_GET_HIDDEN,
441 GPGME_STATUS_PROGRESS,
442 GPGME_STATUS_SIG_CREATED,
443 GPGME_STATUS_SESSION_KEY,
444 GPGME_STATUS_NOTATION_NAME,
445 GPGME_STATUS_NOTATION_DATA,
446 GPGME_STATUS_POLICY_URL,
447 GPGME_STATUS_BEGIN_STREAM,
448 GPGME_STATUS_END_STREAM,
449 GPGME_STATUS_KEY_CREATED,
450 GPGME_STATUS_USERID_HINT,
451 GPGME_STATUS_UNEXPECTED,
452 GPGME_STATUS_INV_RECP,
453 GPGME_STATUS_NO_RECP,
454 GPGME_STATUS_ALREADY_SIGNED,
455 GPGME_STATUS_SIGEXPIRED,
457 GPGME_STATUS_EXPKEYSIG,
458 GPGME_STATUS_TRUNCATED,
461 GPGME_STATUS_REVKEYSIG,
462 GPGME_STATUS_SIG_SUBPACKET,
463 GPGME_STATUS_NEED_PASSPHRASE_PIN,
464 GPGME_STATUS_SC_OP_FAILURE,
465 GPGME_STATUS_SC_OP_SUCCESS,
466 GPGME_STATUS_CARDCTRL,
467 GPGME_STATUS_BACKUP_KEY_CREATED,
468 GPGME_STATUS_PKA_TRUST_BAD,
469 GPGME_STATUS_PKA_TRUST_GOOD,
471 GPGME_STATUS_PLAINTEXT
476 /* The engine information structure. */
477 struct _gpgme_engine_info
479 struct _gpgme_engine_info *next;
481 /* The protocol ID. */
482 gpgme_protocol_t protocol;
484 /* The file name of the engine binary. */
487 /* The version string of the installed engine. */
490 /* The minimum version required for GPGME. */
491 const char *req_version;
493 /* The home directory used, or NULL if default. */
496 typedef struct _gpgme_engine_info *gpgme_engine_info_t;
499 /* A subkey from a key. */
502 struct _gpgme_subkey *next;
504 /* True if subkey is revoked. */
505 unsigned int revoked : 1;
507 /* True if subkey is expired. */
508 unsigned int expired : 1;
510 /* True if subkey is disabled. */
511 unsigned int disabled : 1;
513 /* True if subkey is invalid. */
514 unsigned int invalid : 1;
516 /* True if subkey can be used for encryption. */
517 unsigned int can_encrypt : 1;
519 /* True if subkey can be used for signing. */
520 unsigned int can_sign : 1;
522 /* True if subkey can be used for certification. */
523 unsigned int can_certify : 1;
525 /* True if subkey is secret. */
526 unsigned int secret : 1;
528 /* True if subkey can be used for authentication. */
529 unsigned int can_authenticate : 1;
531 /* True if subkey is qualified for signatures according to German law. */
532 unsigned int is_qualified : 1;
534 /* True if the secret key is stored on a smart card. */
535 unsigned int is_cardkey : 1;
537 /* Internal to GPGME, do not use. */
538 unsigned int _unused : 21;
540 /* Public key algorithm supported by this subkey. */
541 gpgme_pubkey_algo_t pubkey_algo;
543 /* Length of the subkey. */
546 /* The key ID of the subkey. */
549 /* Internal to GPGME, do not use. */
552 /* The fingerprint of the subkey in hex digit form. */
555 /* The creation timestamp, -1 if invalid, 0 if not available. */
558 /* The expiration timestamp, 0 if the subkey does not expire. */
561 /* The serial number of a smart card holding this key or NULL. */
564 typedef struct _gpgme_subkey *gpgme_subkey_t;
567 /* A signature on a user ID. */
568 struct _gpgme_key_sig
570 struct _gpgme_key_sig *next;
572 /* True if the signature is a revocation signature. */
573 unsigned int revoked : 1;
575 /* True if the signature is expired. */
576 unsigned int expired : 1;
578 /* True if the signature is invalid. */
579 unsigned int invalid : 1;
581 /* True if the signature should be exported. */
582 unsigned int exportable : 1;
584 /* Internal to GPGME, do not use. */
585 unsigned int _unused : 28;
587 /* The public key algorithm used to create the signature. */
588 gpgme_pubkey_algo_t pubkey_algo;
590 /* The key ID of key used to create the signature. */
593 /* Internal to GPGME, do not use. */
596 /* The creation timestamp, -1 if invalid, 0 if not available. */
599 /* The expiration timestamp, 0 if the subkey does not expire. */
602 /* Same as in gpgme_signature_t. */
603 gpgme_error_t status;
606 unsigned int _obsolete_class _GPGME_DEPRECATED;
608 /* Must be set to SIG_CLASS below. */
609 unsigned int class _GPGME_DEPRECATED;
612 /* The user ID string. */
615 /* The name part of the user ID. */
618 /* The email part of the user ID. */
621 /* The comment part of the user ID. */
624 /* Crypto backend specific signature class. */
625 unsigned int sig_class;
627 /* Notation data and policy URLs. */
628 gpgme_sig_notation_t notations;
630 /* Internal to GPGME, do not use. */
631 gpgme_sig_notation_t _last_notation;
633 typedef struct _gpgme_key_sig *gpgme_key_sig_t;
636 /* An user ID from a key. */
637 struct _gpgme_user_id
639 struct _gpgme_user_id *next;
641 /* True if the user ID is revoked. */
642 unsigned int revoked : 1;
644 /* True if the user ID is invalid. */
645 unsigned int invalid : 1;
647 /* Internal to GPGME, do not use. */
648 unsigned int _unused : 30;
650 /* The validity of the user ID. */
651 gpgme_validity_t validity;
653 /* The user ID string. */
656 /* The name part of the user ID. */
659 /* The email part of the user ID. */
662 /* The comment part of the user ID. */
665 /* The signatures of the user ID. */
666 gpgme_key_sig_t signatures;
668 /* Internal to GPGME, do not use. */
669 gpgme_key_sig_t _last_keysig;
671 typedef struct _gpgme_user_id *gpgme_user_id_t;
674 /* A key from the keyring. */
677 /* Internal to GPGME, do not use. */
680 /* True if key is revoked. */
681 unsigned int revoked : 1;
683 /* True if key is expired. */
684 unsigned int expired : 1;
686 /* True if key is disabled. */
687 unsigned int disabled : 1;
689 /* True if key is invalid. */
690 unsigned int invalid : 1;
692 /* True if key can be used for encryption. */
693 unsigned int can_encrypt : 1;
695 /* True if key can be used for signing. */
696 unsigned int can_sign : 1;
698 /* True if key can be used for certification. */
699 unsigned int can_certify : 1;
701 /* True if key is secret. */
702 unsigned int secret : 1;
704 /* True if key can be used for authentication. */
705 unsigned int can_authenticate : 1;
707 /* True if subkey is qualified for signatures according to German law. */
708 unsigned int is_qualified : 1;
710 /* Internal to GPGME, do not use. */
711 unsigned int _unused : 22;
713 /* This is the protocol supported by this key. */
714 gpgme_protocol_t protocol;
716 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
720 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
724 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
728 /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
730 gpgme_validity_t owner_trust;
732 /* The subkeys of the key. */
733 gpgme_subkey_t subkeys;
735 /* The user IDs of the key. */
736 gpgme_user_id_t uids;
738 /* Internal to GPGME, do not use. */
739 gpgme_subkey_t _last_subkey;
741 /* Internal to GPGME, do not use. */
742 gpgme_user_id_t _last_uid;
744 /* The keylist mode that was active when listing the key. */
745 gpgme_keylist_mode_t keylist_mode;
747 typedef struct _gpgme_key *gpgme_key_t;
751 /* Types for callback functions. */
753 /* Request a passphrase from the user. */
754 typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
755 const char *uid_hint,
756 const char *passphrase_info,
757 int prev_was_bad, int fd);
759 /* Inform the user about progress made. */
760 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
761 int type, int current, int total);
763 /* Interact with the user about an edit operation. */
764 typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
765 gpgme_status_code_t status,
766 const char *args, int fd);
771 /* Context management functions. */
773 /* Create a new context and return it in CTX. */
774 gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
776 /* Release the context CTX. */
777 void gpgme_release (gpgme_ctx_t ctx);
779 /* Set the protocol to be used by CTX to PROTO. */
780 gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
782 /* Get the protocol used with CTX */
783 gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
785 /* Get the string describing protocol PROTO, or NULL if invalid. */
786 const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
788 /* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
789 void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
791 /* Return non-zero if armor mode is set in CTX. */
792 int gpgme_get_armor (gpgme_ctx_t ctx);
794 /* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
795 void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
797 /* Return non-zero if text mode is set in CTX. */
798 int gpgme_get_textmode (gpgme_ctx_t ctx);
800 /* Use whatever the default of the backend crypto engine is. */
801 #define GPGME_INCLUDE_CERTS_DEFAULT -256
803 /* Include up to NR_OF_CERTS certificates in an S/MIME message. */
804 void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
806 /* Return the number of certs to include in an S/MIME message. */
807 int gpgme_get_include_certs (gpgme_ctx_t ctx);
809 /* Set keylist mode in CTX to MODE. */
810 gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
811 gpgme_keylist_mode_t mode);
813 /* Get keylist mode in CTX. */
814 gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
816 /* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
817 passed as first argument to the passphrase callback function. */
818 void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
819 gpgme_passphrase_cb_t cb, void *hook_value);
821 /* Get the current passphrase callback function in *CB and the current
822 hook value in *HOOK_VALUE. */
823 void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
826 /* Set the progress callback function in CTX to CB. HOOK_VALUE is
827 passed as first argument to the progress callback function. */
828 void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
831 /* Get the current progress callback function in *CB and the current
832 hook value in *HOOK_VALUE. */
833 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
836 /* This function sets the locale for the context CTX, or the default
837 locale if CTX is a null pointer. */
838 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
841 /* Get the information about the configured engines. A pointer to the
842 first engine in the statically allocated linked list is returned.
843 The returned data is valid until the next gpgme_ctx_set_engine_info. */
844 gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
846 /* Set the engine info for the context CTX, protocol PROTO, to the
847 file name FILE_NAME and the home directory HOME_DIR. */
848 gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
849 gpgme_protocol_t proto,
850 const char *file_name,
851 const char *home_dir);
854 /* Return a statically allocated string with the name of the public
855 key algorithm ALGO, or NULL if that name is not known. */
856 const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
858 /* Return a statically allocated string with the name of the hash
859 algorithm ALGO, or NULL if that name is not known. */
860 const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
863 /* Delete all signers from CTX. */
864 void gpgme_signers_clear (gpgme_ctx_t ctx);
866 /* Add KEY to list of signers in CTX. */
867 gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
869 /* Return the SEQth signer's key in CTX. */
870 gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
872 /* Retrieve the signature status of signature IDX in CTX after a
873 successful verify operation in R_STAT (if non-null). The creation
874 time stamp of the signature is returned in R_CREATED (if non-null).
875 The function returns a string containing the fingerprint.
876 Deprecated, use verify result directly. */
877 const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
878 _gpgme_sig_stat_t *r_stat,
879 time_t *r_created) _GPGME_DEPRECATED;
881 /* Retrieve certain attributes of a signature. IDX is the index
882 number of the signature after a successful verify operation. WHAT
883 is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
884 one. WHATIDX is to be passed as 0 for most attributes . */
885 unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
886 _gpgme_attr_t what, int whatidx)
888 const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
889 _gpgme_attr_t what, int whatidx)
893 /* Get the key used to create signature IDX in CTX and return it in
895 gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
899 /* Clear all notation data from the context. */
900 void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
902 /* Add the human-readable notation data with name NAME and value VALUE
903 to the context CTX, using the flags FLAGS. If NAME is NULL, then
904 VALUE should be a policy URL. The flag
905 GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
906 data, and false for policy URLs. */
907 gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
909 gpgme_sig_notation_flags_t flags);
911 /* Get the sig notations for this context. */
912 gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
917 /* The type of an I/O callback function. */
918 typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
920 /* The type of a function that can register FNC as the I/O callback
921 function for the file descriptor FD with direction dir (0: for writing,
922 1: for reading). FNC_DATA should be passed as DATA to FNC. The
923 function should return a TAG suitable for the corresponding
924 gpgme_remove_io_cb_t, and an error value. */
925 typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
927 void *fnc_data, void **tag);
929 /* The type of a function that can remove a previously registered I/O
930 callback function given TAG as returned by the register
932 typedef void (*gpgme_remove_io_cb_t) (void *tag);
938 GPGME_EVENT_NEXT_KEY,
939 GPGME_EVENT_NEXT_TRUSTITEM
943 /* The type of a function that is called when a context finished an
945 typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
950 gpgme_register_io_cb_t add;
952 gpgme_remove_io_cb_t remove;
953 gpgme_event_io_cb_t event;
956 typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
958 /* Set the I/O callback functions in CTX to IO_CBS. */
959 void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
961 /* Get the current I/O callback functions. */
962 void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
964 /* Process the pending operation and, if HANG is non-zero, wait for
965 the pending operation to finish. */
966 gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
969 /* Functions to handle data objects. */
971 /* Read up to SIZE bytes into buffer BUFFER from the data object with
972 the handle HANDLE. Return the number of characters read, 0 on EOF
973 and -1 on error. If an error occurs, errno is set. */
974 typedef ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer,
977 /* Write up to SIZE bytes from buffer BUFFER to the data object with
978 the handle HANDLE. Return the number of characters written, or -1
979 on error. If an error occurs, errno is set. */
980 typedef ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
983 /* Set the current position from where the next read or write starts
984 in the data object with the handle HANDLE to OFFSET, relativ to
986 typedef off_t (*gpgme_data_seek_cb_t) (void *handle, off_t offset, int whence);
988 /* Close the data object with the handle DL. */
989 typedef void (*gpgme_data_release_cb_t) (void *handle);
991 struct gpgme_data_cbs
993 gpgme_data_read_cb_t read;
994 gpgme_data_write_cb_t write;
995 gpgme_data_seek_cb_t seek;
996 gpgme_data_release_cb_t release;
998 typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
1000 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1001 the handle DH. Return the number of characters read, 0 on EOF and
1002 -1 on error. If an error occurs, errno is set. */
1003 ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
1005 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1006 the handle DH. Return the number of characters written, or -1 on
1007 error. If an error occurs, errno is set. */
1008 ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
1010 /* Set the current position from where the next read or write starts
1011 in the data object with the handle DH to OFFSET, relativ to
1013 off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence);
1015 /* Create a new data buffer and return it in R_DH. */
1016 gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
1018 /* Destroy the data buffer DH. */
1019 void gpgme_data_release (gpgme_data_t dh);
1021 /* Create a new data buffer filled with SIZE bytes starting from
1022 BUFFER. If COPY is zero, copying is delayed until necessary, and
1023 the data is taken from the original location when needed. */
1024 gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
1025 const char *buffer, size_t size,
1028 /* Destroy the data buffer DH and return a pointer to its content.
1029 The memory has be to released with gpgme_free() by the user. It's
1030 size is returned in R_LEN. */
1031 char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
1033 /* Release the memory returned by gpgme_data_release_and_get_mem(). */
1034 void gpgme_free (void *buffer);
1036 gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
1037 gpgme_data_cbs_t cbs,
1040 gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
1042 gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
1044 /* Return the encoding attribute of the data buffer DH */
1045 gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
1047 /* Set the encoding attribute of data buffer DH to ENC */
1048 gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
1049 gpgme_data_encoding_t enc);
1051 /* Get the file name associated with the data object with handle DH, or
1052 NULL if there is none. */
1053 char *gpgme_data_get_file_name (gpgme_data_t dh);
1055 /* Set the file name associated with the data object with handle DH to
1057 gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
1058 const char *file_name);
1061 /* Create a new data buffer which retrieves the data from the callback
1062 function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
1064 gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
1065 int (*read_cb) (void*,char *,
1067 void *read_cb_value)
1070 /* Create a new data buffer filled with the content of file FNAME.
1071 COPY must be non-zero. For delayed read, please use
1072 gpgme_data_new_from_fd or gpgme_data_new_from stream instead. */
1073 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
1077 /* Create a new data buffer filled with LENGTH bytes starting from
1078 OFFSET within the file FNAME or stream FP (exactly one must be
1080 gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
1081 const char *fname, FILE *fp,
1082 off_t offset, size_t length);
1084 /* Reset the read pointer in DH. Deprecated, please use
1085 gpgme_data_seek instead. */
1086 gpgme_error_t gpgme_data_rewind (gpgme_data_t dh) _GPGME_DEPRECATED;
1089 /* Key and trust functions. */
1091 /* Get the key with the fingerprint FPR from the crypto backend. If
1092 SECRET is true, get the secret key. */
1093 gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
1094 gpgme_key_t *r_key, int secret);
1096 /* Acquire a reference to KEY. */
1097 void gpgme_key_ref (gpgme_key_t key);
1099 /* Release a reference to KEY. If this was the last one the key is
1101 void gpgme_key_unref (gpgme_key_t key);
1102 void gpgme_key_release (gpgme_key_t key);
1104 /* Return the value of the attribute WHAT of KEY, which has to be
1105 representable by a string. IDX specifies the sub key or user ID
1106 for attributes related to sub keys or user IDs. Deprecated, use
1107 key structure directly instead. */
1108 const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
1109 const void *reserved, int idx)
1112 /* Return the value of the attribute WHAT of KEY, which has to be
1113 representable by an unsigned integer. IDX specifies the sub key or
1114 user ID for attributes related to sub keys or user IDs.
1115 Deprecated, use key structure directly instead. */
1116 unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
1117 const void *reserved, int idx)
1120 /* Return the value of the attribute WHAT of a signature on user ID
1121 UID_IDX in KEY, which has to be representable by a string. IDX
1122 specifies the signature. Deprecated, use key structure directly
1124 const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
1126 const void *reserved, int idx)
1129 /* Return the value of the attribute WHAT of a signature on user ID
1130 UID_IDX in KEY, which has to be representable by an unsigned
1131 integer string. IDX specifies the signature. Deprecated, use key
1132 structure directly instead. */
1133 unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
1135 const void *reserved, int idx)
1139 /* Crypto Operations. */
1141 /* Cancel a pending asynchronous operation. */
1142 gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
1144 /* Cancel a pending operation asynchronously. */
1145 gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx);
1148 struct _gpgme_invalid_key
1150 struct _gpgme_invalid_key *next;
1152 gpgme_error_t reason;
1154 typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
1158 struct _gpgme_op_encrypt_result
1160 /* The list of invalid recipients. */
1161 gpgme_invalid_key_t invalid_recipients;
1163 typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
1165 /* Retrieve a pointer to the result of the encrypt operation. */
1166 gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
1168 /* The valid encryption flags. */
1171 GPGME_ENCRYPT_ALWAYS_TRUST = 1
1173 gpgme_encrypt_flags_t;
1175 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1176 store the resulting ciphertext in CIPHER. */
1177 gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
1178 gpgme_encrypt_flags_t flags,
1179 gpgme_data_t plain, gpgme_data_t cipher);
1180 gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
1181 gpgme_encrypt_flags_t flags,
1182 gpgme_data_t plain, gpgme_data_t cipher);
1184 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1185 store the resulting ciphertext in CIPHER. Also sign the ciphertext
1186 with the signers in CTX. */
1187 gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
1189 gpgme_encrypt_flags_t flags,
1191 gpgme_data_t cipher);
1192 gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
1193 gpgme_encrypt_flags_t flags,
1194 gpgme_data_t plain, gpgme_data_t cipher);
1199 struct _gpgme_recipient
1201 struct _gpgme_recipient *next;
1203 /* The key ID of key for which the text was encrypted. */
1206 /* Internal to GPGME, do not use. */
1207 char _keyid[16 + 1];
1209 /* The public key algorithm of the recipient key. */
1210 gpgme_pubkey_algo_t pubkey_algo;
1212 /* The status of the recipient. */
1213 gpgme_error_t status;
1215 typedef struct _gpgme_recipient *gpgme_recipient_t;
1217 struct _gpgme_op_decrypt_result
1219 char *unsupported_algorithm;
1221 /* Key should not have been used for encryption. */
1222 unsigned int wrong_key_usage : 1;
1224 /* Internal to GPGME, do not use. */
1227 gpgme_recipient_t recipients;
1229 /* The original file name of the plaintext message, if
1233 typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
1235 /* Retrieve a pointer to the result of the decrypt operation. */
1236 gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
1238 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1239 plaintext in PLAIN. */
1240 gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
1241 gpgme_data_t plain);
1242 gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
1243 gpgme_data_t cipher, gpgme_data_t plain);
1245 /* Decrypt ciphertext CIPHER and make a signature verification within
1246 CTX and store the resulting plaintext in PLAIN. */
1247 gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
1248 gpgme_data_t cipher,
1249 gpgme_data_t plain);
1250 gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
1251 gpgme_data_t plain);
1255 struct _gpgme_new_signature
1257 struct _gpgme_new_signature *next;
1259 /* The type of the signature. */
1260 gpgme_sig_mode_t type;
1262 /* The public key algorithm used to create the signature. */
1263 gpgme_pubkey_algo_t pubkey_algo;
1265 /* The hash algorithm used to create the signature. */
1266 gpgme_hash_algo_t hash_algo;
1268 /* Internal to GPGME, do not use. Must be set to the same value as
1270 unsigned long _obsolete_class;
1272 /* Signature creation time. */
1275 /* The fingerprint of the signature. */
1279 unsigned int _obsolete_class_2;
1281 /* Must be set to SIG_CLASS below. */
1282 unsigned int class _GPGME_DEPRECATED;
1285 /* Crypto backend specific signature class. */
1286 unsigned int sig_class;
1288 typedef struct _gpgme_new_signature *gpgme_new_signature_t;
1290 struct _gpgme_op_sign_result
1292 /* The list of invalid signers. */
1293 gpgme_invalid_key_t invalid_signers;
1294 gpgme_new_signature_t signatures;
1296 typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
1298 /* Retrieve a pointer to the result of the signing operation. */
1299 gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1301 /* Sign the plaintext PLAIN and store the signature in SIG. */
1302 gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
1303 gpgme_data_t plain, gpgme_data_t sig,
1304 gpgme_sig_mode_t mode);
1305 gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
1306 gpgme_data_t plain, gpgme_data_t sig,
1307 gpgme_sig_mode_t mode);
1312 /* Flags used for the SUMMARY field in a gpgme_signature_t. */
1315 GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
1316 GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
1317 GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
1318 GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
1319 GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
1320 GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
1321 GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
1322 GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
1323 GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
1324 GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
1325 GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */
1329 struct _gpgme_signature
1331 struct _gpgme_signature *next;
1333 /* A summary of the signature status. */
1334 gpgme_sigsum_t summary;
1336 /* The fingerprint or key ID of the signature. */
1339 /* The status of the signature. */
1340 gpgme_error_t status;
1342 /* Notation data and policy URLs. */
1343 gpgme_sig_notation_t notations;
1345 /* Signature creation time. */
1346 unsigned long timestamp;
1348 /* Signature exipration time or 0. */
1349 unsigned long exp_timestamp;
1351 /* Key should not have been used for signing. */
1352 unsigned int wrong_key_usage : 1;
1354 /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1355 unsigned int pka_trust : 2;
1357 /* Validity has been verified using the chain model. */
1358 unsigned int chain_model : 1;
1360 /* Internal to GPGME, do not use. */
1363 gpgme_validity_t validity;
1364 gpgme_error_t validity_reason;
1366 /* The public key algorithm used to create the signature. */
1367 gpgme_pubkey_algo_t pubkey_algo;
1369 /* The hash algorithm used to create the signature. */
1370 gpgme_hash_algo_t hash_algo;
1372 /* The mailbox from the PKA information or NULL. */
1375 typedef struct _gpgme_signature *gpgme_signature_t;
1377 struct _gpgme_op_verify_result
1379 gpgme_signature_t signatures;
1381 /* The original file name of the plaintext message, if
1385 typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
1387 /* Retrieve a pointer to the result of the verify operation. */
1388 gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
1390 /* Verify within CTX that SIG is a valid signature for TEXT. */
1391 gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
1392 gpgme_data_t signed_text,
1393 gpgme_data_t plaintext);
1394 gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
1395 gpgme_data_t signed_text,
1396 gpgme_data_t plaintext);
1401 /* The key was new. */
1402 #define GPGME_IMPORT_NEW 1
1404 /* The key contained new user IDs. */
1405 #define GPGME_IMPORT_UID 2
1407 /* The key contained new signatures. */
1408 #define GPGME_IMPORT_SIG 4
1410 /* The key contained new sub keys. */
1411 #define GPGME_IMPORT_SUBKEY 8
1413 /* The key contained a secret key. */
1414 #define GPGME_IMPORT_SECRET 16
1417 struct _gpgme_import_status
1419 struct _gpgme_import_status *next;
1424 /* If a problem occured, the reason why the key could not be
1425 imported. Otherwise GPGME_No_Error. */
1426 gpgme_error_t result;
1428 /* The result of the import, the GPGME_IMPORT_* values bit-wise
1429 ORed. 0 means the key was already known and no new components
1431 unsigned int status;
1433 typedef struct _gpgme_import_status *gpgme_import_status_t;
1436 struct _gpgme_op_import_result
1438 /* Number of considered keys. */
1441 /* Keys without user ID. */
1444 /* Imported keys. */
1447 /* Imported RSA keys. */
1450 /* Unchanged keys. */
1453 /* Number of new user ids. */
1456 /* Number of new sub keys. */
1459 /* Number of new signatures. */
1462 /* Number of new revocations. */
1463 int new_revocations;
1465 /* Number of secret keys read. */
1468 /* Number of secret keys imported. */
1469 int secret_imported;
1471 /* Number of secret keys unchanged. */
1472 int secret_unchanged;
1474 /* Number of new keys skipped. */
1475 int skipped_new_keys;
1477 /* Number of keys not imported. */
1480 /* List of keys for which an import was attempted. */
1481 gpgme_import_status_t imports;
1483 typedef struct _gpgme_op_import_result *gpgme_import_result_t;
1485 /* Retrieve a pointer to the result of the import operation. */
1486 gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
1488 /* Import the key in KEYDATA into the keyring. */
1489 gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
1490 gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
1491 gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
1492 int *nr) _GPGME_DEPRECATED;
1495 /* Export the keys found by PATTERN into KEYDATA. */
1496 gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
1497 unsigned int reserved,
1498 gpgme_data_t keydata);
1499 gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
1500 unsigned int reserved, gpgme_data_t keydata);
1502 gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
1503 const char *pattern[],
1504 unsigned int reserved,
1505 gpgme_data_t keydata);
1506 gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
1507 unsigned int reserved,
1508 gpgme_data_t keydata);
1511 /* Key generation. */
1512 struct _gpgme_op_genkey_result
1514 /* A primary key was generated. */
1515 unsigned int primary : 1;
1517 /* A sub key was generated. */
1518 unsigned int sub : 1;
1520 /* Internal to GPGME, do not use. */
1521 unsigned int _unused : 30;
1523 /* The fingerprint of the generated key. */
1526 typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
1528 /* Generate a new keypair and add it to the keyring. PUBKEY and
1529 SECKEY should be null for now. PARMS specifies what keys should be
1531 gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
1532 gpgme_data_t pubkey, gpgme_data_t seckey);
1533 gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
1534 gpgme_data_t pubkey, gpgme_data_t seckey);
1536 /* Retrieve a pointer to the result of the genkey operation. */
1537 gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
1540 /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
1541 keys are also deleted. */
1542 gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
1544 gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
1548 /* Edit the key KEY. Send status and command requests to FNC and
1549 output of edit commands to OUT. */
1550 gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1551 gpgme_edit_cb_t fnc, void *fnc_value,
1553 gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1554 gpgme_edit_cb_t fnc, void *fnc_value,
1557 /* Edit the card for the key KEY. Send status and command requests to
1558 FNC and output of edit commands to OUT. */
1559 gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1560 gpgme_edit_cb_t fnc, void *fnc_value,
1562 gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1563 gpgme_edit_cb_t fnc, void *fnc_value,
1567 /* Key management functions. */
1568 struct _gpgme_op_keylist_result
1570 unsigned int truncated : 1;
1572 /* Internal to GPGME, do not use. */
1573 unsigned int _unused : 31;
1575 typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
1577 /* Retrieve a pointer to the result of the key listing operation. */
1578 gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
1580 /* Start a keylist operation within CTX, searching for keys which
1581 match PATTERN. If SECRET_ONLY is true, only secret keys are
1583 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
1585 gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
1586 const char *pattern[],
1587 int secret_only, int reserved);
1589 /* Return the next key from the keylist in R_KEY. */
1590 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
1592 /* Terminate a pending keylist operation within CTX. */
1593 gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
1596 /* Trust items and operations. */
1598 struct _gpgme_trust_item
1600 /* Internal to GPGME, do not use. */
1603 /* The key ID to which the trust item belongs. */
1606 /* Internal to GPGME, do not use. */
1607 char _keyid[16 + 1];
1609 /* The type of the trust item, 1 refers to a key, 2 to a user ID. */
1612 /* The trust level. */
1615 /* The owner trust if TYPE is 1. */
1618 /* Internal to GPGME, do not use. */
1619 char _owner_trust[2];
1621 /* The calculated validity. */
1624 /* Internal to GPGME, do not use. */
1627 /* The user name if TYPE is 2. */
1630 typedef struct _gpgme_trust_item *gpgme_trust_item_t;
1632 /* Start a trustlist operation within CTX, searching for trust items
1633 which match PATTERN. */
1634 gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
1635 const char *pattern, int max_level);
1637 /* Return the next trust item from the trustlist in R_ITEM. */
1638 gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
1639 gpgme_trust_item_t *r_item);
1641 /* Terminate a pending trustlist operation within CTX. */
1642 gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
1644 /* Acquire a reference to ITEM. */
1645 void gpgme_trust_item_ref (gpgme_trust_item_t item);
1647 /* Release a reference to ITEM. If this was the last one the trust
1648 item is destroyed. */
1649 void gpgme_trust_item_unref (gpgme_trust_item_t item);
1651 /* Release the trust item ITEM. Deprecated, use
1652 gpgme_trust_item_unref. */
1653 void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED;
1655 /* Return the value of the attribute WHAT of ITEM, which has to be
1656 representable by a string. Deprecated, use trust item structure
1658 const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item,
1660 const void *reserved, int idx)
1663 /* Return the value of the attribute WHAT of KEY, which has to be
1664 representable by an integer. IDX specifies a running index if the
1665 attribute appears more than once in the key. Deprecated, use trust
1666 item structure directly. */
1667 int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what,
1668 const void *reserved, int idx)
1672 /* Return the auditlog for the current session. This may be called
1673 after a successful or failed operation. If no audit log is
1674 available GPG_ERR_NO_DATA is returned. */
1675 gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
1676 unsigned int flags);
1677 gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
1678 unsigned int flags);
1682 /* Low-level Assuan protocol access. */
1683 typedef gpgme_error_t (*gpgme_assuan_data_cb_t)
1684 (void *opaque, const void *data, size_t datalen);
1686 typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t)
1687 (void *opaque, const char *name, const char *args,
1688 gpgme_data_t *r_data);
1690 typedef gpgme_error_t (*gpgme_assuan_status_cb_t)
1691 (void *opaque, const char *status, const char *args);
1693 struct _gpgme_op_assuan_result
1695 /* The result of the actual assuan command. An OK is indicated by a
1696 value of 0 and an ERR by the respective error error value. */
1699 typedef struct _gpgme_op_assuan_result *gpgme_assuan_result_t;
1702 /* Return the result of the last Assuan command. */
1703 gpgme_assuan_result_t gpgme_op_assuan_result (gpgme_ctx_t ctx);
1705 /* Send the Assuan COMMAND and return results via the callbacks.
1706 Asynchronous variant. */
1707 gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx,
1708 const char *command,
1709 gpgme_assuan_data_cb_t data_cb,
1710 void *data_cb_value,
1711 gpgme_assuan_inquire_cb_t inq_cb,
1713 gpgme_assuan_status_cb_t stat_cb,
1714 void *stat_cb_value);
1716 /* Send the Assuan COMMAND and return results via the callbacks.
1717 Synchronous variant. */
1718 gpgme_error_t gpgme_op_assuan_transact (gpgme_ctx_t ctx,
1719 const char *command,
1720 gpgme_assuan_data_cb_t data_cb,
1721 void *data_cb_value,
1722 gpgme_assuan_inquire_cb_t inq_cb,
1724 gpgme_assuan_status_cb_t stat_cb,
1725 void *stat_cb_value);
1729 /* Interface to gpgconf(1). */
1731 /* The expert level at which a configuration option or group of
1732 options should be displayed. See the gpgconf(1) documentation for
1736 GPGME_CONF_BASIC = 0,
1737 GPGME_CONF_ADVANCED = 1,
1738 GPGME_CONF_EXPERT = 2,
1739 GPGME_CONF_INVISIBLE = 3,
1740 GPGME_CONF_INTERNAL = 4
1745 /* The data type of a configuration option argument. See the gpgconf(1)
1746 documentation for more details. */
1750 GPGME_CONF_NONE = 0,
1751 GPGME_CONF_STRING = 1,
1752 GPGME_CONF_INT32 = 2,
1753 GPGME_CONF_UINT32 = 3,
1755 /* Complex types. */
1756 GPGME_CONF_FILENAME = 32,
1757 GPGME_CONF_LDAP_SERVER = 33,
1758 GPGME_CONF_KEY_FPR = 34,
1759 GPGME_CONF_PUB_KEY = 35,
1760 GPGME_CONF_SEC_KEY = 36,
1761 GPGME_CONF_ALIAS_LIST = 37
1764 /* Macro for backward compatibility (even though it was undocumented
1765 and marked as experimental in 1.1.6 - will be removed after 1.1.7): */
1766 #define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
1769 /* This represents a single argument for a configuration option.
1770 Which of the members of value is used depends on the ALT_TYPE. */
1771 typedef struct gpgme_conf_arg
1773 struct gpgme_conf_arg *next;
1774 /* True if the option appears without an (optional) argument. */
1775 unsigned int no_arg;
1779 unsigned int uint32;
1783 } *gpgme_conf_arg_t;
1786 /* The flags of a configuration option. See the gpg-conf
1787 documentation for details. */
1788 #define GPGME_CONF_GROUP (1 << 0)
1789 #define GPGME_CONF_OPTIONAL (1 << 1)
1790 #define GPGME_CONF_LIST (1 << 2)
1791 #define GPGME_CONF_RUNTIME (1 << 3)
1792 #define GPGME_CONF_DEFAULT (1 << 4)
1793 #define GPGME_CONF_DEFAULT_DESC (1 << 5)
1794 #define GPGME_CONF_NO_ARG_DESC (1 << 6)
1795 #define GPGME_CONF_NO_CHANGE (1 << 7)
1798 /* The representation of a single configuration option. See the
1799 gpg-conf documentation for details. */
1800 typedef struct gpgme_conf_opt
1802 struct gpgme_conf_opt *next;
1804 /* The option name. */
1807 /* The flags for this option. */
1810 /* The level of this option. */
1811 gpgme_conf_level_t level;
1813 /* The localized description of this option. */
1816 /* The type and alternate type of this option. */
1817 gpgme_conf_type_t type;
1818 gpgme_conf_type_t alt_type;
1820 /* The localized (short) name of the argument, if any. */
1823 /* The default value. */
1824 gpgme_conf_arg_t default_value;
1825 char *default_description;
1827 /* The default value if the option is not set. */
1828 gpgme_conf_arg_t no_arg_value;
1829 char *no_arg_description;
1831 /* The current value if the option is set. */
1832 gpgme_conf_arg_t value;
1834 /* The new value, if any. NULL means reset to default. */
1836 gpgme_conf_arg_t new_value;
1838 /* Free for application use. */
1840 } *gpgme_conf_opt_t;
1843 /* The representation of a component that can be configured. See the
1844 gpg-conf documentation for details. */
1845 typedef struct gpgme_conf_comp
1847 struct gpgme_conf_comp *next;
1849 /* Internal to GPGME, do not use! */
1850 gpgme_conf_opt_t *_last_opt_p;
1852 /* The component name. */
1855 /* A human-readable description for the component. */
1858 /* The program name (an absolute path to the program). */
1861 /* A linked list of options for this component. */
1862 struct gpgme_conf_opt *options;
1863 } *gpgme_conf_comp_t;
1866 /* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg
1867 default" is prepared. If type is a string type, VALUE should point
1868 to the string. Else, it should point to an unsigned or signed
1869 integer respectively. */
1870 gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
1871 gpgme_conf_type_t type, void *value);
1873 /* This also releases all chained argument structures! */
1874 void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
1876 /* Register a change for the value of OPT to ARG. If RESET is 1 (do
1877 not use any values but 0 or 1), ARG is ignored and the option is
1878 not changed (reverting a previous change). Otherwise, if ARG is
1879 NULL, the option is cleared or reset to its default. */
1880 gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
1881 gpgme_conf_arg_t arg);
1883 /* Release a set of configurations. */
1884 void gpgme_conf_release (gpgme_conf_comp_t conf);
1886 /* Retrieve the current configurations. */
1887 gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
1889 /* Save the configuration of component comp. This function does not
1890 follow chained components! */
1891 gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
1894 /* Various functions. */
1896 /* Check that the library fulfills the version requirement. */
1897 const char *gpgme_check_version (const char *req_version);
1899 /* Get the information about the configured and installed engines. A
1900 pointer to the first engine in the statically allocated linked list
1901 is returned in *INFO. If an error occurs, it is returned. The
1902 returned data is valid until the next gpgme_set_engine_info. */
1903 gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
1905 /* Set the default engine info for the protocol PROTO to the file name
1906 FILE_NAME and the home directory HOME_DIR. */
1907 gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
1908 const char *file_name,
1909 const char *home_dir);
1912 /* Engine support functions. */
1914 /* Verify that the engine implementing PROTO is installed and
1916 gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
1919 /* Deprecated types. */
1920 typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED;
1921 typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED;
1922 typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED;
1923 typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED;
1924 typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED;
1925 typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED;
1926 typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED;
1927 typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED;
1928 typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED;
1929 typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED;
1930 typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED;
1931 typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED;
1932 typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED;
1933 typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED;
1934 typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED;
1935 typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED;
1936 typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED;
1937 typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED;
1938 typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED;
1939 typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED;
1940 typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED;
1941 typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED;
1942 typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED;
1943 #define GpgmeIOCbs gpgme_io_cbs
1944 typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED;
1945 typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED;
1946 typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED;
1947 typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED;
1948 #define GpgmeDataCbs gpgme_data_cbs
1949 typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED;
1950 typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED;
1951 typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED;
1952 typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED;
1953 typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED;
1954 typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED;
1955 typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED;
1956 typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED;
1957 typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED;
1962 #endif /* GPGME_H */