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
6 * This file is part of GnuPG.
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.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <https://www.gnu.org/licenses/>.
24 #include <sys/types.h>
30 #include "../common/session-env.h"
32 #ifndef EXTERN_UNLESS_MAIN_MODULE
33 /* Norcraft can't cope with common symbols */
34 #if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
35 #define EXTERN_UNLESS_MAIN_MODULE extern
37 #define EXTERN_UNLESS_MAIN_MODULE
41 /* Declaration of a keyserver spec type. The definition is found in
42 ../common/keyserver.h. */
43 struct keyserver_spec;
44 typedef struct keyserver_spec *keyserver_spec_t;
47 /* Global options for GPG. */
48 EXTERN_UNLESS_MAIN_MODULE
56 estream_t outfp; /* Hack, sometimes used in place of outfile. */
59 /* If > 0 a hint with the expected number of input data bytes. This
60 * is not necessary an exact number but intended to be used for
61 * progress info and to decide on how to allocate buffers. */
62 uint64_t input_size_hint;
70 const char *def_sig_expire;
72 const char *def_cert_expire;
74 int batch; /* run in batch mode */
75 int answer_yes; /* answer yes on most questions */
76 int answer_no; /* answer no on most questions */
77 int check_sigs; /* check key signatures */
80 int with_icao_spelling; /* Print ICAO spelling with fingerprints. */
81 int with_fingerprint; /* Option --with-fingerprint active. */
82 int with_subkey_fingerprint; /* Option --with-subkey-fingerprint active. */
83 int with_keygrip; /* Option --with-keygrip active. */
84 int with_tofu_info; /* Option --with-tofu_info active. */
85 int with_secret; /* Option --with-secret active. */
86 int with_wkd_hash; /* Option --with-wkd-hash. */
87 int fingerprint; /* list fingerprints */
88 int list_sigs; /* list signatures */
90 int list_packets; /* Option --list-packets active. */
98 int bz2_compress_level;
99 int bz2_decompress_lowmem;
100 strlist_t def_secret_key;
102 int def_recipient_self;
103 strlist_t secret_keys_to_try;
105 /* A list of mail addresses (addr-spec) provided by the user with
106 * the option --sender. */
107 strlist_t sender_list;
112 int emit_version; /* 0 = none,
116 4 = full version plus OS string. */
117 int marginals_needed;
118 int completes_needed;
120 const char *agent_program;
121 const char *dirmngr_program;
123 const char *def_new_key_algo;
125 /* Options to be passed to the gpg-agent */
126 session_env_t session_env;
131 int skip_hidden_recipients;
133 /* TM_CLASSIC must be zero to accommodate trustdbsg generated before
134 we started storing the trust model inside the trustdb. */
137 TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2,
138 TM_ALWAYS, TM_DIRECT, TM_AUTO, TM_TOFU, TM_TOFU_PGP
140 enum tofu_policy tofu_default_policy;
141 int force_ownertrust;
144 CO_GNUPG, CO_RFC4880, CO_RFC2440,
145 CO_PGP6, CO_PGP7, CO_PGP8, CO_DE_VS
149 KF_DEFAULT, KF_NONE, KF_SHORT, KF_LONG, KF_0xSHORT, KF_0xLONG
152 const char *set_filename;
155 const char *photo_viewer;
159 unsigned char s2k_count; /* This is the encoded form, not the raw
161 int not_dash_escaped;
164 keyserver_spec_t keyserver; /* The list of configured keyservers. */
167 unsigned int options;
168 unsigned int import_options;
169 unsigned int export_options;
174 unsigned int import_options;
175 unsigned int export_options;
176 unsigned int list_options;
177 unsigned int verify_options;
178 const char *def_preference_list;
179 const char *def_keyserver_url;
180 prefitem_t *personal_cipher_prefs;
181 prefitem_t *personal_digest_prefs;
182 prefitem_t *personal_compress_prefs;
183 struct weakhash *weak_digests;
188 int encrypt_to_default_key;
190 struct notation *sig_notations;
191 struct notation *cert_notations;
192 strlist_t sig_policy_url;
193 strlist_t cert_policy_url;
194 strlist_t sig_keyserver_url;
195 strlist_t cert_subpackets;
196 strlist_t sig_subpackets;
197 int allow_non_selfsigned_uid;
198 int allow_freeform_uid;
202 int legacy_list_mode;
203 int ignore_time_conflict;
204 int ignore_valid_from;
205 int ignore_crc_error;
206 int ignore_mdc_error;
208 const char *override_session_key;
209 int show_session_key;
211 const char *gpg_agent_info;
213 int no_expensive_trust_checks;
215 int no_auto_check_trustdb;
216 int preserve_permissions;
217 int no_homedir_creation;
218 struct groupitem *grouplist;
219 int mangle_dos_filenames;
220 int enable_progress_filter;
221 unsigned int screen_columns;
222 unsigned int screen_lines;
223 byte *show_subpackets;
226 /* If true, let write failures on the status-fd exit the process. */
227 int exit_on_status_write_error;
229 /* If > 0, limit the number of card insertion prompts to this
231 int limit_card_insert_tries;
235 /* If set, require an 0x19 backsig to be present on signatures
236 made by signing subkeys. If not set, a missing backsig is not
237 an error (but an invalid backsig still is). */
238 unsigned int require_cross_cert:1;
240 unsigned int use_embedded_filename:1;
241 unsigned int utf8_filename:1;
243 unsigned int allow_multiple_messages:1;
244 unsigned int allow_weak_digest_algos:1;
245 unsigned int large_rsa:1;
246 unsigned int disable_signer_uid:1;
247 /* Flag to enbale experimental features from RFC4880bis. */
248 unsigned int rfc4880bis:1;
251 /* Linked list of ways to find a key if the key isn't on the local
266 keyserver_spec_t spec;
270 int passphrase_repeat;
273 int unwrap_encryption;
274 int only_sign_text_ids;
277 /* CTRL is used to keep some global variables we currently can't
278 avoid. Future concurrent versions of gpg will put it into a per
279 request structure CTRL. */
280 EXTERN_UNLESS_MAIN_MODULE
282 int in_auto_key_retrieve; /* True if we are doing an
283 auto_key_retrieve. */
284 /* Hack to store the last error. We currently need it because the
285 proc_packet machinery is not able to reliabale return error
286 codes. Thus for the --server purposes we store some of the error
287 codes here. FIXME! */
291 #define DBG_PACKET_VALUE 1 /* debug packet reading/writing */
292 #define DBG_MPI_VALUE 2 /* debug mpi details */
293 #define DBG_CRYPTO_VALUE 4 /* debug crypto handling */
294 /* (may reveal sensitive data) */
295 #define DBG_FILTER_VALUE 8 /* debug internal filter handling */
296 #define DBG_IOBUF_VALUE 16 /* debug iobuf stuff */
297 #define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
298 #define DBG_CACHE_VALUE 64 /* debug the caching */
299 #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
300 #define DBG_TRUST_VALUE 256 /* debug the trustdb */
301 #define DBG_HASHING_VALUE 512 /* debug hashing operations */
302 #define DBG_IPC_VALUE 1024 /* debug assuan communication */
303 #define DBG_CLOCK_VALUE 4096
304 #define DBG_LOOKUP_VALUE 8192 /* debug the key lookup */
305 #define DBG_EXTPROG_VALUE 16384 /* debug external program calls */
307 /* Tests for the debugging flags. */
308 #define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
309 #define DBG_MPI (opt.debug & DBG_MPI_VALUE)
310 #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
311 #define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
312 #define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
313 #define DBG_TRUST (opt.debug & DBG_TRUST_VALUE)
314 #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
315 #define DBG_IPC (opt.debug & DBG_IPC_VALUE)
316 #define DBG_IPC (opt.debug & DBG_IPC_VALUE)
317 #define DBG_CLOCK (opt.debug & DBG_CLOCK_VALUE)
318 #define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
319 #define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
321 /* FIXME: We need to check why we did not put this into opt. */
322 #define DBG_MEMORY memory_debug_mode
323 #define DBG_MEMSTAT memory_stat_debug_mode
325 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
326 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
329 /* Compatibility flags. */
330 #define GNUPG (opt.compliance==CO_GNUPG || opt.compliance==CO_DE_VS)
331 #define RFC2440 (opt.compliance==CO_RFC2440)
332 #define RFC4880 (opt.compliance==CO_RFC4880)
333 #define PGP6 (opt.compliance==CO_PGP6)
334 #define PGP7 (opt.compliance==CO_PGP7)
335 #define PGP8 (opt.compliance==CO_PGP8)
336 #define PGPX (PGP6 || PGP7 || PGP8)
338 /* Various option flags. Note that there should be no common string
339 names between the IMPORT_ and EXPORT_ flags as they can be mixed in
340 the keyserver-options option. */
342 #define IMPORT_LOCAL_SIGS (1<<0)
343 #define IMPORT_REPAIR_PKS_SUBKEY_BUG (1<<1)
344 #define IMPORT_FAST (1<<2)
345 #define IMPORT_SHOW (1<<3)
346 #define IMPORT_MERGE_ONLY (1<<4)
347 #define IMPORT_MINIMAL (1<<5)
348 #define IMPORT_CLEAN (1<<6)
349 #define IMPORT_NO_SECKEY (1<<7)
350 #define IMPORT_KEEP_OWNERTTRUST (1<<8)
351 #define IMPORT_EXPORT (1<<9)
352 #define IMPORT_RESTORE (1<<10)
354 #define EXPORT_LOCAL_SIGS (1<<0)
355 #define EXPORT_ATTRIBUTES (1<<1)
356 #define EXPORT_SENSITIVE_REVKEYS (1<<2)
357 #define EXPORT_RESET_SUBKEY_PASSWD (1<<3)
358 #define EXPORT_MINIMAL (1<<4)
359 #define EXPORT_CLEAN (1<<5)
360 #define EXPORT_PKA_FORMAT (1<<6)
361 #define EXPORT_DANE_FORMAT (1<<7)
362 #define EXPORT_BACKUP (1<<10)
364 #define LIST_SHOW_PHOTOS (1<<0)
365 #define LIST_SHOW_POLICY_URLS (1<<1)
366 #define LIST_SHOW_STD_NOTATIONS (1<<2)
367 #define LIST_SHOW_USER_NOTATIONS (1<<3)
368 #define LIST_SHOW_NOTATIONS (LIST_SHOW_STD_NOTATIONS|LIST_SHOW_USER_NOTATIONS)
369 #define LIST_SHOW_KEYSERVER_URLS (1<<4)
370 #define LIST_SHOW_UID_VALIDITY (1<<5)
371 #define LIST_SHOW_UNUSABLE_UIDS (1<<6)
372 #define LIST_SHOW_UNUSABLE_SUBKEYS (1<<7)
373 #define LIST_SHOW_KEYRING (1<<8)
374 #define LIST_SHOW_SIG_EXPIRE (1<<9)
375 #define LIST_SHOW_SIG_SUBPACKETS (1<<10)
376 #define LIST_SHOW_USAGE (1<<11)
378 #define VERIFY_SHOW_PHOTOS (1<<0)
379 #define VERIFY_SHOW_POLICY_URLS (1<<1)
380 #define VERIFY_SHOW_STD_NOTATIONS (1<<2)
381 #define VERIFY_SHOW_USER_NOTATIONS (1<<3)
382 #define VERIFY_SHOW_NOTATIONS (VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_USER_NOTATIONS)
383 #define VERIFY_SHOW_KEYSERVER_URLS (1<<4)
384 #define VERIFY_SHOW_UID_VALIDITY (1<<5)
385 #define VERIFY_SHOW_UNUSABLE_UIDS (1<<6)
386 #define VERIFY_PKA_LOOKUPS (1<<7)
387 #define VERIFY_PKA_TRUST_INCREASE (1<<8)
388 #define VERIFY_SHOW_PRIMARY_UID_ONLY (1<<9)
390 #define KEYSERVER_HTTP_PROXY (1<<0)
391 #define KEYSERVER_TIMEOUT (1<<1)
392 #define KEYSERVER_ADD_FAKE_V3 (1<<2)
393 #define KEYSERVER_AUTO_KEY_RETRIEVE (1<<3)
394 #define KEYSERVER_HONOR_KEYSERVER_URL (1<<4)
395 #define KEYSERVER_HONOR_PKA_RECORD (1<<5)
398 #endif /*G10_OPTIONS_H*/