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
69 /* The macro _GPGME_DEPRECATED_OUTSIDE_GPGME suppresses warnings for
70 fields we must access in GPGME for ABI compatibility. */
71 #ifdef _GPGME_IN_GPGME
72 #define _GPGME_DEPRECATED_OUTSIDE_GPGME
74 #define _GPGME_DEPRECATED_OUTSIDE_GPGME _GPGME_DEPRECATED
78 /* The version of this header should match the one of the library. Do
79 not use this symbol in your application, use gpgme_check_version
80 instead. The purpose of this macro is to let autoconf (using the
81 AM_PATH_GPGME macro) check that this header matches the installed
83 #define GPGME_VERSION "@PACKAGE_VERSION@"
85 /* Check for a matching _FILE_OFFSET_BITS definition. */
86 #if @NEED__FILE_OFFSET_BITS@
87 #ifndef _FILE_OFFSET_BITS
88 #error GPGME was compiled with _FILE_OFFSET_BITS = @NEED__FILE_OFFSET_BITS@, please see the section "Largefile support (LFS)" in the GPGME manual.
90 #if (_FILE_OFFSET_BITS) != (@NEED__FILE_OFFSET_BITS@)
91 #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.
98 /* Some opaque data types used by GPGME. */
100 /* The context holds some global state and configration options, as
101 well as the results of a crypto operation. */
102 struct gpgme_context;
103 typedef struct gpgme_context *gpgme_ctx_t;
105 /* The data object is used by GPGME to exchange arbitrary data. */
107 typedef struct gpgme_data *gpgme_data_t;
110 /* Wrappers for the libgpg-error library. */
112 typedef gpg_error_t gpgme_error_t;
113 typedef gpg_err_code_t gpgme_err_code_t;
114 typedef gpg_err_source_t gpgme_err_source_t;
117 static _GPGME_INLINE gpgme_error_t
118 gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code)
120 return gpg_err_make (source, code);
124 /* The user can define GPGME_ERR_SOURCE_DEFAULT before including this
125 file to specify a default source for gpgme_error. */
126 #ifndef GPGME_ERR_SOURCE_DEFAULT
127 #define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
130 static _GPGME_INLINE gpgme_error_t
131 gpgme_error (gpgme_err_code_t code)
133 return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code);
137 static _GPGME_INLINE gpgme_err_code_t
138 gpgme_err_code (gpgme_error_t err)
140 return gpg_err_code (err);
144 static _GPGME_INLINE gpgme_err_source_t
145 gpgme_err_source (gpgme_error_t err)
147 return gpg_err_source (err);
151 /* Return a pointer to a string containing a description of the error
152 code in the error value ERR. This function is not thread safe. */
153 const char *gpgme_strerror (gpgme_error_t err);
155 /* Return the error string for ERR in the user-supplied buffer BUF of
156 size BUFLEN. This function is, in contrast to gpg_strerror,
157 thread-safe if a thread-safe strerror_r() function is provided by
158 the system. If the function succeeds, 0 is returned and BUF
159 contains the string describing the error. If the buffer was not
160 large enough, ERANGE is returned and BUF contains as much of the
161 beginning of the error string as fits into the buffer. */
162 int gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen);
165 /* Return a pointer to a string containing a description of the error
166 source in the error value ERR. */
167 const char *gpgme_strsource (gpgme_error_t err);
170 /* Retrieve the error code for the system error ERR. This returns
171 GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
173 gpgme_err_code_t gpgme_err_code_from_errno (int err);
176 /* Retrieve the system error for the error code CODE. This returns 0
177 if CODE is not a system error code. */
178 int gpgme_err_code_to_errno (gpgme_err_code_t code);
181 /* Return an error value with the error source SOURCE and the system
183 gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err);
186 /* Return an error value with the system error ERR. */
187 gpgme_err_code_t gpgme_error_from_errno (int err);
190 /* The possible encoding mode of gpgme_data_t objects. */
193 GPGME_DATA_ENCODING_NONE = 0, /* Not specified. */
194 GPGME_DATA_ENCODING_BINARY = 1,
195 GPGME_DATA_ENCODING_BASE64 = 2,
196 GPGME_DATA_ENCODING_ARMOR = 3, /* Either PEM or OpenPGP Armor. */
197 GPGME_DATA_ENCODING_URL = 4, /* LF delimited URL list. */
198 GPGME_DATA_ENCODING_URLESC = 5, /* Ditto, but percent escaped. */
199 GPGME_DATA_ENCODING_URL0 = 6 /* Nul delimited URL list. */
201 gpgme_data_encoding_t;
204 /* Public key algorithms from libgcrypt. */
217 /* Hash algorithms from libgcrypt. */
225 GPGME_MD_TIGER = 6, /* TIGER/192. */
226 GPGME_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */
229 GPGME_MD_SHA512 = 10,
231 GPGME_MD_CRC32 = 302,
232 GPGME_MD_CRC32_RFC1510 = 303,
233 GPGME_MD_CRC24_RFC2440 = 304
238 /* The possible signature stati. Deprecated, use error value in sig
242 GPGME_SIG_STAT_NONE = 0,
243 GPGME_SIG_STAT_GOOD = 1,
244 GPGME_SIG_STAT_BAD = 2,
245 GPGME_SIG_STAT_NOKEY = 3,
246 GPGME_SIG_STAT_NOSIG = 4,
247 GPGME_SIG_STAT_ERROR = 5,
248 GPGME_SIG_STAT_DIFF = 6,
249 GPGME_SIG_STAT_GOOD_EXP = 7,
250 GPGME_SIG_STAT_GOOD_EXPKEY = 8
253 typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED;
256 /* The available signature modes. */
259 GPGME_SIG_MODE_NORMAL = 0,
260 GPGME_SIG_MODE_DETACH = 1,
261 GPGME_SIG_MODE_CLEAR = 2
266 /* The available key and signature attributes. Deprecated, use the
267 individual result structures instead. */
270 GPGME_ATTR_KEYID = 1,
274 GPGME_ATTR_CREATED = 5,
275 GPGME_ATTR_EXPIRE = 6,
276 GPGME_ATTR_OTRUST = 7,
277 GPGME_ATTR_USERID = 8,
279 GPGME_ATTR_EMAIL = 10,
280 GPGME_ATTR_COMMENT = 11,
281 GPGME_ATTR_VALIDITY = 12,
282 GPGME_ATTR_LEVEL = 13,
283 GPGME_ATTR_TYPE = 14,
284 GPGME_ATTR_IS_SECRET = 15,
285 GPGME_ATTR_KEY_REVOKED = 16,
286 GPGME_ATTR_KEY_INVALID = 17,
287 GPGME_ATTR_UID_REVOKED = 18,
288 GPGME_ATTR_UID_INVALID = 19,
289 GPGME_ATTR_KEY_CAPS = 20,
290 GPGME_ATTR_CAN_ENCRYPT = 21,
291 GPGME_ATTR_CAN_SIGN = 22,
292 GPGME_ATTR_CAN_CERTIFY = 23,
293 GPGME_ATTR_KEY_EXPIRED = 24,
294 GPGME_ATTR_KEY_DISABLED = 25,
295 GPGME_ATTR_SERIAL = 26,
296 GPGME_ATTR_ISSUER = 27,
297 GPGME_ATTR_CHAINID = 28,
298 GPGME_ATTR_SIG_STATUS = 29,
299 GPGME_ATTR_ERRTOK = 30,
300 GPGME_ATTR_SIG_SUMMARY = 31,
301 GPGME_ATTR_SIG_CLASS = 32
304 typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED;
307 /* The available validities for a trust item or key. */
310 GPGME_VALIDITY_UNKNOWN = 0,
311 GPGME_VALIDITY_UNDEFINED = 1,
312 GPGME_VALIDITY_NEVER = 2,
313 GPGME_VALIDITY_MARGINAL = 3,
314 GPGME_VALIDITY_FULL = 4,
315 GPGME_VALIDITY_ULTIMATE = 5
320 /* The available protocols. */
323 GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
324 GPGME_PROTOCOL_CMS = 1,
325 GPGME_PROTOCOL_GPGCONF = 2, /* Special code for gpgconf. */
326 GPGME_PROTOCOL_ASSUAN = 3, /* Low-level access to an Assuan server. */
327 GPGME_PROTOCOL_G13 = 4,
328 GPGME_PROTOCOL_UNKNOWN = 255
333 /* The available keylist mode flags. */
334 #define GPGME_KEYLIST_MODE_LOCAL 1
335 #define GPGME_KEYLIST_MODE_EXTERN 2
336 #define GPGME_KEYLIST_MODE_SIGS 4
337 #define GPGME_KEYLIST_MODE_SIG_NOTATIONS 8
338 #define GPGME_KEYLIST_MODE_EPHEMERAL 128
339 #define GPGME_KEYLIST_MODE_VALIDATE 256
341 typedef unsigned int gpgme_keylist_mode_t;
344 /* The available export mode flags. */
345 #define GPGME_EXPORT_MODE_EXTERN 2
347 typedef unsigned int gpgme_export_mode_t;
350 /* Flags for the audit log functions. */
351 #define GPGME_AUDITLOG_HTML 1
352 #define GPGME_AUDITLOG_WITH_HELP 128
355 /* Signature notations. */
357 /* The available signature notation flags. */
358 #define GPGME_SIG_NOTATION_HUMAN_READABLE 1
359 #define GPGME_SIG_NOTATION_CRITICAL 2
361 typedef unsigned int gpgme_sig_notation_flags_t;
363 struct _gpgme_sig_notation
365 struct _gpgme_sig_notation *next;
367 /* If NAME is a null pointer, then VALUE contains a policy URL
368 rather than a notation. */
371 /* The value of the notation data. */
374 /* The length of the name of the notation data. */
377 /* The length of the value of the notation data. */
380 /* The accumulated flags. */
381 gpgme_sig_notation_flags_t flags;
383 /* Notation data is human-readable. */
384 unsigned int human_readable : 1;
386 /* Notation data is critical. */
387 unsigned int critical : 1;
389 /* Internal to GPGME, do not use. */
392 typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
395 /* The possible stati for the edit operation. */
398 GPGME_STATUS_EOF = 0,
399 /* mkstatus processing starts here */
400 GPGME_STATUS_ENTER = 1,
401 GPGME_STATUS_LEAVE = 2,
402 GPGME_STATUS_ABORT = 3,
404 GPGME_STATUS_GOODSIG = 4,
405 GPGME_STATUS_BADSIG = 5,
406 GPGME_STATUS_ERRSIG = 6,
408 GPGME_STATUS_BADARMOR = 7,
410 GPGME_STATUS_RSA_OR_IDEA = 8,
411 GPGME_STATUS_KEYEXPIRED = 9,
412 GPGME_STATUS_KEYREVOKED = 10,
414 GPGME_STATUS_TRUST_UNDEFINED = 11,
415 GPGME_STATUS_TRUST_NEVER = 12,
416 GPGME_STATUS_TRUST_MARGINAL = 13,
417 GPGME_STATUS_TRUST_FULLY = 14,
418 GPGME_STATUS_TRUST_ULTIMATE = 15,
420 GPGME_STATUS_SHM_INFO = 16,
421 GPGME_STATUS_SHM_GET = 17,
422 GPGME_STATUS_SHM_GET_BOOL = 18,
423 GPGME_STATUS_SHM_GET_HIDDEN = 19,
425 GPGME_STATUS_NEED_PASSPHRASE = 20,
426 GPGME_STATUS_VALIDSIG = 21,
427 GPGME_STATUS_SIG_ID = 22,
428 GPGME_STATUS_ENC_TO = 23,
429 GPGME_STATUS_NODATA = 24,
430 GPGME_STATUS_BAD_PASSPHRASE = 25,
431 GPGME_STATUS_NO_PUBKEY = 26,
432 GPGME_STATUS_NO_SECKEY = 27,
433 GPGME_STATUS_NEED_PASSPHRASE_SYM = 28,
434 GPGME_STATUS_DECRYPTION_FAILED = 29,
435 GPGME_STATUS_DECRYPTION_OKAY = 30,
436 GPGME_STATUS_MISSING_PASSPHRASE = 31,
437 GPGME_STATUS_GOOD_PASSPHRASE = 32,
438 GPGME_STATUS_GOODMDC = 33,
439 GPGME_STATUS_BADMDC = 34,
440 GPGME_STATUS_ERRMDC = 35,
441 GPGME_STATUS_IMPORTED = 36,
442 GPGME_STATUS_IMPORT_OK = 37,
443 GPGME_STATUS_IMPORT_PROBLEM = 38,
444 GPGME_STATUS_IMPORT_RES = 39,
445 GPGME_STATUS_FILE_START = 40,
446 GPGME_STATUS_FILE_DONE = 41,
447 GPGME_STATUS_FILE_ERROR = 42,
449 GPGME_STATUS_BEGIN_DECRYPTION = 43,
450 GPGME_STATUS_END_DECRYPTION = 44,
451 GPGME_STATUS_BEGIN_ENCRYPTION = 45,
452 GPGME_STATUS_END_ENCRYPTION = 46,
454 GPGME_STATUS_DELETE_PROBLEM = 47,
455 GPGME_STATUS_GET_BOOL = 48,
456 GPGME_STATUS_GET_LINE = 49,
457 GPGME_STATUS_GET_HIDDEN = 50,
458 GPGME_STATUS_GOT_IT = 51,
459 GPGME_STATUS_PROGRESS = 52,
460 GPGME_STATUS_SIG_CREATED = 53,
461 GPGME_STATUS_SESSION_KEY = 54,
462 GPGME_STATUS_NOTATION_NAME = 55,
463 GPGME_STATUS_NOTATION_DATA = 56,
464 GPGME_STATUS_POLICY_URL = 57,
465 GPGME_STATUS_BEGIN_STREAM = 58,
466 GPGME_STATUS_END_STREAM = 59,
467 GPGME_STATUS_KEY_CREATED = 60,
468 GPGME_STATUS_USERID_HINT = 61,
469 GPGME_STATUS_UNEXPECTED = 62,
470 GPGME_STATUS_INV_RECP = 63,
471 GPGME_STATUS_NO_RECP = 64,
472 GPGME_STATUS_ALREADY_SIGNED = 65,
473 GPGME_STATUS_SIGEXPIRED = 66,
474 GPGME_STATUS_EXPSIG = 67,
475 GPGME_STATUS_EXPKEYSIG = 68,
476 GPGME_STATUS_TRUNCATED = 69,
477 GPGME_STATUS_ERROR = 70,
478 GPGME_STATUS_NEWSIG = 71,
479 GPGME_STATUS_REVKEYSIG = 72,
480 GPGME_STATUS_SIG_SUBPACKET = 73,
481 GPGME_STATUS_NEED_PASSPHRASE_PIN = 74,
482 GPGME_STATUS_SC_OP_FAILURE = 75,
483 GPGME_STATUS_SC_OP_SUCCESS = 76,
484 GPGME_STATUS_CARDCTRL = 77,
485 GPGME_STATUS_BACKUP_KEY_CREATED = 78,
486 GPGME_STATUS_PKA_TRUST_BAD = 79,
487 GPGME_STATUS_PKA_TRUST_GOOD = 80,
489 GPGME_STATUS_PLAINTEXT = 81,
490 GPGME_STATUS_INV_SGNR = 82,
491 GPGME_STATUS_NO_SGNR = 83
496 /* The engine information structure. */
497 struct _gpgme_engine_info
499 struct _gpgme_engine_info *next;
501 /* The protocol ID. */
502 gpgme_protocol_t protocol;
504 /* The file name of the engine binary. */
507 /* The version string of the installed engine. */
510 /* The minimum version required for GPGME. */
511 const char *req_version;
513 /* The home directory used, or NULL if default. */
516 typedef struct _gpgme_engine_info *gpgme_engine_info_t;
519 /* A subkey from a key. */
522 struct _gpgme_subkey *next;
524 /* True if subkey is revoked. */
525 unsigned int revoked : 1;
527 /* True if subkey is expired. */
528 unsigned int expired : 1;
530 /* True if subkey is disabled. */
531 unsigned int disabled : 1;
533 /* True if subkey is invalid. */
534 unsigned int invalid : 1;
536 /* True if subkey can be used for encryption. */
537 unsigned int can_encrypt : 1;
539 /* True if subkey can be used for signing. */
540 unsigned int can_sign : 1;
542 /* True if subkey can be used for certification. */
543 unsigned int can_certify : 1;
545 /* True if subkey is secret. */
546 unsigned int secret : 1;
548 /* True if subkey can be used for authentication. */
549 unsigned int can_authenticate : 1;
551 /* True if subkey is qualified for signatures according to German law. */
552 unsigned int is_qualified : 1;
554 /* True if the secret key is stored on a smart card. */
555 unsigned int is_cardkey : 1;
557 /* Internal to GPGME, do not use. */
558 unsigned int _unused : 21;
560 /* Public key algorithm supported by this subkey. */
561 gpgme_pubkey_algo_t pubkey_algo;
563 /* Length of the subkey. */
566 /* The key ID of the subkey. */
569 /* Internal to GPGME, do not use. */
572 /* The fingerprint of the subkey in hex digit form. */
575 /* The creation timestamp, -1 if invalid, 0 if not available. */
578 /* The expiration timestamp, 0 if the subkey does not expire. */
581 /* The serial number of a smart card holding this key or NULL. */
584 typedef struct _gpgme_subkey *gpgme_subkey_t;
587 /* A signature on a user ID. */
588 struct _gpgme_key_sig
590 struct _gpgme_key_sig *next;
592 /* True if the signature is a revocation signature. */
593 unsigned int revoked : 1;
595 /* True if the signature is expired. */
596 unsigned int expired : 1;
598 /* True if the signature is invalid. */
599 unsigned int invalid : 1;
601 /* True if the signature should be exported. */
602 unsigned int exportable : 1;
604 /* Internal to GPGME, do not use. */
605 unsigned int _unused : 28;
607 /* The public key algorithm used to create the signature. */
608 gpgme_pubkey_algo_t pubkey_algo;
610 /* The key ID of key used to create the signature. */
613 /* Internal to GPGME, do not use. */
616 /* The creation timestamp, -1 if invalid, 0 if not available. */
619 /* The expiration timestamp, 0 if the subkey does not expire. */
622 /* Same as in gpgme_signature_t. */
623 gpgme_error_t status;
626 unsigned int _obsolete_class _GPGME_DEPRECATED;
628 /* Must be set to SIG_CLASS below. */
629 unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME;
632 /* The user ID string. */
635 /* The name part of the user ID. */
638 /* The email part of the user ID. */
641 /* The comment part of the user ID. */
644 /* Crypto backend specific signature class. */
645 unsigned int sig_class;
647 /* Notation data and policy URLs. */
648 gpgme_sig_notation_t notations;
650 /* Internal to GPGME, do not use. */
651 gpgme_sig_notation_t _last_notation;
653 typedef struct _gpgme_key_sig *gpgme_key_sig_t;
656 /* An user ID from a key. */
657 struct _gpgme_user_id
659 struct _gpgme_user_id *next;
661 /* True if the user ID is revoked. */
662 unsigned int revoked : 1;
664 /* True if the user ID is invalid. */
665 unsigned int invalid : 1;
667 /* Internal to GPGME, do not use. */
668 unsigned int _unused : 30;
670 /* The validity of the user ID. */
671 gpgme_validity_t validity;
673 /* The user ID string. */
676 /* The name part of the user ID. */
679 /* The email part of the user ID. */
682 /* The comment part of the user ID. */
685 /* The signatures of the user ID. */
686 gpgme_key_sig_t signatures;
688 /* Internal to GPGME, do not use. */
689 gpgme_key_sig_t _last_keysig;
691 typedef struct _gpgme_user_id *gpgme_user_id_t;
694 /* A key from the keyring. */
697 /* Internal to GPGME, do not use. */
700 /* True if key is revoked. */
701 unsigned int revoked : 1;
703 /* True if key is expired. */
704 unsigned int expired : 1;
706 /* True if key is disabled. */
707 unsigned int disabled : 1;
709 /* True if key is invalid. */
710 unsigned int invalid : 1;
712 /* True if key can be used for encryption. */
713 unsigned int can_encrypt : 1;
715 /* True if key can be used for signing. */
716 unsigned int can_sign : 1;
718 /* True if key can be used for certification. */
719 unsigned int can_certify : 1;
721 /* True if key is secret. */
722 unsigned int secret : 1;
724 /* True if key can be used for authentication. */
725 unsigned int can_authenticate : 1;
727 /* True if subkey is qualified for signatures according to German law. */
728 unsigned int is_qualified : 1;
730 /* Internal to GPGME, do not use. */
731 unsigned int _unused : 22;
733 /* This is the protocol supported by this key. */
734 gpgme_protocol_t protocol;
736 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
740 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
744 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
748 /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
750 gpgme_validity_t owner_trust;
752 /* The subkeys of the key. */
753 gpgme_subkey_t subkeys;
755 /* The user IDs of the key. */
756 gpgme_user_id_t uids;
758 /* Internal to GPGME, do not use. */
759 gpgme_subkey_t _last_subkey;
761 /* Internal to GPGME, do not use. */
762 gpgme_user_id_t _last_uid;
764 /* The keylist mode that was active when listing the key. */
765 gpgme_keylist_mode_t keylist_mode;
767 typedef struct _gpgme_key *gpgme_key_t;
771 /* Types for callback functions. */
773 /* Request a passphrase from the user. */
774 typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
775 const char *uid_hint,
776 const char *passphrase_info,
777 int prev_was_bad, int fd);
779 /* Inform the user about progress made. */
780 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
781 int type, int current, int total);
783 /* Interact with the user about an edit operation. */
784 typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
785 gpgme_status_code_t status,
786 const char *args, int fd);
791 /* Context management functions. */
793 /* Create a new context and return it in CTX. */
794 gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
796 /* Release the context CTX. */
797 void gpgme_release (gpgme_ctx_t ctx);
799 /* Set the protocol to be used by CTX to PROTO. */
800 gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
802 /* Get the protocol used with CTX */
803 gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
805 /* Get the string describing protocol PROTO, or NULL if invalid. */
806 const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
808 /* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
809 void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
811 /* Return non-zero if armor mode is set in CTX. */
812 int gpgme_get_armor (gpgme_ctx_t ctx);
814 /* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
815 void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
817 /* Return non-zero if text mode is set in CTX. */
818 int gpgme_get_textmode (gpgme_ctx_t ctx);
820 /* Use whatever the default of the backend crypto engine is. */
821 #define GPGME_INCLUDE_CERTS_DEFAULT -256
823 /* Include up to NR_OF_CERTS certificates in an S/MIME message. */
824 void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
826 /* Return the number of certs to include in an S/MIME message. */
827 int gpgme_get_include_certs (gpgme_ctx_t ctx);
829 /* Set keylist mode in CTX to MODE. */
830 gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
831 gpgme_keylist_mode_t mode);
833 /* Get keylist mode in CTX. */
834 gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
836 /* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
837 passed as first argument to the passphrase callback function. */
838 void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
839 gpgme_passphrase_cb_t cb, void *hook_value);
841 /* Get the current passphrase callback function in *CB and the current
842 hook value in *HOOK_VALUE. */
843 void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
846 /* Set the progress callback function in CTX to CB. HOOK_VALUE is
847 passed as first argument to the progress callback function. */
848 void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
851 /* Get the current progress callback function in *CB and the current
852 hook value in *HOOK_VALUE. */
853 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
856 /* This function sets the locale for the context CTX, or the default
857 locale if CTX is a null pointer. */
858 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
861 /* Get the information about the configured engines. A pointer to the
862 first engine in the statically allocated linked list is returned.
863 The returned data is valid until the next gpgme_ctx_set_engine_info. */
864 gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
866 /* Set the engine info for the context CTX, protocol PROTO, to the
867 file name FILE_NAME and the home directory HOME_DIR. */
868 gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
869 gpgme_protocol_t proto,
870 const char *file_name,
871 const char *home_dir);
874 /* Return a statically allocated string with the name of the public
875 key algorithm ALGO, or NULL if that name is not known. */
876 const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
878 /* Return a statically allocated string with the name of the hash
879 algorithm ALGO, or NULL if that name is not known. */
880 const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
883 /* Delete all signers from CTX. */
884 void gpgme_signers_clear (gpgme_ctx_t ctx);
886 /* Add KEY to list of signers in CTX. */
887 gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
889 /* Return the SEQth signer's key in CTX. */
890 gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
892 /* Retrieve the signature status of signature IDX in CTX after a
893 successful verify operation in R_STAT (if non-null). The creation
894 time stamp of the signature is returned in R_CREATED (if non-null).
895 The function returns a string containing the fingerprint.
896 Deprecated, use verify result directly. */
897 const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
898 _gpgme_sig_stat_t *r_stat,
899 time_t *r_created) _GPGME_DEPRECATED;
901 /* Retrieve certain attributes of a signature. IDX is the index
902 number of the signature after a successful verify operation. WHAT
903 is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
904 one. WHATIDX is to be passed as 0 for most attributes . */
905 unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
906 _gpgme_attr_t what, int whatidx)
908 const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
909 _gpgme_attr_t what, int whatidx)
913 /* Get the key used to create signature IDX in CTX and return it in
915 gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
919 /* Clear all notation data from the context. */
920 void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
922 /* Add the human-readable notation data with name NAME and value VALUE
923 to the context CTX, using the flags FLAGS. If NAME is NULL, then
924 VALUE should be a policy URL. The flag
925 GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
926 data, and false for policy URLs. */
927 gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
929 gpgme_sig_notation_flags_t flags);
931 /* Get the sig notations for this context. */
932 gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
937 /* The type of an I/O callback function. */
938 typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
940 /* The type of a function that can register FNC as the I/O callback
941 function for the file descriptor FD with direction dir (0: for writing,
942 1: for reading). FNC_DATA should be passed as DATA to FNC. The
943 function should return a TAG suitable for the corresponding
944 gpgme_remove_io_cb_t, and an error value. */
945 typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
947 void *fnc_data, void **tag);
949 /* The type of a function that can remove a previously registered I/O
950 callback function given TAG as returned by the register
952 typedef void (*gpgme_remove_io_cb_t) (void *tag);
958 GPGME_EVENT_NEXT_KEY,
959 GPGME_EVENT_NEXT_TRUSTITEM
963 /* The type of a function that is called when a context finished an
965 typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
970 gpgme_register_io_cb_t add;
972 gpgme_remove_io_cb_t remove;
973 gpgme_event_io_cb_t event;
976 typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
978 /* Set the I/O callback functions in CTX to IO_CBS. */
979 void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
981 /* Get the current I/O callback functions. */
982 void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
984 /* Wrappers around the internal I/O functions for use with
985 gpgme_passphrase_cb_t and gpgme_edit_cb_t. */
986 ssize_t gpgme_io_read (int fd, void *buffer, size_t count);
987 ssize_t gpgme_io_write (int fd, const void *buffer, size_t count);
989 /* Process the pending operation and, if HANG is non-zero, wait for
990 the pending operation to finish. */
991 gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
994 /* Functions to handle data objects. */
996 /* Read up to SIZE bytes into buffer BUFFER from the data object with
997 the handle HANDLE. Return the number of characters read, 0 on EOF
998 and -1 on error. If an error occurs, errno is set. */
999 typedef ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer,
1002 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1003 the handle HANDLE. Return the number of characters written, or -1
1004 on error. If an error occurs, errno is set. */
1005 typedef ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
1008 /* Set the current position from where the next read or write starts
1009 in the data object with the handle HANDLE to OFFSET, relativ to
1011 typedef off_t (*gpgme_data_seek_cb_t) (void *handle, off_t offset, int whence);
1013 /* Close the data object with the handle DL. */
1014 typedef void (*gpgme_data_release_cb_t) (void *handle);
1016 struct gpgme_data_cbs
1018 gpgme_data_read_cb_t read;
1019 gpgme_data_write_cb_t write;
1020 gpgme_data_seek_cb_t seek;
1021 gpgme_data_release_cb_t release;
1023 typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
1025 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1026 the handle DH. Return the number of characters read, 0 on EOF and
1027 -1 on error. If an error occurs, errno is set. */
1028 ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
1030 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1031 the handle DH. Return the number of characters written, or -1 on
1032 error. If an error occurs, errno is set. */
1033 ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
1035 /* Set the current position from where the next read or write starts
1036 in the data object with the handle DH to OFFSET, relativ to
1038 off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence);
1040 /* Create a new data buffer and return it in R_DH. */
1041 gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
1043 /* Destroy the data buffer DH. */
1044 void gpgme_data_release (gpgme_data_t dh);
1046 /* Create a new data buffer filled with SIZE bytes starting from
1047 BUFFER. If COPY is zero, copying is delayed until necessary, and
1048 the data is taken from the original location when needed. */
1049 gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
1050 const char *buffer, size_t size,
1053 /* Destroy the data buffer DH and return a pointer to its content.
1054 The memory has be to released with gpgme_free() by the user. It's
1055 size is returned in R_LEN. */
1056 char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
1058 /* Release the memory returned by gpgme_data_release_and_get_mem(). */
1059 void gpgme_free (void *buffer);
1061 gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
1062 gpgme_data_cbs_t cbs,
1065 gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
1067 gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
1069 /* Return the encoding attribute of the data buffer DH */
1070 gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
1072 /* Set the encoding attribute of data buffer DH to ENC */
1073 gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
1074 gpgme_data_encoding_t enc);
1076 /* Get the file name associated with the data object with handle DH, or
1077 NULL if there is none. */
1078 char *gpgme_data_get_file_name (gpgme_data_t dh);
1080 /* Set the file name associated with the data object with handle DH to
1082 gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
1083 const char *file_name);
1086 /* Create a new data buffer which retrieves the data from the callback
1087 function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
1089 gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
1090 int (*read_cb) (void*,char *,
1092 void *read_cb_value)
1095 /* Create a new data buffer filled with the content of file FNAME.
1096 COPY must be non-zero. For delayed read, please use
1097 gpgme_data_new_from_fd or gpgme_data_new_from stream instead. */
1098 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
1102 /* Create a new data buffer filled with LENGTH bytes starting from
1103 OFFSET within the file FNAME or stream FP (exactly one must be
1105 gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
1106 const char *fname, FILE *fp,
1107 off_t offset, size_t length);
1109 /* Reset the read pointer in DH. Deprecated, please use
1110 gpgme_data_seek instead. */
1111 gpgme_error_t gpgme_data_rewind (gpgme_data_t dh) _GPGME_DEPRECATED;
1114 /* Key and trust functions. */
1116 /* Get the key with the fingerprint FPR from the crypto backend. If
1117 SECRET is true, get the secret key. */
1118 gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
1119 gpgme_key_t *r_key, int secret);
1121 /* Acquire a reference to KEY. */
1122 void gpgme_key_ref (gpgme_key_t key);
1124 /* Release a reference to KEY. If this was the last one the key is
1126 void gpgme_key_unref (gpgme_key_t key);
1127 void gpgme_key_release (gpgme_key_t key);
1129 /* Return the value of the attribute WHAT of KEY, which has to be
1130 representable by a string. IDX specifies the sub key or user ID
1131 for attributes related to sub keys or user IDs. Deprecated, use
1132 key structure directly instead. */
1133 const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
1134 const void *reserved, int idx)
1137 /* Return the value of the attribute WHAT of KEY, which has to be
1138 representable by an unsigned integer. IDX specifies the sub key or
1139 user ID for attributes related to sub keys or user IDs.
1140 Deprecated, use key structure directly instead. */
1141 unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
1142 const void *reserved, int idx)
1145 /* Return the value of the attribute WHAT of a signature on user ID
1146 UID_IDX in KEY, which has to be representable by a string. IDX
1147 specifies the signature. Deprecated, use key structure directly
1149 const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
1151 const void *reserved, int idx)
1154 /* Return the value of the attribute WHAT of a signature on user ID
1155 UID_IDX in KEY, which has to be representable by an unsigned
1156 integer string. IDX specifies the signature. Deprecated, use key
1157 structure directly instead. */
1158 unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
1160 const void *reserved, int idx)
1164 /* Crypto Operations. */
1166 /* Cancel a pending asynchronous operation. */
1167 gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
1169 /* Cancel a pending operation asynchronously. */
1170 gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx);
1173 struct _gpgme_invalid_key
1175 struct _gpgme_invalid_key *next;
1177 gpgme_error_t reason;
1179 typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
1183 struct _gpgme_op_encrypt_result
1185 /* The list of invalid recipients. */
1186 gpgme_invalid_key_t invalid_recipients;
1188 typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
1190 /* Retrieve a pointer to the result of the encrypt operation. */
1191 gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
1193 /* The valid encryption flags. */
1196 GPGME_ENCRYPT_ALWAYS_TRUST = 1,
1197 GPGME_ENCRYPT_NO_ENCRYPT_TO = 2
1199 gpgme_encrypt_flags_t;
1201 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1202 store the resulting ciphertext in CIPHER. */
1203 gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
1204 gpgme_encrypt_flags_t flags,
1205 gpgme_data_t plain, gpgme_data_t cipher);
1206 gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
1207 gpgme_encrypt_flags_t flags,
1208 gpgme_data_t plain, gpgme_data_t cipher);
1210 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1211 store the resulting ciphertext in CIPHER. Also sign the ciphertext
1212 with the signers in CTX. */
1213 gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
1215 gpgme_encrypt_flags_t flags,
1217 gpgme_data_t cipher);
1218 gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
1219 gpgme_encrypt_flags_t flags,
1220 gpgme_data_t plain, gpgme_data_t cipher);
1225 struct _gpgme_recipient
1227 struct _gpgme_recipient *next;
1229 /* The key ID of key for which the text was encrypted. */
1232 /* Internal to GPGME, do not use. */
1233 char _keyid[16 + 1];
1235 /* The public key algorithm of the recipient key. */
1236 gpgme_pubkey_algo_t pubkey_algo;
1238 /* The status of the recipient. */
1239 gpgme_error_t status;
1241 typedef struct _gpgme_recipient *gpgme_recipient_t;
1243 struct _gpgme_op_decrypt_result
1245 char *unsupported_algorithm;
1247 /* Key should not have been used for encryption. */
1248 unsigned int wrong_key_usage : 1;
1250 /* Internal to GPGME, do not use. */
1253 gpgme_recipient_t recipients;
1255 /* The original file name of the plaintext message, if
1259 typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
1261 /* Retrieve a pointer to the result of the decrypt operation. */
1262 gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
1264 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1265 plaintext in PLAIN. */
1266 gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
1267 gpgme_data_t plain);
1268 gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
1269 gpgme_data_t cipher, gpgme_data_t plain);
1271 /* Decrypt ciphertext CIPHER and make a signature verification within
1272 CTX and store the resulting plaintext in PLAIN. */
1273 gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
1274 gpgme_data_t cipher,
1275 gpgme_data_t plain);
1276 gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
1277 gpgme_data_t plain);
1281 struct _gpgme_new_signature
1283 struct _gpgme_new_signature *next;
1285 /* The type of the signature. */
1286 gpgme_sig_mode_t type;
1288 /* The public key algorithm used to create the signature. */
1289 gpgme_pubkey_algo_t pubkey_algo;
1291 /* The hash algorithm used to create the signature. */
1292 gpgme_hash_algo_t hash_algo;
1294 /* Internal to GPGME, do not use. Must be set to the same value as
1296 unsigned long _obsolete_class;
1298 /* Signature creation time. */
1301 /* The fingerprint of the signature. */
1305 unsigned int _obsolete_class_2;
1307 /* Must be set to SIG_CLASS below. */
1308 unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME;
1311 /* Crypto backend specific signature class. */
1312 unsigned int sig_class;
1314 typedef struct _gpgme_new_signature *gpgme_new_signature_t;
1316 struct _gpgme_op_sign_result
1318 /* The list of invalid signers. */
1319 gpgme_invalid_key_t invalid_signers;
1320 gpgme_new_signature_t signatures;
1322 typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
1324 /* Retrieve a pointer to the result of the signing operation. */
1325 gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1327 /* Sign the plaintext PLAIN and store the signature in SIG. */
1328 gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
1329 gpgme_data_t plain, gpgme_data_t sig,
1330 gpgme_sig_mode_t mode);
1331 gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
1332 gpgme_data_t plain, gpgme_data_t sig,
1333 gpgme_sig_mode_t mode);
1338 /* Flags used for the SUMMARY field in a gpgme_signature_t. */
1341 GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
1342 GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
1343 GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
1344 GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
1345 GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
1346 GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
1347 GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
1348 GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
1349 GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
1350 GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
1351 GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */
1355 struct _gpgme_signature
1357 struct _gpgme_signature *next;
1359 /* A summary of the signature status. */
1360 gpgme_sigsum_t summary;
1362 /* The fingerprint or key ID of the signature. */
1365 /* The status of the signature. */
1366 gpgme_error_t status;
1368 /* Notation data and policy URLs. */
1369 gpgme_sig_notation_t notations;
1371 /* Signature creation time. */
1372 unsigned long timestamp;
1374 /* Signature exipration time or 0. */
1375 unsigned long exp_timestamp;
1377 /* Key should not have been used for signing. */
1378 unsigned int wrong_key_usage : 1;
1380 /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1381 unsigned int pka_trust : 2;
1383 /* Validity has been verified using the chain model. */
1384 unsigned int chain_model : 1;
1386 /* Internal to GPGME, do not use. */
1389 gpgme_validity_t validity;
1390 gpgme_error_t validity_reason;
1392 /* The public key algorithm used to create the signature. */
1393 gpgme_pubkey_algo_t pubkey_algo;
1395 /* The hash algorithm used to create the signature. */
1396 gpgme_hash_algo_t hash_algo;
1398 /* The mailbox from the PKA information or NULL. */
1401 typedef struct _gpgme_signature *gpgme_signature_t;
1403 struct _gpgme_op_verify_result
1405 gpgme_signature_t signatures;
1407 /* The original file name of the plaintext message, if
1411 typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
1413 /* Retrieve a pointer to the result of the verify operation. */
1414 gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
1416 /* Verify within CTX that SIG is a valid signature for TEXT. */
1417 gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
1418 gpgme_data_t signed_text,
1419 gpgme_data_t plaintext);
1420 gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
1421 gpgme_data_t signed_text,
1422 gpgme_data_t plaintext);
1427 /* The key was new. */
1428 #define GPGME_IMPORT_NEW 1
1430 /* The key contained new user IDs. */
1431 #define GPGME_IMPORT_UID 2
1433 /* The key contained new signatures. */
1434 #define GPGME_IMPORT_SIG 4
1436 /* The key contained new sub keys. */
1437 #define GPGME_IMPORT_SUBKEY 8
1439 /* The key contained a secret key. */
1440 #define GPGME_IMPORT_SECRET 16
1443 struct _gpgme_import_status
1445 struct _gpgme_import_status *next;
1450 /* If a problem occured, the reason why the key could not be
1451 imported. Otherwise GPGME_No_Error. */
1452 gpgme_error_t result;
1454 /* The result of the import, the GPGME_IMPORT_* values bit-wise
1455 ORed. 0 means the key was already known and no new components
1457 unsigned int status;
1459 typedef struct _gpgme_import_status *gpgme_import_status_t;
1462 struct _gpgme_op_import_result
1464 /* Number of considered keys. */
1467 /* Keys without user ID. */
1470 /* Imported keys. */
1473 /* Imported RSA keys. */
1476 /* Unchanged keys. */
1479 /* Number of new user ids. */
1482 /* Number of new sub keys. */
1485 /* Number of new signatures. */
1488 /* Number of new revocations. */
1489 int new_revocations;
1491 /* Number of secret keys read. */
1494 /* Number of secret keys imported. */
1495 int secret_imported;
1497 /* Number of secret keys unchanged. */
1498 int secret_unchanged;
1500 /* Number of new keys skipped. */
1501 int skipped_new_keys;
1503 /* Number of keys not imported. */
1506 /* List of keys for which an import was attempted. */
1507 gpgme_import_status_t imports;
1509 typedef struct _gpgme_op_import_result *gpgme_import_result_t;
1511 /* Retrieve a pointer to the result of the import operation. */
1512 gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
1514 /* Import the key in KEYDATA into the keyring. */
1515 gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
1516 gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
1517 gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
1518 int *nr) _GPGME_DEPRECATED;
1520 /* Import the keys from the array KEYS into the keyring. */
1521 gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1522 gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1526 /* Export the keys found by PATTERN into KEYDATA. */
1527 gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
1528 gpgme_export_mode_t mode,
1529 gpgme_data_t keydata);
1530 gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
1531 gpgme_export_mode_t mode,
1532 gpgme_data_t keydata);
1534 gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
1535 const char *pattern[],
1536 gpgme_export_mode_t mode,
1537 gpgme_data_t keydata);
1538 gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
1539 gpgme_export_mode_t mode,
1540 gpgme_data_t keydata);
1542 /* Export the keys from the array KEYS into KEYDATA. */
1543 gpgme_error_t gpgme_op_export_keys_start (gpgme_ctx_t ctx,
1545 gpgme_export_mode_t mode,
1546 gpgme_data_t keydata);
1547 gpgme_error_t gpgme_op_export_keys (gpgme_ctx_t ctx,
1549 gpgme_export_mode_t mode,
1550 gpgme_data_t keydata);
1554 /* Key generation. */
1555 struct _gpgme_op_genkey_result
1557 /* A primary key was generated. */
1558 unsigned int primary : 1;
1560 /* A sub key was generated. */
1561 unsigned int sub : 1;
1563 /* Internal to GPGME, do not use. */
1564 unsigned int _unused : 30;
1566 /* The fingerprint of the generated key. */
1569 typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
1571 /* Generate a new keypair and add it to the keyring. PUBKEY and
1572 SECKEY should be null for now. PARMS specifies what keys should be
1574 gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
1575 gpgme_data_t pubkey, gpgme_data_t seckey);
1576 gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
1577 gpgme_data_t pubkey, gpgme_data_t seckey);
1579 /* Retrieve a pointer to the result of the genkey operation. */
1580 gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
1583 /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
1584 keys are also deleted. */
1585 gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
1587 gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
1591 /* Edit the key KEY. Send status and command requests to FNC and
1592 output of edit commands to OUT. */
1593 gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1594 gpgme_edit_cb_t fnc, void *fnc_value,
1596 gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1597 gpgme_edit_cb_t fnc, void *fnc_value,
1600 /* Edit the card for the key KEY. Send status and command requests to
1601 FNC and output of edit commands to OUT. */
1602 gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1603 gpgme_edit_cb_t fnc, void *fnc_value,
1605 gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1606 gpgme_edit_cb_t fnc, void *fnc_value,
1610 /* Key management functions. */
1611 struct _gpgme_op_keylist_result
1613 unsigned int truncated : 1;
1615 /* Internal to GPGME, do not use. */
1616 unsigned int _unused : 31;
1618 typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
1620 /* Retrieve a pointer to the result of the key listing operation. */
1621 gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
1623 /* Start a keylist operation within CTX, searching for keys which
1624 match PATTERN. If SECRET_ONLY is true, only secret keys are
1626 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
1628 gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
1629 const char *pattern[],
1630 int secret_only, int reserved);
1632 /* Return the next key from the keylist in R_KEY. */
1633 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
1635 /* Terminate a pending keylist operation within CTX. */
1636 gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
1639 /* Trust items and operations. */
1641 struct _gpgme_trust_item
1643 /* Internal to GPGME, do not use. */
1646 /* The key ID to which the trust item belongs. */
1649 /* Internal to GPGME, do not use. */
1650 char _keyid[16 + 1];
1652 /* The type of the trust item, 1 refers to a key, 2 to a user ID. */
1655 /* The trust level. */
1658 /* The owner trust if TYPE is 1. */
1661 /* Internal to GPGME, do not use. */
1662 char _owner_trust[2];
1664 /* The calculated validity. */
1667 /* Internal to GPGME, do not use. */
1670 /* The user name if TYPE is 2. */
1673 typedef struct _gpgme_trust_item *gpgme_trust_item_t;
1675 /* Start a trustlist operation within CTX, searching for trust items
1676 which match PATTERN. */
1677 gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
1678 const char *pattern, int max_level);
1680 /* Return the next trust item from the trustlist in R_ITEM. */
1681 gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
1682 gpgme_trust_item_t *r_item);
1684 /* Terminate a pending trustlist operation within CTX. */
1685 gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
1687 /* Acquire a reference to ITEM. */
1688 void gpgme_trust_item_ref (gpgme_trust_item_t item);
1690 /* Release a reference to ITEM. If this was the last one the trust
1691 item is destroyed. */
1692 void gpgme_trust_item_unref (gpgme_trust_item_t item);
1694 /* Release the trust item ITEM. Deprecated, use
1695 gpgme_trust_item_unref. */
1696 void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED;
1698 /* Return the value of the attribute WHAT of ITEM, which has to be
1699 representable by a string. Deprecated, use trust item structure
1701 const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item,
1703 const void *reserved, int idx)
1706 /* Return the value of the attribute WHAT of KEY, which has to be
1707 representable by an integer. IDX specifies a running index if the
1708 attribute appears more than once in the key. Deprecated, use trust
1709 item structure directly. */
1710 int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what,
1711 const void *reserved, int idx)
1715 /* Return the auditlog for the current session. This may be called
1716 after a successful or failed operation. If no audit log is
1717 available GPG_ERR_NO_DATA is returned. */
1718 gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
1719 unsigned int flags);
1720 gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
1721 unsigned int flags);
1725 /* Low-level Assuan protocol access. */
1726 typedef gpgme_error_t (*gpgme_assuan_data_cb_t)
1727 (void *opaque, const void *data, size_t datalen);
1729 typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t)
1730 (void *opaque, const char *name, const char *args,
1731 gpgme_data_t *r_data);
1733 typedef gpgme_error_t (*gpgme_assuan_status_cb_t)
1734 (void *opaque, const char *status, const char *args);
1736 struct _gpgme_op_assuan_result
1738 /* The result of the actual assuan command. An OK is indicated by a
1739 value of 0 and an ERR by the respective error error value. This
1740 is required because assuan operations use a session-based
1741 interface. The error code of the GPGME function calls just
1742 reflects transmission errors. */
1745 typedef struct _gpgme_op_assuan_result *gpgme_assuan_result_t;
1748 /* Return the result of the last Assuan command. */
1749 gpgme_assuan_result_t gpgme_op_assuan_result (gpgme_ctx_t ctx);
1751 /* Send the Assuan COMMAND and return results via the callbacks.
1752 Asynchronous variant. */
1753 gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx,
1754 const char *command,
1755 gpgme_assuan_data_cb_t data_cb,
1756 void *data_cb_value,
1757 gpgme_assuan_inquire_cb_t inq_cb,
1759 gpgme_assuan_status_cb_t stat_cb,
1760 void *stat_cb_value);
1762 /* Send the Assuan COMMAND and return results via the callbacks.
1763 Synchronous variant. */
1764 gpgme_error_t gpgme_op_assuan_transact (gpgme_ctx_t ctx,
1765 const char *command,
1766 gpgme_assuan_data_cb_t data_cb,
1767 void *data_cb_value,
1768 gpgme_assuan_inquire_cb_t inq_cb,
1770 gpgme_assuan_status_cb_t stat_cb,
1771 void *stat_cb_value);
1775 /* Crypto container support. */
1776 struct _gpgme_op_g13_result
1778 /* The result of the actual assuan command. An OK is indicated by a
1779 value of 0 and an ERR by the respective error error value. This
1780 is required because assuan operations use a session-based
1781 interface. The error code of the GPGME function calls just
1782 reflects transmission errors. */
1785 typedef struct _gpgme_op_g13_result *gpgme_g13_result_t;
1787 /* The container is automatically unmounted when the context is reset
1788 or destroyed. This is a synchronous convenience interface, which
1789 automatically returns an operation error if there is no
1790 transmission error. */
1791 gpgme_error_t gpgme_op_g13_mount (gpgme_ctx_t ctx, const char *container_file,
1792 const char *mount_dir, int flags);
1795 /* Interface to gpgconf(1). */
1797 /* The expert level at which a configuration option or group of
1798 options should be displayed. See the gpgconf(1) documentation for
1802 GPGME_CONF_BASIC = 0,
1803 GPGME_CONF_ADVANCED = 1,
1804 GPGME_CONF_EXPERT = 2,
1805 GPGME_CONF_INVISIBLE = 3,
1806 GPGME_CONF_INTERNAL = 4
1811 /* The data type of a configuration option argument. See the gpgconf(1)
1812 documentation for more details. */
1816 GPGME_CONF_NONE = 0,
1817 GPGME_CONF_STRING = 1,
1818 GPGME_CONF_INT32 = 2,
1819 GPGME_CONF_UINT32 = 3,
1821 /* Complex types. */
1822 GPGME_CONF_FILENAME = 32,
1823 GPGME_CONF_LDAP_SERVER = 33,
1824 GPGME_CONF_KEY_FPR = 34,
1825 GPGME_CONF_PUB_KEY = 35,
1826 GPGME_CONF_SEC_KEY = 36,
1827 GPGME_CONF_ALIAS_LIST = 37
1831 /* For now, compatibility. */
1832 #define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
1835 /* This represents a single argument for a configuration option.
1836 Which of the members of value is used depends on the ALT_TYPE. */
1837 typedef struct gpgme_conf_arg
1839 struct gpgme_conf_arg *next;
1840 /* True if the option appears without an (optional) argument. */
1841 unsigned int no_arg;
1845 unsigned int uint32;
1849 } *gpgme_conf_arg_t;
1852 /* The flags of a configuration option. See the gpg-conf
1853 documentation for details. */
1854 #define GPGME_CONF_GROUP (1 << 0)
1855 #define GPGME_CONF_OPTIONAL (1 << 1)
1856 #define GPGME_CONF_LIST (1 << 2)
1857 #define GPGME_CONF_RUNTIME (1 << 3)
1858 #define GPGME_CONF_DEFAULT (1 << 4)
1859 #define GPGME_CONF_DEFAULT_DESC (1 << 5)
1860 #define GPGME_CONF_NO_ARG_DESC (1 << 6)
1861 #define GPGME_CONF_NO_CHANGE (1 << 7)
1864 /* The representation of a single configuration option. See the
1865 gpg-conf documentation for details. */
1866 typedef struct gpgme_conf_opt
1868 struct gpgme_conf_opt *next;
1870 /* The option name. */
1873 /* The flags for this option. */
1876 /* The level of this option. */
1877 gpgme_conf_level_t level;
1879 /* The localized description of this option. */
1882 /* The type and alternate type of this option. */
1883 gpgme_conf_type_t type;
1884 gpgme_conf_type_t alt_type;
1886 /* The localized (short) name of the argument, if any. */
1889 /* The default value. */
1890 gpgme_conf_arg_t default_value;
1891 char *default_description;
1893 /* The default value if the option is not set. */
1894 gpgme_conf_arg_t no_arg_value;
1895 char *no_arg_description;
1897 /* The current value if the option is set. */
1898 gpgme_conf_arg_t value;
1900 /* The new value, if any. NULL means reset to default. */
1902 gpgme_conf_arg_t new_value;
1904 /* Free for application use. */
1906 } *gpgme_conf_opt_t;
1909 /* The representation of a component that can be configured. See the
1910 gpg-conf documentation for details. */
1911 typedef struct gpgme_conf_comp
1913 struct gpgme_conf_comp *next;
1915 /* Internal to GPGME, do not use! */
1916 gpgme_conf_opt_t *_last_opt_p;
1918 /* The component name. */
1921 /* A human-readable description for the component. */
1924 /* The program name (an absolute path to the program). */
1927 /* A linked list of options for this component. */
1928 struct gpgme_conf_opt *options;
1929 } *gpgme_conf_comp_t;
1932 /* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg
1933 default" is prepared. If type is a string type, VALUE should point
1934 to the string. Else, it should point to an unsigned or signed
1935 integer respectively. */
1936 gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
1937 gpgme_conf_type_t type, void *value);
1939 /* This also releases all chained argument structures! */
1940 void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
1942 /* Register a change for the value of OPT to ARG. If RESET is 1 (do
1943 not use any values but 0 or 1), ARG is ignored and the option is
1944 not changed (reverting a previous change). Otherwise, if ARG is
1945 NULL, the option is cleared or reset to its default. */
1946 gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
1947 gpgme_conf_arg_t arg);
1949 /* Release a set of configurations. */
1950 void gpgme_conf_release (gpgme_conf_comp_t conf);
1952 /* Retrieve the current configurations. */
1953 gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
1955 /* Save the configuration of component comp. This function does not
1956 follow chained components! */
1957 gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
1960 /* Various functions. */
1962 /* Check that the library fulfills the version requirement. Note:
1963 This is here only for the case where a user takes a pointer from
1964 the old version of this function. The new version and macro for
1965 run-time checks are below. */
1966 const char *gpgme_check_version (const char *req_version);
1968 /* Check that the library fulfills the version requirement and check
1969 for struct layout mismatch involving bitfields. */
1970 const char *gpgme_check_version_internal (const char *req_version,
1971 size_t offset_sig_validity);
1973 #define gpgme_check_version(req_version) \
1974 gpgme_check_version_internal (req_version, \
1975 offsetof (struct _gpgme_signature, validity))
1977 /* Get the information about the configured and installed engines. A
1978 pointer to the first engine in the statically allocated linked list
1979 is returned in *INFO. If an error occurs, it is returned. The
1980 returned data is valid until the next gpgme_set_engine_info. */
1981 gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
1983 /* Set the default engine info for the protocol PROTO to the file name
1984 FILE_NAME and the home directory HOME_DIR. */
1985 gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
1986 const char *file_name,
1987 const char *home_dir);
1990 /* Engine support functions. */
1992 /* Verify that the engine implementing PROTO is installed and
1994 gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
1997 void gpgme_result_ref (void *result);
1998 void gpgme_result_unref (void *result);
2001 /* Deprecated types. */
2002 typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED;
2003 typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED;
2004 typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED;
2005 typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED;
2006 typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED;
2007 typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED;
2008 typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED;
2009 typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED;
2010 typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED;
2011 typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED;
2012 typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED;
2013 typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED;
2014 typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED;
2015 typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED;
2016 typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED;
2017 typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED;
2018 typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED;
2019 typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED;
2020 typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED;
2021 typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED;
2022 typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED;
2023 typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED;
2024 typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED;
2025 #define GpgmeIOCbs gpgme_io_cbs
2026 typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED;
2027 typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED;
2028 typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED;
2029 typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED;
2030 #define GpgmeDataCbs gpgme_data_cbs
2031 typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED;
2032 typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED;
2033 typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED;
2034 typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED;
2035 typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED;
2036 typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED;
2037 typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED;
2038 typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED;
2039 typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED;
2044 #endif /* GPGME_H */