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