"-O ftrunc=": implement file truncations (without sanity checks).
[tfcrypt.git] / tfc_vars.c
1 /*
2  * tfcrypt -- high security Threefish encryption tool.
3  *
4  * tfcrypt is copyrighted:
5  * Copyright (C) 2012-2018 Andrey Rys. All rights reserved.
6  *
7  * tfcrypt is licensed to you under the terms of std. MIT/X11 license:
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28
29 #include "tfcrypt.h"
30 #include "tfcrypt_defs.h"
31
32 char *progname;
33 int exitcode;
34
35 tfc_byte key[TF_KEY_SIZE], ctr[TF_BLOCK_SIZE], xtskey[TF_KEY_SIZE], mackey[TF_FROM_BITS(TF_MAX_BITS)], tweak[TF_TWEAK_SIZE];
36 struct skein sk;
37 struct tfe_stream tfe;
38 tfc_byte srcblk[TFC_BLKSIZE], dstblk[TFC_BLKSIZE], *pblk;
39 tfc_byte macvrfy[SKEIN_DIGEST_SIZE], macresult[SKEIN_DIGEST_SIZE];
40 tfc_byte tmpdata[TFC_TMPSIZE];
41
42 char *randsource = TFC_DEFAULT_RANDSOURCE;
43
44 tfc_fsize iseek_blocks, iseek, oseek, maxlen = NOFSIZE, ftrunc_dfd = NOFSIZE;
45 tfc_fsize total_processed_src, total_processed_dst;
46 tfc_fsize delta_processed;
47 tfc_fsize genrandom_nr_bytes, genzero_nr_bytes;
48 tfc_fsize rdpos = NOFSIZE;
49 tfc_fsize maxkeylen = NOFSIZE, keyoffset;
50 int sfd, kfd = -1, dfd = 1;
51 struct stat s_stat;
52 size_t blksize = TFC_BLKSIZE, xtsblocks = TFC_XTSBLOCKS;
53 char pwdask[512], pwdagain[512];
54
55 size_t lio, lrem, ldone, lblock;
56 size_t ctrsz = NOSIZE;
57
58 struct sigaction sigact;
59
60 size_t sksum_turns;
61
62 int do_edcrypt = TFC_DO_ENCRYPT, do_stop, quiet, error_action;
63 int counter_opt, mackey_opt, do_mac, do_outfmt = TFC_OUTFMT_B64, rawkey;
64 int idx, write_flags;
65 tfc_yesno catch_all_errors, ignore_seek_errors, password, overwrite_source, do_fsync, do_pad;
66 tfc_yesno do_preserve_time, do_stats_in_gibs, do_statline_dynamic = YES, do_less_stats;
67 tfc_yesno no_repeat, do_full_hexdump = YES, verbose, statline_was_shown, show_secrets;
68 char *srcfname = TFC_STDIN_NAME, *dstfname = TFC_STDOUT_NAME, *do_mac_file, *counter_file, *sksum_hashlist_file;
69 char *saltf, *genkeyf, *mackeyf, *tweakf;
70 char *pw_prompt, *mac_pw_prompt;
71 tfc_useconds status_timer, bench_timer;
72 tfc_useconds current_time, delta_time;
73
74 struct getpasswd_state getps;