Debian Codegraph @

g10/options.h

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
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 <https://www.gnu.org/licenses/>.
20 */
21 #ifndef G10_OPTIONS_H
22 #define G10_OPTIONS_H
23
24 #include <sys/types.h>
25 #include "../common/types.h"
26 #include <stdint.h>
27 #include "main.h"
28 #include "packet.h"
29 #include "tofu.h"
30 #include "../common/session-env.h"
31 #include "../common/compliance.h"
32
33
34 /* Object to hold information pertaining to a keyserver; it also
35 allows building a list of keyservers. For historic reasons this is
36 not a strlist_t. */
37 struct keyserver_spec
38 {
39 struct keyserver_spec *next;
40 char *uri;
41 };
42 typedef struct keyserver_spec *keyserver_spec_t;
43
44 /* The --auto-key-locate mechanisms object. */
45 struct akl
46 {
47 enum {
48 AKL_NODEFAULT,
49 AKL_LOCAL,
50 AKL_CERT,
51 AKL_PKA,
52 AKL_DANE,
53 AKL_WKD,
54 AKL_LDAP,
55 AKL_NTDS,
56 AKL_KEYSERVER,
57 AKL_SPEC
58 } type;
59 keyserver_spec_t spec;
60 struct akl *next;
61 };
62
63
64
65 /* Global options for GPG. */
66 EXTERN_UNLESS_MAIN_MODULE
67 struct
68 {
69 int verbose;
70 int quiet;
71 unsigned debug;
72 int armor;
73 char *outfile;
74 estream_t outfp; /* Hack, sometimes used in place of outfile. */
75 off_t max_output;
76
77 /* If > 0 a hint with the expected number of input data bytes. This
78 * is not necessary an exact number but intended to be used for
79 * progress info and to decide on how to allocate buffers. */
80 uint64_t input_size_hint;
81
82 /* The AEAD chunk size expressed as a power of 2. */
83 int chunk_size;
84
85 int dry_run;
86 int autostart;
87 int list_only;
88 int mimemode;
89 int textmode;
90 int expert;
91 const char *def_sig_expire;
92 int ask_sig_expire;
93 const char *def_cert_expire;
94 int ask_cert_expire;
95 int batch; /* run in batch mode */
96 int answer_yes; /* answer yes on most questions */
97 int answer_no; /* answer no on most questions */
98 int check_sigs; /* check key signatures */
99 int with_colons;
100 int with_key_data;
101 int with_icao_spelling; /* Print ICAO spelling with fingerprints. */
102 int with_v5_fingerprint; /* Option --with-v5-fingerprint active. */
103 int with_fingerprint; /* Option --with-fingerprint active. */
104 int with_subkey_fingerprint; /* Option --with-subkey-fingerprint active. */
105 int with_keygrip; /* Option --with-keygrip active. */
106 int with_key_screening;/* Option --with-key-screening active. */
107 int with_tofu_info; /* Option --with-tofu_info active. */
108 int with_secret; /* Option --with-secret active. */
109 int with_wkd_hash; /* Option --with-wkd-hash. */
110 int with_key_origin; /* Option --with-key-origin. */
111 int fingerprint; /* list fingerprints */
112 int list_sigs; /* list signatures */
113 int no_armor;
114 int list_packets; /* Option --list-packets active. */
115 int def_cipher_algo;
116 int force_mdc;
117 int disable_mdc;
118 int force_aead;
119 int def_digest_algo;
120 int cert_digest_algo;
121 int compress_algo;
122 int explicit_compress_option; /* A compress option was explicitly given. */
123 int compress_level;
124 int bz2_compress_level;
125 int bz2_decompress_lowmem;
126 strlist_t def_secret_key;
127 char *def_recipient;
128 int def_recipient_self;
129 strlist_t secret_keys_to_try;
130
131 /* A list of mail addresses (addr-spec) provided by the user with
132 * the option --sender. */
133 strlist_t sender_list;
134
135 /* A list of fingerprints added as designated revokers to new keys. */
136 strlist_t desig_revokers;
137
138 int def_cert_level;
139 int min_cert_level;
140 int ask_cert_level;
141 int emit_version; /* 0 = none,
142 1 = major only,
143 2 = major and minor,
144 3 = full version,
145 4 = full version plus OS string. */
146 int marginals_needed;
147 int completes_needed;
148 int max_cert_depth;
149 char *agent_program;
150 char *keyboxd_program;
151 char *dirmngr_program;
152 int disable_dirmngr;
153
154 const char *def_new_key_algo;
155
156 strlist_t def_new_key_adsks; /* Option --default-new-key-adsk. */
157
158 /* Options to be passed to the gpg-agent */
159 session_env_t session_env;
160 char *lc_ctype;
161 char *lc_messages;
162
163 int skip_verify;
164 int skip_hidden_recipients;
165
166 /* TM_CLASSIC must be zero to accommodate trustdbsg generated before
167 we started storing the trust model inside the trustdb. */
168 enum
169 {
170 TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2,
171 TM_ALWAYS, TM_DIRECT, TM_AUTO, TM_TOFU, TM_TOFU_PGP
172 } trust_model;
173 enum tofu_policy tofu_default_policy;
174 int force_ownertrust;
175 enum gnupg_compliance_mode compliance;
176 enum
177 {
178 KF_DEFAULT, KF_NONE, KF_SHORT, KF_LONG, KF_0xSHORT, KF_0xLONG
179 } keyid_format;
180 const char *set_filename;
181 strlist_t comments;
182 int throw_keyids;
183 const char *photo_viewer;
184 int s2k_mode;
185 int s2k_digest_algo;
186 int s2k_cipher_algo;
187 unsigned char s2k_count; /* This is the encoded form, not the raw
188 count */
189 int not_dash_escaped;
190 int escape_from;
191 int lock_once;
192 keyserver_spec_t keyserver; /* The list of configured keyservers. */
193 struct
194 {
195 unsigned int options;
196 unsigned int import_options;
197 unsigned int export_options;
198 char *http_proxy;
199 } keyserver_options;
200 int exec_disable;
201 int exec_path_set;
202 unsigned int import_options;
203 unsigned int export_options;
204 unsigned int list_options;
205 unsigned int verify_options;
206 const char *def_preference_list;
207 const char *def_keyserver_url;
208 prefitem_t *personal_cipher_prefs;
209 prefitem_t *personal_digest_prefs;
210 prefitem_t *personal_compress_prefs;
211 struct weakhash *weak_digests;
212 int no_perm_warn;
213 char *temp_dir;
214 int no_encrypt_to;
215 int encrypt_to_default_key;
216 int interactive;
217 struct notation *sig_notations;
218 struct notation *cert_notations;
219 strlist_t sig_policy_url;
220 strlist_t cert_policy_url;
221 strlist_t sig_keyserver_url;
222 strlist_t cert_subpackets;
223 strlist_t sig_subpackets;
224 int allow_non_selfsigned_uid;
225 int allow_freeform_uid;
226 int no_literal;
227 ulong set_filesize;
228 int fast_list_mode;
229 int legacy_list_mode;
230 int ignore_time_conflict;
231 int ignore_valid_from;
232 int ignore_crc_error;
233 int ignore_mdc_error;
234 int ignore_expiration;
235 int command_fd;
236 const char *override_session_key;
237 int show_session_key;
238
239 const char *gpg_agent_info;
240 int try_all_secrets;
241 int no_expensive_trust_checks;
242 int no_sig_cache;
243 int no_auto_check_trustdb;
244 int preserve_permissions;
245 int no_homedir_creation;
246 struct groupitem *grouplist;
247 int mangle_dos_filenames;
248 int enable_progress_filter;
249 unsigned int screen_columns;
250 unsigned int screen_lines;
251 byte *show_subpackets;
252 int rfc2440_text;
253 unsigned int min_rsa_length; /* Used for compliance checks. */
254
255 /* If true, let write failures on the status-fd exit the process. */
256 int exit_on_status_write_error;
257
258 /* If > 0, limit the number of card insertion prompts to this
259 value. */
260 int limit_card_insert_tries;
261
262 /* The list of --assert-signer option values. Note: The values are
263 * modify to be uppercase if they represent a fingerrint */
264 strlist_t assert_signer_list;
265
266 /* A single string with the comma delimited args from
267 * --assert-pubkey_algo. */
268 char *assert_pubkey_algos;
269
270 struct
271 {
272 /* If set, require an 0x19 backsig to be present on signatures
273 made by signing subkeys. If not set, a missing backsig is not
274 an error (but an invalid backsig still is). */
275 unsigned int require_cross_cert:1;
276
277 unsigned int use_embedded_filename:1;
278 unsigned int utf8_filename:1;
279 unsigned int dsa2:1;
280 unsigned int allow_old_cipher_algos:1;
281 unsigned int allow_weak_digest_algos:1;
282 unsigned int allow_weak_key_signatures:1;
283 unsigned int large_rsa:1;
284 unsigned int disable_signer_uid:1;
285 unsigned int include_key_block:1;
286 unsigned int auto_key_import:1;
287 /* Flag to enable experimental features from RFC4880bis. */
288 unsigned int rfc4880bis:1;
289 /* Hack: --output is not given but OUTFILE was temporary set to "-". */
290 unsigned int dummy_outfile:1;
291 /* Force the use of the OpenPGP card and do not allow the use of
292 * another card. */
293 unsigned int use_only_openpgp_card:1;
294 unsigned int full_timestrings:1;
295 /* Force signing keys even if a key signature already exists. */
296 unsigned int force_sign_key:1;
297 /* On key generation do not set the ownertrust. */
298 unsigned int no_auto_trust_new_key:1;
299 /* The next flag is set internally iff IMPORT_SELF_SIGS_ONLY has
300 * been set by the user and is not the default value. */
301 unsigned int expl_import_self_sigs_only:1;
302 /* The next flag is set internally iff IMPORT_CLEAN has
303 * been set by the user and is not the default value. */
304 unsigned int expl_import_clean:1;
305 /* Fail if an operation can't be done in the requested compliance
306 * mode. */
307 unsigned int require_compliance:1;
308 /* Process all signatures even in batch mode. */
309 unsigned int proc_all_sigs:1;
310 } flags;
311
312 /* Linked list of ways to find a key if the key isn't on the local
313 keyring. */
314 struct akl *auto_key_locate;
315
316 /* The value of --key-origin. See parse_key_origin(). */
317 int key_origin;
318 char *key_origin_url;
319
320 int passphrase_repeat;
321 int pinentry_mode;
322 int request_origin;
323
324 int unwrap_encryption;
325 int only_sign_text_ids;
326
327 int no_symkey_cache; /* Disable the cache used for --symmetric. */
328
329 int use_keyboxd; /* Use the external keyboxd as storage backend. */
330
331 /* Compatibility flags (COMPAT_FLAG_xxxx). */
332 unsigned int compat_flags;
333 } opt;
334
335
336 /* CTRL is used to keep some global variables we currently can't
337 avoid. Future concurrent versions of gpg will put it into a per
338 request structure CTRL. */
339 EXTERN_UNLESS_MAIN_MODULE
340 struct {
341 int in_auto_key_retrieve; /* True if we are doing an
342 auto_key_retrieve. */
343 /* Hack to store the last error. We currently need it because the
344 proc_packet machinery is not able to reliabale return error
345 codes. Thus for the --server purposes we store some of the error
346 codes here. FIXME! */
347 gpg_error_t lasterr;
348
349 /* Kludge to silence some warnings using --secret-key-list. */
350 int silence_parse_warnings;
351 } glo_ctrl;
352
353 #define DBG_PACKET_VALUE 1 /* debug packet reading/writing */
354 #define DBG_MPI_VALUE 2 /* debug mpi details */
355 #define DBG_CRYPTO_VALUE 4 /* debug crypto handling */
356 /* (may reveal sensitive data) */
357 #define DBG_FILTER_VALUE 8 /* debug internal filter handling */
358 #define DBG_IOBUF_VALUE 16 /* debug iobuf stuff */
359 #define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
360 #define DBG_CACHE_VALUE 64 /* debug the caching */
361 #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
362 #define DBG_TRUST_VALUE 256 /* debug the trustdb */
363 #define DBG_HASHING_VALUE 512 /* debug hashing operations */
364 #define DBG_IPC_VALUE 1024 /* debug assuan communication */
365 #define DBG_CLOCK_VALUE 4096
366 #define DBG_LOOKUP_VALUE 8192 /* debug the key lookup */
367 #define DBG_EXTPROG_VALUE 16384 /* debug external program calls */
368
369 /* Tests for the debugging flags. */
370 #define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
371 #define DBG_MPI (opt.debug & DBG_MPI_VALUE)
372 #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
373 #define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
374 #define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
375 #define DBG_TRUST (opt.debug & DBG_TRUST_VALUE)
376 #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
377 #define DBG_IPC (opt.debug & DBG_IPC_VALUE)
378 #define DBG_CLOCK (opt.debug & DBG_CLOCK_VALUE)
379 #define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
380 #define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
381
382 /* FIXME: We need to check why we did not put this into opt. */
383 #define DBG_MEMORY memory_debug_mode
384 #define DBG_MEMSTAT memory_stat_debug_mode
385
386 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
387 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
388
389 /* Compatibility flags */
390 #define COMPAT_COMPR_KEYS 4 /* Allow import of compressed keys. (T7014) */
391
392
393 /* Compliance test macors. */
394 #define GNUPG (opt.compliance==CO_GNUPG || opt.compliance==CO_DE_VS)
395 #define RFC2440 (opt.compliance==CO_RFC2440)
396 #define RFC4880 (opt.compliance==CO_RFC4880)
397 #define PGP7 (opt.compliance==CO_PGP7)
398 #define PGP8 (opt.compliance==CO_PGP8)
399 #define PGPX (PGP7 || PGP8)
400
401 /* Various option flags. Note that there should be no common string
402 names between the IMPORT_ and EXPORT_ flags as they can be mixed in
403 the keyserver-options option. */
404
405 #define IMPORT_LOCAL_SIGS (1<<0)
406 #define IMPORT_REPAIR_PKS_SUBKEY_BUG (1<<1)
407 #define IMPORT_FAST (1<<2)
408 #define IMPORT_SHOW (1<<3)
409 #define IMPORT_MERGE_ONLY (1<<4)
410 #define IMPORT_MINIMAL (1<<5)
411 #define IMPORT_CLEAN (1<<6)
412 #define IMPORT_ONLY_PUBKEYS (1<<7)
413 #define IMPORT_KEEP_OWNERTTRUST (1<<8)
414 #define IMPORT_EXPORT (1<<9)
415 #define IMPORT_RESTORE (1<<10)
416 #define IMPORT_REPAIR_KEYS (1<<11)
417 #define IMPORT_DRY_RUN (1<<12)
418 #define IMPORT_SELF_SIGS_ONLY (1<<14)
419 #define IMPORT_COLLAPSE_UIDS (1<<15)
420 #define IMPORT_COLLAPSE_SUBKEYS (1<<16)
421 #define IMPORT_BULK (1<<17)
422 #define IMPORT_IGNORE_ATTRIBUTES (1<<18)
423
424 #define EXPORT_LOCAL_SIGS (1<<0)
425 #define EXPORT_ATTRIBUTES (1<<1)
426 #define EXPORT_SENSITIVE_REVKEYS (1<<2)
427 #define EXPORT_RESET_SUBKEY_PASSWD (1<<3)
428 #define EXPORT_MINIMAL (1<<5)
429 #define EXPORT_CLEAN (1<<6)
430 #define EXPORT_DANE_FORMAT (1<<7)
431 #define EXPORT_BACKUP (1<<10)
432 #define EXPORT_REVOCS (1<<11)
433 #define EXPORT_MODE1003 (1<<12)
434 #define EXPORT_REALCLEAN (1<<13)
435
436 #define LIST_SHOW_PHOTOS (1<<0)
437 #define LIST_SHOW_POLICY_URLS (1<<1)
438 #define LIST_SHOW_STD_NOTATIONS (1<<2)
439 #define LIST_SHOW_USER_NOTATIONS (1<<3)
440 #define LIST_SHOW_NOTATIONS (LIST_SHOW_STD_NOTATIONS|LIST_SHOW_USER_NOTATIONS)
441 #define LIST_SHOW_KEYSERVER_URLS (1<<4)
442 #define LIST_SHOW_UID_VALIDITY (1<<5)
443 #define LIST_SHOW_UNUSABLE_UIDS (1<<6)
444 #define LIST_SHOW_UNUSABLE_SUBKEYS (1<<7)
445 #define LIST_SHOW_KEYRING (1<<8)
446 #define LIST_SHOW_SIG_EXPIRE (1<<9)
447 #define LIST_SHOW_SIG_SUBPACKETS (1<<10)
448 #define LIST_SHOW_USAGE (1<<11)
449 #define LIST_SHOW_ONLY_FPR_MBOX (1<<12)
450 #define LIST_SORT_SIGS (1<<13)
451 #define LIST_SHOW_PREF (1<<14)
452 #define LIST_SHOW_PREF_VERBOSE (1<<15)
453 #define LIST_SHOW_UNUSABLE_SIGS (1<<16)
454 #define LIST_SHOW_OWNERTRUST (1<<19)
455
456 #define VERIFY_SHOW_PHOTOS (1<<0)
457 #define VERIFY_SHOW_POLICY_URLS (1<<1)
458 #define VERIFY_SHOW_STD_NOTATIONS (1<<2)
459 #define VERIFY_SHOW_USER_NOTATIONS (1<<3)
460 #define VERIFY_SHOW_NOTATIONS (VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_USER_NOTATIONS)
461 #define VERIFY_SHOW_KEYSERVER_URLS (1<<4)
462 #define VERIFY_SHOW_UID_VALIDITY (1<<5)
463 #define VERIFY_SHOW_UNUSABLE_UIDS (1<<6)
464 #define VERIFY_SHOW_PRIMARY_UID_ONLY (1<<9)
465
466 #define KEYSERVER_HTTP_PROXY (1<<0)
467 #define KEYSERVER_TIMEOUT (1<<1)
468 #define KEYSERVER_ADD_FAKE_V3 (1<<2)
469 #define KEYSERVER_AUTO_KEY_RETRIEVE (1<<3)
470 #define KEYSERVER_HONOR_KEYSERVER_URL (1<<4)
471
472
473 #endif /*G10_OPTIONS_H*/