Imported Upstream version 2.1.12
[platform/upstream/gpg2.git] / g10 / options.h
1 /* options.h
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3  *               2007, 2010, 2011 Free Software Foundation, Inc.
4  * Copyright (C) 2015 g10 Code GmbH
5  *
6  * This file is part of GnuPG.
7  *
8  * GnuPG is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * GnuPG is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21 #ifndef G10_OPTIONS_H
22 #define G10_OPTIONS_H
23
24 #include <sys/types.h>
25 #include <types.h>
26 #include "main.h"
27 #include "packet.h"
28 #include "tofu.h"
29 #include "../common/session-env.h"
30
31 #ifndef EXTERN_UNLESS_MAIN_MODULE
32 /* Norcraft can't cope with common symbols */
33 #if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
34 #define EXTERN_UNLESS_MAIN_MODULE extern
35 #else
36 #define EXTERN_UNLESS_MAIN_MODULE
37 #endif
38 #endif
39
40 /* Declaration of a keyserver spec type.  The definition is found in
41    ../common/keyserver.h.  */
42 struct keyserver_spec;
43 typedef struct keyserver_spec *keyserver_spec_t;
44
45
46 /* Global options for GPG.  */
47 EXTERN_UNLESS_MAIN_MODULE
48 struct
49 {
50   int verbose;
51   int quiet;
52   unsigned debug;
53   int armor;
54   char *outfile;
55   estream_t outfp;  /* Hack, sometimes used in place of outfile.  */
56   off_t max_output;
57   int dry_run;
58   int autostart;
59   int list_only;
60   int textmode;
61   int expert;
62   const char *def_sig_expire;
63   int ask_sig_expire;
64   const char *def_cert_expire;
65   int ask_cert_expire;
66   int batch;        /* run in batch mode */
67   int answer_yes; /* answer yes on most questions */
68   int answer_no;  /* answer no on most questions */
69   int check_sigs; /* check key signatures */
70   int with_colons;
71   int with_key_data;
72   int with_icao_spelling; /* Print ICAO spelling with fingerprints.  */
73   int with_fingerprint; /* Option --with-fingerprint active.  */
74   int with_keygrip;     /* Option --with-keygrip active.  */
75   int with_secret;      /* Option --with-secret active.  */
76   int with_wkd_hash;    /* Option --with-wkd-hash.  */
77   int fingerprint; /* list fingerprints */
78   int list_sigs;   /* list signatures */
79   int print_pka_records;
80   int print_dane_records;
81   int no_armor;
82   int list_packets; /* list-packets mode: 1=normal, 2=invoked by command*/
83   int def_cipher_algo;
84   int force_mdc;
85   int disable_mdc;
86   int def_digest_algo;
87   int cert_digest_algo;
88   int compress_algo;
89   int compress_level;
90   int bz2_compress_level;
91   int bz2_decompress_lowmem;
92   strlist_t def_secret_key;
93   char *def_recipient;
94   int def_recipient_self;
95   strlist_t secret_keys_to_try;
96
97   int def_cert_level;
98   int min_cert_level;
99   int ask_cert_level;
100   int emit_version;       /* 0 = none,
101                              1 = major only,
102                              2 = major and minor,
103                              3 = full version,
104                              4 = full version plus OS string. */
105   int marginals_needed;
106   int completes_needed;
107   int max_cert_depth;
108   const char *homedir;
109   const char *agent_program;
110   const char *dirmngr_program;
111
112   /* Options to be passed to the gpg-agent */
113   session_env_t session_env;
114   char *lc_ctype;
115   char *lc_messages;
116
117   int skip_verify;
118   int skip_hidden_recipients;
119
120   /* TM_CLASSIC must be zero to accommodate trustdbs generated before
121      we started storing the trust model inside the trustdb. */
122   enum
123     {
124       TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2,
125       TM_ALWAYS, TM_DIRECT, TM_AUTO, TM_TOFU, TM_TOFU_PGP
126     } trust_model;
127   enum
128     {
129       TOFU_DB_AUTO=0, TOFU_DB_SPLIT, TOFU_DB_FLAT
130     } tofu_db_format;
131   enum tofu_policy tofu_default_policy;
132   int force_ownertrust;
133   enum
134     {
135       CO_GNUPG, CO_RFC4880, CO_RFC2440,
136       CO_PGP6, CO_PGP7, CO_PGP8
137     } compliance;
138   enum
139     {
140       KF_DEFAULT, KF_SHORT, KF_LONG, KF_0xSHORT, KF_0xLONG
141     } keyid_format;
142   int shm_coprocess;
143   const char *set_filename;
144   strlist_t comments;
145   int throw_keyids;
146   const char *photo_viewer;
147   int s2k_mode;
148   int s2k_digest_algo;
149   int s2k_cipher_algo;
150   unsigned char s2k_count; /* This is the encoded form, not the raw
151                               count */
152   int not_dash_escaped;
153   int escape_from;
154   int lock_once;
155   keyserver_spec_t keyserver;  /* The list of configured keyservers.  */
156   struct
157   {
158     unsigned int options;
159     unsigned int import_options;
160     unsigned int export_options;
161     char *http_proxy;
162   } keyserver_options;
163   int exec_disable;
164   int exec_path_set;
165   unsigned int import_options;
166   unsigned int export_options;
167   unsigned int list_options;
168   unsigned int verify_options;
169   const char *def_preference_list;
170   const char *def_keyserver_url;
171   prefitem_t *personal_cipher_prefs;
172   prefitem_t *personal_digest_prefs;
173   prefitem_t *personal_compress_prefs;
174   struct weakhash *weak_digests;
175   int no_perm_warn;
176   int no_mdc_warn;
177   char *temp_dir;
178   int no_encrypt_to;
179   int encrypt_to_default_key;
180   int interactive;
181   struct notation *sig_notations;
182   struct notation *cert_notations;
183   strlist_t sig_policy_url;
184   strlist_t cert_policy_url;
185   strlist_t sig_keyserver_url;
186   strlist_t cert_subpackets;
187   strlist_t sig_subpackets;
188   int allow_non_selfsigned_uid;
189   int allow_freeform_uid;
190   int no_literal;
191   ulong set_filesize;
192   int fast_list_mode;
193   int legacy_list_mode;
194   int ignore_time_conflict;
195   int ignore_valid_from;
196   int ignore_crc_error;
197   int ignore_mdc_error;
198   int command_fd;
199   const char *override_session_key;
200   int show_session_key;
201
202   const char *gpg_agent_info;
203   int try_all_secrets;
204   int no_expensive_trust_checks;
205   int no_sig_cache;
206   int no_auto_check_trustdb;
207   int preserve_permissions;
208   int no_homedir_creation;
209   struct groupitem *grouplist;
210   int mangle_dos_filenames;
211   int enable_progress_filter;
212   unsigned int screen_columns;
213   unsigned int screen_lines;
214   byte *show_subpackets;
215   int rfc2440_text;
216
217   /* If true, let write failures on the status-fd exit the process. */
218   int exit_on_status_write_error;
219
220   /* If > 0, limit the number of card insertion prompts to this
221      value. */
222   int limit_card_insert_tries;
223
224   struct
225   {
226     /* If set, require an 0x19 backsig to be present on signatures
227        made by signing subkeys.  If not set, a missing backsig is not
228        an error (but an invalid backsig still is). */
229     unsigned int require_cross_cert:1;
230
231     unsigned int use_embedded_filename:1;
232     unsigned int utf8_filename:1;
233     unsigned int dsa2:1;
234     unsigned int allow_multiple_messages:1;
235     unsigned int allow_weak_digest_algos:1;
236     unsigned int large_rsa:1;
237   } flags;
238
239   /* Linked list of ways to find a key if the key isn't on the local
240      keyring. */
241   struct akl
242   {
243     enum {
244       AKL_NODEFAULT,
245       AKL_LOCAL,
246       AKL_CERT,
247       AKL_PKA,
248       AKL_DANE,
249       AKL_WKD,
250       AKL_LDAP,
251       AKL_KEYSERVER,
252       AKL_SPEC
253     } type;
254     keyserver_spec_t spec;
255     struct akl *next;
256   } *auto_key_locate;
257
258   int passphrase_repeat;
259   int pinentry_mode;
260
261   int unwrap_encryption;
262   int only_sign_text_ids;
263 } opt;
264
265 /* CTRL is used to keep some global variables we currently can't
266    avoid.  Future concurrent versions of gpg will put it into a per
267    request structure CTRL. */
268 EXTERN_UNLESS_MAIN_MODULE
269 struct {
270   int in_auto_key_retrieve; /* True if we are doing an
271                                auto_key_retrieve. */
272   /* Hack to store the last error.  We currently need it because the
273      proc_packet machinery is not able to reliabale return error
274      codes.  Thus for the --server purposes we store some of the error
275      codes here.  FIXME! */
276   gpg_error_t lasterr;
277 } glo_ctrl;
278
279 #define DBG_PACKET_VALUE  1     /* debug packet reading/writing */
280 #define DBG_MPI_VALUE     2     /* debug mpi details */
281 #define DBG_CRYPTO_VALUE  4     /* debug crypto handling */
282                                 /* (may reveal sensitive data) */
283 #define DBG_FILTER_VALUE  8     /* debug internal filter handling */
284 #define DBG_IOBUF_VALUE   16    /* debug iobuf stuff */
285 #define DBG_MEMORY_VALUE  32    /* debug memory allocation stuff */
286 #define DBG_CACHE_VALUE   64    /* debug the caching */
287 #define DBG_MEMSTAT_VALUE 128   /* show memory statistics */
288 #define DBG_TRUST_VALUE   256   /* debug the trustdb */
289 #define DBG_HASHING_VALUE 512   /* debug hashing operations */
290 #define DBG_IPC_VALUE     1024  /* debug assuan communication */
291 #define DBG_CARD_IO_VALUE 2048  /* debug smart card I/O.  */
292 #define DBG_CLOCK_VALUE   4096
293 #define DBG_LOOKUP_VALUE  8192  /* debug the kety lookup */
294 #define DBG_EXTPROG_VALUE 16384 /* debug external program calls */
295
296 /* Tests for the debugging flags.  */
297 #define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
298 #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
299 #define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
300 #define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
301 #define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
302 #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
303 #define DBG_IPC     (opt.debug & DBG_IPC_VALUE)
304 #define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
305 #define DBG_IPC     (opt.debug & DBG_IPC_VALUE)
306 #define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
307 #define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
308 #define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
309
310 /* FIXME: We need to check whey we did not put this into opt. */
311 #define DBG_MEMORY    memory_debug_mode
312 #define DBG_MEMSTAT   memory_stat_debug_mode
313
314 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
315 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
316
317
318 /* Compatibility flags.  */
319 #define GNUPG   (opt.compliance==CO_GNUPG)
320 #define RFC2440 (opt.compliance==CO_RFC2440)
321 #define RFC4880 (opt.compliance==CO_RFC4880)
322 #define PGP6    (opt.compliance==CO_PGP6)
323 #define PGP7    (opt.compliance==CO_PGP7)
324 #define PGP8    (opt.compliance==CO_PGP8)
325 #define PGPX    (PGP6 || PGP7 || PGP8)
326
327 /* Various option flags.  Note that there should be no common string
328    names between the IMPORT_ and EXPORT_ flags as they can be mixed in
329    the keyserver-options option. */
330
331 #define IMPORT_LOCAL_SIGS                (1<<0)
332 #define IMPORT_REPAIR_PKS_SUBKEY_BUG     (1<<1)
333 #define IMPORT_FAST                      (1<<2)
334 #define IMPORT_MERGE_ONLY                (1<<4)
335 #define IMPORT_MINIMAL                   (1<<5)
336 #define IMPORT_CLEAN                     (1<<6)
337 #define IMPORT_NO_SECKEY                 (1<<7)
338 #define IMPORT_KEEP_OWNERTTRUST          (1<<8)
339
340 #define EXPORT_LOCAL_SIGS                (1<<0)
341 #define EXPORT_ATTRIBUTES                (1<<1)
342 #define EXPORT_SENSITIVE_REVKEYS         (1<<2)
343 #define EXPORT_RESET_SUBKEY_PASSWD       (1<<3)
344 #define EXPORT_MINIMAL                   (1<<4)
345 #define EXPORT_CLEAN                     (1<<5)
346 #define EXPORT_DANE_FORMAT               (1<<6)
347
348 #define LIST_SHOW_PHOTOS                 (1<<0)
349 #define LIST_SHOW_POLICY_URLS            (1<<1)
350 #define LIST_SHOW_STD_NOTATIONS          (1<<2)
351 #define LIST_SHOW_USER_NOTATIONS         (1<<3)
352 #define LIST_SHOW_NOTATIONS (LIST_SHOW_STD_NOTATIONS|LIST_SHOW_USER_NOTATIONS)
353 #define LIST_SHOW_KEYSERVER_URLS         (1<<4)
354 #define LIST_SHOW_UID_VALIDITY           (1<<5)
355 #define LIST_SHOW_UNUSABLE_UIDS          (1<<6)
356 #define LIST_SHOW_UNUSABLE_SUBKEYS       (1<<7)
357 #define LIST_SHOW_KEYRING                (1<<8)
358 #define LIST_SHOW_SIG_EXPIRE             (1<<9)
359 #define LIST_SHOW_SIG_SUBPACKETS         (1<<10)
360 #define LIST_SHOW_USAGE                  (1<<11)
361
362 #define VERIFY_SHOW_PHOTOS               (1<<0)
363 #define VERIFY_SHOW_POLICY_URLS          (1<<1)
364 #define VERIFY_SHOW_STD_NOTATIONS        (1<<2)
365 #define VERIFY_SHOW_USER_NOTATIONS       (1<<3)
366 #define VERIFY_SHOW_NOTATIONS (VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_USER_NOTATIONS)
367 #define VERIFY_SHOW_KEYSERVER_URLS       (1<<4)
368 #define VERIFY_SHOW_UID_VALIDITY         (1<<5)
369 #define VERIFY_SHOW_UNUSABLE_UIDS        (1<<6)
370 #define VERIFY_PKA_LOOKUPS               (1<<7)
371 #define VERIFY_PKA_TRUST_INCREASE        (1<<8)
372 #define VERIFY_SHOW_PRIMARY_UID_ONLY     (1<<9)
373
374 #define KEYSERVER_HTTP_PROXY             (1<<0)
375 #define KEYSERVER_TIMEOUT                (1<<1)
376 #define KEYSERVER_ADD_FAKE_V3            (1<<2)
377 #define KEYSERVER_AUTO_KEY_RETRIEVE      (1<<3)
378 #define KEYSERVER_HONOR_KEYSERVER_URL    (1<<4)
379 #define KEYSERVER_HONOR_PKA_RECORD       (1<<5)
380
381
382 #endif /*G10_OPTIONS_H*/