1 /* gpgme.h - Public interface to GnuPG Made Easy.
2 Copyright (C) 2000 Werner Koch (dd9jn)
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 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/>.
25 #define _GPGME_INLINE __inline__
26 #elif __STDC_VERSION__ >= 199901L
27 #define _GPGME_INLINE inline
32 /* Include stdio.h for the FILE type definition. */
39 # include <sys/types.h>
42 #include <gpg-error.h>
46 #if 0 /* just to make Emacs auto-indent happy */
49 #endif /* __cplusplus */
53 /* Check for compiler features. */
55 #define _GPGME_GCC_VERSION (__GNUC__ * 10000 \
56 + __GNUC_MINOR__ * 100 \
57 + __GNUC_PATCHLEVEL__)
59 #if _GPGME_GCC_VERSION > 30100
60 #define _GPGME_DEPRECATED __attribute__ ((__deprecated__))
64 #ifndef _GPGME_DEPRECATED
65 #define _GPGME_DEPRECATED
69 /* The version of this header should match the one of the library. Do
70 not use this symbol in your application, use gpgme_check_version
71 instead. The purpose of this macro is to let autoconf (using the
72 AM_PATH_GPGME macro) check that this header matches the installed
73 library. Warning: Do not edit the next line. configure will do
75 #define GPGME_VERSION "1.1.6-svn1258"
79 /* Some opaque data types used by GPGME. */
81 /* The context holds some global state and configration options, as
82 well as the results of a crypto operation. */
84 typedef struct gpgme_context *gpgme_ctx_t;
86 /* The data object is used by GPGME to exchange arbitrary data. */
88 typedef struct gpgme_data *gpgme_data_t;
91 /* Wrappers for the libgpg-error library. */
93 typedef gpg_error_t gpgme_error_t;
94 typedef gpg_err_code_t gpgme_err_code_t;
95 typedef gpg_err_source_t gpgme_err_source_t;
98 static _GPGME_INLINE gpgme_error_t
99 gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code)
101 return gpg_err_make (source, code);
105 /* The user can define GPGME_ERR_SOURCE_DEFAULT before including this
106 file to specify a default source for gpgme_error. */
107 #ifndef GPGME_ERR_SOURCE_DEFAULT
108 #define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
111 static _GPGME_INLINE gpgme_error_t
112 gpgme_error (gpgme_err_code_t code)
114 return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code);
118 static _GPGME_INLINE gpgme_err_code_t
119 gpgme_err_code (gpgme_error_t err)
121 return gpg_err_code (err);
125 static _GPGME_INLINE gpgme_err_source_t
126 gpgme_err_source (gpgme_error_t err)
128 return gpg_err_source (err);
132 /* Return a pointer to a string containing a description of the error
133 code in the error value ERR. This function is not thread safe. */
134 const char *gpgme_strerror (gpgme_error_t err);
136 /* Return the error string for ERR in the user-supplied buffer BUF of
137 size BUFLEN. This function is, in contrast to gpg_strerror,
138 thread-safe if a thread-safe strerror_r() function is provided by
139 the system. If the function succeeds, 0 is returned and BUF
140 contains the string describing the error. If the buffer was not
141 large enough, ERANGE is returned and BUF contains as much of the
142 beginning of the error string as fits into the buffer. */
143 int gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen);
146 /* Return a pointer to a string containing a description of the error
147 source in the error value ERR. */
148 const char *gpgme_strsource (gpgme_error_t err);
151 /* Retrieve the error code for the system error ERR. This returns
152 GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
154 gpgme_err_code_t gpgme_err_code_from_errno (int err);
157 /* Retrieve the system error for the error code CODE. This returns 0
158 if CODE is not a system error code. */
159 int gpgme_err_code_to_errno (gpgme_err_code_t code);
162 /* Return an error value with the error source SOURCE and the system
164 gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err);
167 /* Return an error value with the system error ERR. */
168 gpgme_err_code_t gpgme_error_from_errno (int err);
171 /* The possible encoding mode of gpgme_data_t objects. */
174 GPGME_DATA_ENCODING_NONE = 0, /* Not specified. */
175 GPGME_DATA_ENCODING_BINARY = 1,
176 GPGME_DATA_ENCODING_BASE64 = 2,
177 GPGME_DATA_ENCODING_ARMOR = 3 /* Either PEM or OpenPGP Armor. */
179 gpgme_data_encoding_t;
182 /* Public key algorithms from libgcrypt. */
195 /* Hash algorithms from libgcrypt. */
203 GPGME_MD_TIGER = 6, /* TIGER/192. */
204 GPGME_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */
207 GPGME_MD_SHA512 = 10,
209 GPGME_MD_CRC32 = 302,
210 GPGME_MD_CRC32_RFC1510 = 303,
211 GPGME_MD_CRC24_RFC2440 = 304
216 /* The possible signature stati. Deprecated, use error value in sig
220 GPGME_SIG_STAT_NONE = 0,
221 GPGME_SIG_STAT_GOOD = 1,
222 GPGME_SIG_STAT_BAD = 2,
223 GPGME_SIG_STAT_NOKEY = 3,
224 GPGME_SIG_STAT_NOSIG = 4,
225 GPGME_SIG_STAT_ERROR = 5,
226 GPGME_SIG_STAT_DIFF = 6,
227 GPGME_SIG_STAT_GOOD_EXP = 7,
228 GPGME_SIG_STAT_GOOD_EXPKEY = 8
231 typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED;
234 /* The available signature modes. */
237 GPGME_SIG_MODE_NORMAL = 0,
238 GPGME_SIG_MODE_DETACH = 1,
239 GPGME_SIG_MODE_CLEAR = 2
244 /* The available key and signature attributes. Deprecated, use the
245 individual result structures instead. */
248 GPGME_ATTR_KEYID = 1,
252 GPGME_ATTR_CREATED = 5,
253 GPGME_ATTR_EXPIRE = 6,
254 GPGME_ATTR_OTRUST = 7,
255 GPGME_ATTR_USERID = 8,
257 GPGME_ATTR_EMAIL = 10,
258 GPGME_ATTR_COMMENT = 11,
259 GPGME_ATTR_VALIDITY = 12,
260 GPGME_ATTR_LEVEL = 13,
261 GPGME_ATTR_TYPE = 14,
262 GPGME_ATTR_IS_SECRET = 15,
263 GPGME_ATTR_KEY_REVOKED = 16,
264 GPGME_ATTR_KEY_INVALID = 17,
265 GPGME_ATTR_UID_REVOKED = 18,
266 GPGME_ATTR_UID_INVALID = 19,
267 GPGME_ATTR_KEY_CAPS = 20,
268 GPGME_ATTR_CAN_ENCRYPT = 21,
269 GPGME_ATTR_CAN_SIGN = 22,
270 GPGME_ATTR_CAN_CERTIFY = 23,
271 GPGME_ATTR_KEY_EXPIRED = 24,
272 GPGME_ATTR_KEY_DISABLED = 25,
273 GPGME_ATTR_SERIAL = 26,
274 GPGME_ATTR_ISSUER = 27,
275 GPGME_ATTR_CHAINID = 28,
276 GPGME_ATTR_SIG_STATUS = 29,
277 GPGME_ATTR_ERRTOK = 30,
278 GPGME_ATTR_SIG_SUMMARY = 31,
279 GPGME_ATTR_SIG_CLASS = 32
282 typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED;
285 /* The available validities for a trust item or key. */
288 GPGME_VALIDITY_UNKNOWN = 0,
289 GPGME_VALIDITY_UNDEFINED = 1,
290 GPGME_VALIDITY_NEVER = 2,
291 GPGME_VALIDITY_MARGINAL = 3,
292 GPGME_VALIDITY_FULL = 4,
293 GPGME_VALIDITY_ULTIMATE = 5
298 /* The available protocols. */
301 GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
302 GPGME_PROTOCOL_CMS = 1,
303 GPGME_PROTOCOL_UNKNOWN = 255
308 /* The available keylist mode flags. */
309 #define GPGME_KEYLIST_MODE_LOCAL 1
310 #define GPGME_KEYLIST_MODE_EXTERN 2
311 #define GPGME_KEYLIST_MODE_SIGS 4
312 #define GPGME_KEYLIST_MODE_SIG_NOTATIONS 8
313 #define GPGME_KEYLIST_MODE_VALIDATE 256
315 typedef unsigned int gpgme_keylist_mode_t;
318 /* Flags for the audit log functions. */
319 #define GPGME_AUDITLOG_HTML 1
320 #define GPGME_AUDITLOG_WITH_HELP 128
323 /* Signature notations. */
325 /* The available signature notation flags. */
326 #define GPGME_SIG_NOTATION_HUMAN_READABLE 1
327 #define GPGME_SIG_NOTATION_CRITICAL 2
329 typedef unsigned int gpgme_sig_notation_flags_t;
331 struct _gpgme_sig_notation
333 struct _gpgme_sig_notation *next;
335 /* If NAME is a null pointer, then VALUE contains a policy URL
336 rather than a notation. */
339 /* The value of the notation data. */
342 /* The length of the name of the notation data. */
345 /* The length of the value of the notation data. */
348 /* The accumulated flags. */
349 gpgme_sig_notation_flags_t flags;
351 /* Notation data is human-readable. */
352 unsigned int human_readable : 1;
354 /* Notation data is critical. */
355 unsigned int critical : 1;
357 /* Internal to GPGME, do not use. */
360 typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
363 /* The possible stati for the edit operation. */
367 /* mkstatus processing starts here */
372 GPGME_STATUS_GOODSIG,
376 GPGME_STATUS_BADARMOR,
378 GPGME_STATUS_RSA_OR_IDEA,
379 GPGME_STATUS_KEYEXPIRED,
380 GPGME_STATUS_KEYREVOKED,
382 GPGME_STATUS_TRUST_UNDEFINED,
383 GPGME_STATUS_TRUST_NEVER,
384 GPGME_STATUS_TRUST_MARGINAL,
385 GPGME_STATUS_TRUST_FULLY,
386 GPGME_STATUS_TRUST_ULTIMATE,
388 GPGME_STATUS_SHM_INFO,
389 GPGME_STATUS_SHM_GET,
390 GPGME_STATUS_SHM_GET_BOOL,
391 GPGME_STATUS_SHM_GET_HIDDEN,
393 GPGME_STATUS_NEED_PASSPHRASE,
394 GPGME_STATUS_VALIDSIG,
398 GPGME_STATUS_BAD_PASSPHRASE,
399 GPGME_STATUS_NO_PUBKEY,
400 GPGME_STATUS_NO_SECKEY,
401 GPGME_STATUS_NEED_PASSPHRASE_SYM,
402 GPGME_STATUS_DECRYPTION_FAILED,
403 GPGME_STATUS_DECRYPTION_OKAY,
404 GPGME_STATUS_MISSING_PASSPHRASE,
405 GPGME_STATUS_GOOD_PASSPHRASE,
406 GPGME_STATUS_GOODMDC,
409 GPGME_STATUS_IMPORTED,
410 GPGME_STATUS_IMPORT_OK,
411 GPGME_STATUS_IMPORT_PROBLEM,
412 GPGME_STATUS_IMPORT_RES,
413 GPGME_STATUS_FILE_START,
414 GPGME_STATUS_FILE_DONE,
415 GPGME_STATUS_FILE_ERROR,
417 GPGME_STATUS_BEGIN_DECRYPTION,
418 GPGME_STATUS_END_DECRYPTION,
419 GPGME_STATUS_BEGIN_ENCRYPTION,
420 GPGME_STATUS_END_ENCRYPTION,
422 GPGME_STATUS_DELETE_PROBLEM,
423 GPGME_STATUS_GET_BOOL,
424 GPGME_STATUS_GET_LINE,
425 GPGME_STATUS_GET_HIDDEN,
427 GPGME_STATUS_PROGRESS,
428 GPGME_STATUS_SIG_CREATED,
429 GPGME_STATUS_SESSION_KEY,
430 GPGME_STATUS_NOTATION_NAME,
431 GPGME_STATUS_NOTATION_DATA,
432 GPGME_STATUS_POLICY_URL,
433 GPGME_STATUS_BEGIN_STREAM,
434 GPGME_STATUS_END_STREAM,
435 GPGME_STATUS_KEY_CREATED,
436 GPGME_STATUS_USERID_HINT,
437 GPGME_STATUS_UNEXPECTED,
438 GPGME_STATUS_INV_RECP,
439 GPGME_STATUS_NO_RECP,
440 GPGME_STATUS_ALREADY_SIGNED,
441 GPGME_STATUS_SIGEXPIRED,
443 GPGME_STATUS_EXPKEYSIG,
444 GPGME_STATUS_TRUNCATED,
447 GPGME_STATUS_REVKEYSIG,
448 GPGME_STATUS_SIG_SUBPACKET,
449 GPGME_STATUS_NEED_PASSPHRASE_PIN,
450 GPGME_STATUS_SC_OP_FAILURE,
451 GPGME_STATUS_SC_OP_SUCCESS,
452 GPGME_STATUS_CARDCTRL,
453 GPGME_STATUS_BACKUP_KEY_CREATED,
454 GPGME_STATUS_PKA_TRUST_BAD,
455 GPGME_STATUS_PKA_TRUST_GOOD,
457 GPGME_STATUS_PLAINTEXT
462 /* The engine information structure. */
463 struct _gpgme_engine_info
465 struct _gpgme_engine_info *next;
467 /* The protocol ID. */
468 gpgme_protocol_t protocol;
470 /* The file name of the engine binary. */
473 /* The version string of the installed engine. */
476 /* The minimum version required for GPGME. */
477 const char *req_version;
479 /* The home directory used, or NULL if default. */
482 typedef struct _gpgme_engine_info *gpgme_engine_info_t;
485 /* A subkey from a key. */
488 struct _gpgme_subkey *next;
490 /* True if subkey is revoked. */
491 unsigned int revoked : 1;
493 /* True if subkey is expired. */
494 unsigned int expired : 1;
496 /* True if subkey is disabled. */
497 unsigned int disabled : 1;
499 /* True if subkey is invalid. */
500 unsigned int invalid : 1;
502 /* True if subkey can be used for encryption. */
503 unsigned int can_encrypt : 1;
505 /* True if subkey can be used for signing. */
506 unsigned int can_sign : 1;
508 /* True if subkey can be used for certification. */
509 unsigned int can_certify : 1;
511 /* True if subkey is secret. */
512 unsigned int secret : 1;
514 /* True if subkey can be used for authentication. */
515 unsigned int can_authenticate : 1;
517 /* True if subkey is qualified for signatures according to German law. */
518 unsigned int is_qualified : 1;
520 /* Internal to GPGME, do not use. */
521 unsigned int _unused : 22;
523 /* Public key algorithm supported by this subkey. */
524 gpgme_pubkey_algo_t pubkey_algo;
526 /* Length of the subkey. */
529 /* The key ID of the subkey. */
532 /* Internal to GPGME, do not use. */
535 /* The fingerprint of the subkey in hex digit form. */
538 /* The creation timestamp, -1 if invalid, 0 if not available. */
541 /* The expiration timestamp, 0 if the subkey does not expire. */
544 typedef struct _gpgme_subkey *gpgme_subkey_t;
547 /* A signature on a user ID. */
548 struct _gpgme_key_sig
550 struct _gpgme_key_sig *next;
552 /* True if the signature is a revocation signature. */
553 unsigned int revoked : 1;
555 /* True if the signature is expired. */
556 unsigned int expired : 1;
558 /* True if the signature is invalid. */
559 unsigned int invalid : 1;
561 /* True if the signature should be exported. */
562 unsigned int exportable : 1;
564 /* Internal to GPGME, do not use. */
565 unsigned int _unused : 28;
567 /* The public key algorithm used to create the signature. */
568 gpgme_pubkey_algo_t pubkey_algo;
570 /* The key ID of key used to create the signature. */
573 /* Internal to GPGME, do not use. */
576 /* The creation timestamp, -1 if invalid, 0 if not available. */
579 /* The expiration timestamp, 0 if the subkey does not expire. */
582 /* Same as in gpgme_signature_t. */
583 gpgme_error_t status;
586 unsigned int _obsolete_class _GPGME_DEPRECATED;
588 /* Must be set to SIG_CLASS below. */
589 unsigned int class _GPGME_DEPRECATED;
592 /* The user ID string. */
595 /* The name part of the user ID. */
598 /* The email part of the user ID. */
601 /* The comment part of the user ID. */
604 /* Crypto backend specific signature class. */
605 unsigned int sig_class;
607 /* Notation data and policy URLs. */
608 gpgme_sig_notation_t notations;
610 /* Internal to GPGME, do not use. */
611 gpgme_sig_notation_t _last_notation;
613 typedef struct _gpgme_key_sig *gpgme_key_sig_t;
616 /* An user ID from a key. */
617 struct _gpgme_user_id
619 struct _gpgme_user_id *next;
621 /* True if the user ID is revoked. */
622 unsigned int revoked : 1;
624 /* True if the user ID is invalid. */
625 unsigned int invalid : 1;
627 /* Internal to GPGME, do not use. */
628 unsigned int _unused : 30;
630 /* The validity of the user ID. */
631 gpgme_validity_t validity;
633 /* The user ID string. */
636 /* The name part of the user ID. */
639 /* The email part of the user ID. */
642 /* The comment part of the user ID. */
645 /* The signatures of the user ID. */
646 gpgme_key_sig_t signatures;
648 /* Internal to GPGME, do not use. */
649 gpgme_key_sig_t _last_keysig;
651 typedef struct _gpgme_user_id *gpgme_user_id_t;
654 /* A key from the keyring. */
657 /* Internal to GPGME, do not use. */
660 /* True if key is revoked. */
661 unsigned int revoked : 1;
663 /* True if key is expired. */
664 unsigned int expired : 1;
666 /* True if key is disabled. */
667 unsigned int disabled : 1;
669 /* True if key is invalid. */
670 unsigned int invalid : 1;
672 /* True if key can be used for encryption. */
673 unsigned int can_encrypt : 1;
675 /* True if key can be used for signing. */
676 unsigned int can_sign : 1;
678 /* True if key can be used for certification. */
679 unsigned int can_certify : 1;
681 /* True if key is secret. */
682 unsigned int secret : 1;
684 /* True if key can be used for authentication. */
685 unsigned int can_authenticate : 1;
687 /* True if subkey is qualified for signatures according to German law. */
688 unsigned int is_qualified : 1;
690 /* Internal to GPGME, do not use. */
691 unsigned int _unused : 22;
693 /* This is the protocol supported by this key. */
694 gpgme_protocol_t protocol;
696 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
700 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
704 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
708 /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
710 gpgme_validity_t owner_trust;
712 /* The subkeys of the key. */
713 gpgme_subkey_t subkeys;
715 /* The user IDs of the key. */
716 gpgme_user_id_t uids;
718 /* Internal to GPGME, do not use. */
719 gpgme_subkey_t _last_subkey;
721 /* Internal to GPGME, do not use. */
722 gpgme_user_id_t _last_uid;
724 /* The keylist mode that was active when listing the key. */
725 gpgme_keylist_mode_t keylist_mode;
727 typedef struct _gpgme_key *gpgme_key_t;
731 /* Types for callback functions. */
733 /* Request a passphrase from the user. */
734 typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
735 const char *uid_hint,
736 const char *passphrase_info,
737 int prev_was_bad, int fd);
739 /* Inform the user about progress made. */
740 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
741 int type, int current, int total);
743 /* Interact with the user about an edit operation. */
744 typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
745 gpgme_status_code_t status,
746 const char *args, int fd);
749 /* Context management functions. */
751 /* Create a new context and return it in CTX. */
752 gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
754 /* Release the context CTX. */
755 void gpgme_release (gpgme_ctx_t ctx);
757 /* Set the protocol to be used by CTX to PROTO. */
758 gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
760 /* Get the protocol used with CTX */
761 gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
763 /* Get the string describing protocol PROTO, or NULL if invalid. */
764 const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
766 /* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
767 void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
769 /* Return non-zero if armor mode is set in CTX. */
770 int gpgme_get_armor (gpgme_ctx_t ctx);
772 /* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
773 void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
775 /* Return non-zero if text mode is set in CTX. */
776 int gpgme_get_textmode (gpgme_ctx_t ctx);
778 /* Use whatever the default of the backend crypto engine is. */
779 #define GPGME_INCLUDE_CERTS_DEFAULT -256
781 /* Include up to NR_OF_CERTS certificates in an S/MIME message. */
782 void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
784 /* Return the number of certs to include in an S/MIME message. */
785 int gpgme_get_include_certs (gpgme_ctx_t ctx);
787 /* Set keylist mode in CTX to MODE. */
788 gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
789 gpgme_keylist_mode_t mode);
791 /* Get keylist mode in CTX. */
792 gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
794 /* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
795 passed as first argument to the passphrase callback function. */
796 void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
797 gpgme_passphrase_cb_t cb, void *hook_value);
799 /* Get the current passphrase callback function in *CB and the current
800 hook value in *HOOK_VALUE. */
801 void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
804 /* Set the progress callback function in CTX to CB. HOOK_VALUE is
805 passed as first argument to the progress callback function. */
806 void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
809 /* Get the current progress callback function in *CB and the current
810 hook value in *HOOK_VALUE. */
811 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
814 /* This function sets the locale for the context CTX, or the default
815 locale if CTX is a null pointer. */
816 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
819 /* Get the information about the configured engines. A pointer to the
820 first engine in the statically allocated linked list is returned.
821 The returned data is valid until the next gpgme_ctx_set_engine_info. */
822 gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
824 /* Set the engine info for the context CTX, protocol PROTO, to the
825 file name FILE_NAME and the home directory HOME_DIR. */
826 gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
827 gpgme_protocol_t proto,
828 const char *file_name,
829 const char *home_dir);
832 /* Return a statically allocated string with the name of the public
833 key algorithm ALGO, or NULL if that name is not known. */
834 const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
836 /* Return a statically allocated string with the name of the hash
837 algorithm ALGO, or NULL if that name is not known. */
838 const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
841 /* Delete all signers from CTX. */
842 void gpgme_signers_clear (gpgme_ctx_t ctx);
844 /* Add KEY to list of signers in CTX. */
845 gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
847 /* Return the SEQth signer's key in CTX. */
848 gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
850 /* Retrieve the signature status of signature IDX in CTX after a
851 successful verify operation in R_STAT (if non-null). The creation
852 time stamp of the signature is returned in R_CREATED (if non-null).
853 The function returns a string containing the fingerprint.
854 Deprecated, use verify result directly. */
855 const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
856 _gpgme_sig_stat_t *r_stat,
857 time_t *r_created) _GPGME_DEPRECATED;
859 /* Retrieve certain attributes of a signature. IDX is the index
860 number of the signature after a successful verify operation. WHAT
861 is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
862 one. WHATIDX is to be passed as 0 for most attributes . */
863 unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
864 _gpgme_attr_t what, int whatidx)
866 const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
867 _gpgme_attr_t what, int whatidx)
871 /* Get the key used to create signature IDX in CTX and return it in
873 gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
877 /* Clear all notation data from the context. */
878 void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
880 /* Add the human-readable notation data with name NAME and value VALUE
881 to the context CTX, using the flags FLAGS. If NAME is NULL, then
882 VALUE should be a policy URL. The flag
883 GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
884 data, and false for policy URLs. */
885 gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
887 gpgme_sig_notation_flags_t flags);
889 /* Get the sig notations for this context. */
890 gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
895 /* The type of an I/O callback function. */
896 typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
898 /* The type of a function that can register FNC as the I/O callback
899 function for the file descriptor FD with direction dir (0: for writing,
900 1: for reading). FNC_DATA should be passed as DATA to FNC. The
901 function should return a TAG suitable for the corresponding
902 gpgme_remove_io_cb_t, and an error value. */
903 typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
905 void *fnc_data, void **tag);
907 /* The type of a function that can remove a previously registered I/O
908 callback function given TAG as returned by the register
910 typedef void (*gpgme_remove_io_cb_t) (void *tag);
916 GPGME_EVENT_NEXT_KEY,
917 GPGME_EVENT_NEXT_TRUSTITEM
921 /* The type of a function that is called when a context finished an
923 typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
928 gpgme_register_io_cb_t add;
930 gpgme_remove_io_cb_t remove;
931 gpgme_event_io_cb_t event;
934 typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
936 /* Set the I/O callback functions in CTX to IO_CBS. */
937 void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
939 /* Get the current I/O callback functions. */
940 void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
942 /* Process the pending operation and, if HANG is non-zero, wait for
943 the pending operation to finish. */
944 gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
947 /* Functions to handle data objects. */
949 /* Read up to SIZE bytes into buffer BUFFER from the data object with
950 the handle HANDLE. Return the number of characters read, 0 on EOF
951 and -1 on error. If an error occurs, errno is set. */
952 typedef ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer,
955 /* Write up to SIZE bytes from buffer BUFFER to the data object with
956 the handle HANDLE. Return the number of characters written, or -1
957 on error. If an error occurs, errno is set. */
958 typedef ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
961 /* Set the current position from where the next read or write starts
962 in the data object with the handle HANDLE to OFFSET, relativ to
964 typedef off_t (*gpgme_data_seek_cb_t) (void *handle, off_t offset, int whence);
966 /* Close the data object with the handle DL. */
967 typedef void (*gpgme_data_release_cb_t) (void *handle);
969 struct gpgme_data_cbs
971 gpgme_data_read_cb_t read;
972 gpgme_data_write_cb_t write;
973 gpgme_data_seek_cb_t seek;
974 gpgme_data_release_cb_t release;
976 typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
978 /* Read up to SIZE bytes into buffer BUFFER from the data object with
979 the handle DH. Return the number of characters read, 0 on EOF and
980 -1 on error. If an error occurs, errno is set. */
981 ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
983 /* Write up to SIZE bytes from buffer BUFFER to the data object with
984 the handle DH. Return the number of characters written, or -1 on
985 error. If an error occurs, errno is set. */
986 ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
988 /* Set the current position from where the next read or write starts
989 in the data object with the handle DH to OFFSET, relativ to
991 off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence);
993 /* Create a new data buffer and return it in R_DH. */
994 gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
996 /* Destroy the data buffer DH. */
997 void gpgme_data_release (gpgme_data_t dh);
999 /* Create a new data buffer filled with SIZE bytes starting from
1000 BUFFER. If COPY is zero, copying is delayed until necessary, and
1001 the data is taken from the original location when needed. */
1002 gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
1003 const char *buffer, size_t size,
1006 /* Destroy the data buffer DH and return a pointer to its content.
1007 The memory has be to released with gpgme_free() by the user. It's
1008 size is returned in R_LEN. */
1009 char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
1011 /* Release the memory returned by gpgme_data_release_and_get_mem(). */
1012 void gpgme_free (void *buffer);
1014 gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
1015 gpgme_data_cbs_t cbs,
1018 gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
1020 gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
1022 /* Return the encoding attribute of the data buffer DH */
1023 gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
1025 /* Set the encoding attribute of data buffer DH to ENC */
1026 gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
1027 gpgme_data_encoding_t enc);
1029 /* Get the file name associated with the data object with handle DH, or
1030 NULL if there is none. */
1031 char *gpgme_data_get_file_name (gpgme_data_t dh);
1033 /* Set the file name associated with the data object with handle DH to
1035 gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
1036 const char *file_name);
1039 /* Create a new data buffer which retrieves the data from the callback
1040 function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
1042 gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
1043 int (*read_cb) (void*,char *,
1045 void *read_cb_value)
1048 /* Create a new data buffer filled with the content of file FNAME.
1049 COPY must be non-zero. For delayed read, please use
1050 gpgme_data_new_from_fd or gpgme_data_new_from stream instead. */
1051 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
1055 /* Create a new data buffer filled with LENGTH bytes starting from
1056 OFFSET within the file FNAME or stream FP (exactly one must be
1058 gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
1059 const char *fname, FILE *fp,
1060 off_t offset, size_t length);
1062 /* Reset the read pointer in DH. Deprecated, please use
1063 gpgme_data_seek instead. */
1064 gpgme_error_t gpgme_data_rewind (gpgme_data_t dh) _GPGME_DEPRECATED;
1067 /* Key and trust functions. */
1069 /* Get the key with the fingerprint FPR from the crypto backend. If
1070 SECRET is true, get the secret key. */
1071 gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
1072 gpgme_key_t *r_key, int secret);
1074 /* Acquire a reference to KEY. */
1075 void gpgme_key_ref (gpgme_key_t key);
1077 /* Release a reference to KEY. If this was the last one the key is
1079 void gpgme_key_unref (gpgme_key_t key);
1080 void gpgme_key_release (gpgme_key_t key);
1082 /* Return the value of the attribute WHAT of KEY, which has to be
1083 representable by a string. IDX specifies the sub key or user ID
1084 for attributes related to sub keys or user IDs. Deprecated, use
1085 key structure directly instead. */
1086 const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
1087 const void *reserved, int idx)
1090 /* Return the value of the attribute WHAT of KEY, which has to be
1091 representable by an unsigned integer. IDX specifies the sub key or
1092 user ID for attributes related to sub keys or user IDs.
1093 Deprecated, use key structure directly instead. */
1094 unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
1095 const void *reserved, int idx)
1098 /* Return the value of the attribute WHAT of a signature on user ID
1099 UID_IDX in KEY, which has to be representable by a string. IDX
1100 specifies the signature. Deprecated, use key structure directly
1102 const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
1104 const void *reserved, int idx)
1107 /* Return the value of the attribute WHAT of a signature on user ID
1108 UID_IDX in KEY, which has to be representable by an unsigned
1109 integer string. IDX specifies the signature. Deprecated, use key
1110 structure directly instead. */
1111 unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
1113 const void *reserved, int idx)
1117 /* Crypto Operations. */
1119 /* Cancel a pending asynchronous operation. */
1120 gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
1123 struct _gpgme_invalid_key
1125 struct _gpgme_invalid_key *next;
1127 gpgme_error_t reason;
1129 typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
1133 struct _gpgme_op_encrypt_result
1135 /* The list of invalid recipients. */
1136 gpgme_invalid_key_t invalid_recipients;
1138 typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
1140 /* Retrieve a pointer to the result of the encrypt operation. */
1141 gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
1143 /* The valid encryption flags. */
1146 GPGME_ENCRYPT_ALWAYS_TRUST = 1
1148 gpgme_encrypt_flags_t;
1150 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1151 store the resulting ciphertext in CIPHER. */
1152 gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
1153 gpgme_encrypt_flags_t flags,
1154 gpgme_data_t plain, gpgme_data_t cipher);
1155 gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
1156 gpgme_encrypt_flags_t flags,
1157 gpgme_data_t plain, gpgme_data_t cipher);
1159 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1160 store the resulting ciphertext in CIPHER. Also sign the ciphertext
1161 with the signers in CTX. */
1162 gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
1164 gpgme_encrypt_flags_t flags,
1166 gpgme_data_t cipher);
1167 gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
1168 gpgme_encrypt_flags_t flags,
1169 gpgme_data_t plain, gpgme_data_t cipher);
1174 struct _gpgme_recipient
1176 struct _gpgme_recipient *next;
1178 /* The key ID of key for which the text was encrypted. */
1181 /* Internal to GPGME, do not use. */
1182 char _keyid[16 + 1];
1184 /* The public key algorithm of the recipient key. */
1185 gpgme_pubkey_algo_t pubkey_algo;
1187 /* The status of the recipient. */
1188 gpgme_error_t status;
1190 typedef struct _gpgme_recipient *gpgme_recipient_t;
1192 struct _gpgme_op_decrypt_result
1194 char *unsupported_algorithm;
1196 /* Key should not have been used for encryption. */
1197 unsigned int wrong_key_usage : 1;
1199 /* Internal to GPGME, do not use. */
1202 gpgme_recipient_t recipients;
1204 /* The original file name of the plaintext message, if
1208 typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
1210 /* Retrieve a pointer to the result of the decrypt operation. */
1211 gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
1213 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1214 plaintext in PLAIN. */
1215 gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
1216 gpgme_data_t plain);
1217 gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
1218 gpgme_data_t cipher, gpgme_data_t plain);
1220 /* Decrypt ciphertext CIPHER and make a signature verification within
1221 CTX and store the resulting plaintext in PLAIN. */
1222 gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
1223 gpgme_data_t cipher,
1224 gpgme_data_t plain);
1225 gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
1226 gpgme_data_t plain);
1230 struct _gpgme_new_signature
1232 struct _gpgme_new_signature *next;
1234 /* The type of the signature. */
1235 gpgme_sig_mode_t type;
1237 /* The public key algorithm used to create the signature. */
1238 gpgme_pubkey_algo_t pubkey_algo;
1240 /* The hash algorithm used to create the signature. */
1241 gpgme_hash_algo_t hash_algo;
1243 /* Internal to GPGME, do not use. Must be set to the same value as
1245 unsigned long _obsolete_class;
1247 /* Signature creation time. */
1250 /* The fingerprint of the signature. */
1254 unsigned int _obsolete_class_2;
1256 /* Must be set to SIG_CLASS below. */
1257 unsigned int class _GPGME_DEPRECATED;
1260 /* Crypto backend specific signature class. */
1261 unsigned int sig_class;
1263 typedef struct _gpgme_new_signature *gpgme_new_signature_t;
1265 struct _gpgme_op_sign_result
1267 /* The list of invalid signers. */
1268 gpgme_invalid_key_t invalid_signers;
1269 gpgme_new_signature_t signatures;
1271 typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
1273 /* Retrieve a pointer to the result of the signing operation. */
1274 gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1276 /* Sign the plaintext PLAIN and store the signature in SIG. */
1277 gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
1278 gpgme_data_t plain, gpgme_data_t sig,
1279 gpgme_sig_mode_t mode);
1280 gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
1281 gpgme_data_t plain, gpgme_data_t sig,
1282 gpgme_sig_mode_t mode);
1287 /* Flags used for the SUMMARY field in a gpgme_signature_t. */
1290 GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
1291 GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
1292 GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
1293 GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
1294 GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
1295 GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
1296 GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
1297 GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
1298 GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
1299 GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
1300 GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */
1304 struct _gpgme_signature
1306 struct _gpgme_signature *next;
1308 /* A summary of the signature status. */
1309 gpgme_sigsum_t summary;
1311 /* The fingerprint or key ID of the signature. */
1314 /* The status of the signature. */
1315 gpgme_error_t status;
1317 /* Notation data and policy URLs. */
1318 gpgme_sig_notation_t notations;
1320 /* Signature creation time. */
1321 unsigned long timestamp;
1323 /* Signature exipration time or 0. */
1324 unsigned long exp_timestamp;
1326 /* Key should not have been used for signing. */
1327 unsigned int wrong_key_usage : 1;
1329 /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1330 unsigned int pka_trust : 2;
1332 /* Validity has been verified using the chain model. */
1333 unsigned int chain_model : 1;
1335 /* Internal to GPGME, do not use. */
1338 gpgme_validity_t validity;
1339 gpgme_error_t validity_reason;
1341 /* The public key algorithm used to create the signature. */
1342 gpgme_pubkey_algo_t pubkey_algo;
1344 /* The hash algorithm used to create the signature. */
1345 gpgme_hash_algo_t hash_algo;
1347 /* The mailbox from the PKA information or NULL. */
1350 typedef struct _gpgme_signature *gpgme_signature_t;
1352 struct _gpgme_op_verify_result
1354 gpgme_signature_t signatures;
1356 /* The original file name of the plaintext message, if
1360 typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
1362 /* Retrieve a pointer to the result of the verify operation. */
1363 gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
1365 /* Verify within CTX that SIG is a valid signature for TEXT. */
1366 gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
1367 gpgme_data_t signed_text,
1368 gpgme_data_t plaintext);
1369 gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
1370 gpgme_data_t signed_text,
1371 gpgme_data_t plaintext);
1376 /* The key was new. */
1377 #define GPGME_IMPORT_NEW 1
1379 /* The key contained new user IDs. */
1380 #define GPGME_IMPORT_UID 2
1382 /* The key contained new signatures. */
1383 #define GPGME_IMPORT_SIG 4
1385 /* The key contained new sub keys. */
1386 #define GPGME_IMPORT_SUBKEY 8
1388 /* The key contained a secret key. */
1389 #define GPGME_IMPORT_SECRET 16
1392 struct _gpgme_import_status
1394 struct _gpgme_import_status *next;
1399 /* If a problem occured, the reason why the key could not be
1400 imported. Otherwise GPGME_No_Error. */
1401 gpgme_error_t result;
1403 /* The result of the import, the GPGME_IMPORT_* values bit-wise
1404 ORed. 0 means the key was already known and no new components
1406 unsigned int status;
1408 typedef struct _gpgme_import_status *gpgme_import_status_t;
1411 struct _gpgme_op_import_result
1413 /* Number of considered keys. */
1416 /* Keys without user ID. */
1419 /* Imported keys. */
1422 /* Imported RSA keys. */
1425 /* Unchanged keys. */
1428 /* Number of new user ids. */
1431 /* Number of new sub keys. */
1434 /* Number of new signatures. */
1437 /* Number of new revocations. */
1438 int new_revocations;
1440 /* Number of secret keys read. */
1443 /* Number of secret keys imported. */
1444 int secret_imported;
1446 /* Number of secret keys unchanged. */
1447 int secret_unchanged;
1449 /* Number of new keys skipped. */
1450 int skipped_new_keys;
1452 /* Number of keys not imported. */
1455 /* List of keys for which an import was attempted. */
1456 gpgme_import_status_t imports;
1458 typedef struct _gpgme_op_import_result *gpgme_import_result_t;
1460 /* Retrieve a pointer to the result of the import operation. */
1461 gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
1463 /* Import the key in KEYDATA into the keyring. */
1464 gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
1465 gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
1466 gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
1467 int *nr) _GPGME_DEPRECATED;
1470 /* Export the keys found by PATTERN into KEYDATA. */
1471 gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
1472 unsigned int reserved,
1473 gpgme_data_t keydata);
1474 gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
1475 unsigned int reserved, gpgme_data_t keydata);
1477 gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
1478 const char *pattern[],
1479 unsigned int reserved,
1480 gpgme_data_t keydata);
1481 gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
1482 unsigned int reserved,
1483 gpgme_data_t keydata);
1486 /* Key generation. */
1487 struct _gpgme_op_genkey_result
1489 /* A primary key was generated. */
1490 unsigned int primary : 1;
1492 /* A sub key was generated. */
1493 unsigned int sub : 1;
1495 /* Internal to GPGME, do not use. */
1496 unsigned int _unused : 30;
1498 /* The fingerprint of the generated key. */
1501 typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
1503 /* Generate a new keypair and add it to the keyring. PUBKEY and
1504 SECKEY should be null for now. PARMS specifies what keys should be
1506 gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
1507 gpgme_data_t pubkey, gpgme_data_t seckey);
1508 gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
1509 gpgme_data_t pubkey, gpgme_data_t seckey);
1511 /* Retrieve a pointer to the result of the genkey operation. */
1512 gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
1515 /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
1516 keys are also deleted. */
1517 gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
1519 gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
1523 /* Edit the key KEY. Send status and command requests to FNC and
1524 output of edit commands to OUT. */
1525 gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1526 gpgme_edit_cb_t fnc, void *fnc_value,
1528 gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1529 gpgme_edit_cb_t fnc, void *fnc_value,
1532 /* Edit the card for the key KEY. Send status and command requests to
1533 FNC and output of edit commands to OUT. */
1534 gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
1535 gpgme_edit_cb_t fnc, void *fnc_value,
1537 gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key,
1538 gpgme_edit_cb_t fnc, void *fnc_value,
1542 /* Key management functions. */
1543 struct _gpgme_op_keylist_result
1545 unsigned int truncated : 1;
1547 /* Internal to GPGME, do not use. */
1548 unsigned int _unused : 31;
1550 typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
1552 /* Retrieve a pointer to the result of the key listing operation. */
1553 gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
1555 /* Start a keylist operation within CTX, searching for keys which
1556 match PATTERN. If SECRET_ONLY is true, only secret keys are
1558 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
1560 gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
1561 const char *pattern[],
1562 int secret_only, int reserved);
1564 /* Return the next key from the keylist in R_KEY. */
1565 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
1567 /* Terminate a pending keylist operation within CTX. */
1568 gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
1571 /* Trust items and operations. */
1573 struct _gpgme_trust_item
1575 /* Internal to GPGME, do not use. */
1578 /* The key ID to which the trust item belongs. */
1581 /* Internal to GPGME, do not use. */
1582 char _keyid[16 + 1];
1584 /* The type of the trust item, 1 refers to a key, 2 to a user ID. */
1587 /* The trust level. */
1590 /* The owner trust if TYPE is 1. */
1593 /* Internal to GPGME, do not use. */
1594 char _owner_trust[2];
1596 /* The calculated validity. */
1599 /* Internal to GPGME, do not use. */
1602 /* The user name if TYPE is 2. */
1605 typedef struct _gpgme_trust_item *gpgme_trust_item_t;
1607 /* Start a trustlist operation within CTX, searching for trust items
1608 which match PATTERN. */
1609 gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
1610 const char *pattern, int max_level);
1612 /* Return the next trust item from the trustlist in R_ITEM. */
1613 gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
1614 gpgme_trust_item_t *r_item);
1616 /* Terminate a pending trustlist operation within CTX. */
1617 gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
1619 /* Acquire a reference to ITEM. */
1620 void gpgme_trust_item_ref (gpgme_trust_item_t item);
1622 /* Release a reference to ITEM. If this was the last one the trust
1623 item is destroyed. */
1624 void gpgme_trust_item_unref (gpgme_trust_item_t item);
1626 /* Release the trust item ITEM. Deprecated, use
1627 gpgme_trust_item_unref. */
1628 void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED;
1630 /* Return the value of the attribute WHAT of ITEM, which has to be
1631 representable by a string. Deprecated, use trust item structure
1633 const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item,
1635 const void *reserved, int idx)
1638 /* Return the value of the attribute WHAT of KEY, which has to be
1639 representable by an integer. IDX specifies a running index if the
1640 attribute appears more than once in the key. Deprecated, use trust
1641 item structure directly. */
1642 int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what,
1643 const void *reserved, int idx)
1647 /* Return the auditlog for the current session. This may be called
1648 after a successful or failed operation. If no audit log is
1649 available GPG_ERR_NO_DATA is returned. */
1650 gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
1651 unsigned int flags);
1652 gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
1653 unsigned int flags);
1657 /* Various functions. */
1659 /* Check that the library fulfills the version requirement. */
1660 const char *gpgme_check_version (const char *req_version);
1662 /* Get the information about the configured and installed engines. A
1663 pointer to the first engine in the statically allocated linked list
1664 is returned in *INFO. If an error occurs, it is returned. The
1665 returned data is valid until the next gpgme_set_engine_info. */
1666 gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
1668 /* Set the default engine info for the protocol PROTO to the file name
1669 FILE_NAME and the home directory HOME_DIR. */
1670 gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
1671 const char *file_name,
1672 const char *home_dir);
1675 /* Engine support functions. */
1677 /* Verify that the engine implementing PROTO is installed and
1679 gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
1682 /* Deprecated types. */
1683 typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED;
1684 typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED;
1685 typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED;
1686 typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED;
1687 typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED;
1688 typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED;
1689 typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED;
1690 typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED;
1691 typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED;
1692 typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED;
1693 typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED;
1694 typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED;
1695 typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED;
1696 typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED;
1697 typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED;
1698 typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED;
1699 typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED;
1700 typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED;
1701 typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED;
1702 typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED;
1703 typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED;
1704 typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED;
1705 typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED;
1706 #define GpgmeIOCbs gpgme_io_cbs
1707 typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED;
1708 typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED;
1709 typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED;
1710 typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED;
1711 #define GpgmeDataCbs gpgme_data_cbs
1712 typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED;
1713 typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED;
1714 typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED;
1715 typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED;
1716 typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED;
1717 typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED;
1718 typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED;
1719 typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED;
1720 typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED;
1725 #endif /* GPGME_H */