7f78b84fad5b70222c3259bb1c725e5098a66608
[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
31 char *progname;
32 int exitcode;
33
34 size_t nr_turns = TFC_NR_TURNS;
35 int ctr_mode = TFC_CTR_MODE;
36 size_t macbits = TF_MAX_BITS;
37
38 tfc_byte key[TF_KEY_SIZE], ctr[TF_BLOCK_SIZE], xtskey[TF_KEY_SIZE], mackey[TF_FROM_BITS(TF_MAX_BITS)];
39 struct skein sk;
40 struct tfe_stream tfe;
41 tfc_byte srcblk[TFC_BLKSIZE], dstblk[TFC_BLKSIZE], *pblk;
42 tfc_byte macvrfy[SKEIN_DIGEST_SIZE], macresult[SKEIN_DIGEST_SIZE];
43 tfc_byte tmpdata[TFC_TMPSIZE];
44
45 char *randsource = TFC_DEFAULT_RANDSOURCE;
46
47 tfc_fsize iseek_blocks, iseek, oseek, maxlen = NOFSIZE;
48 tfc_fsize total_processed_src, total_processed_dst;
49 tfc_fsize delta_processed;
50 tfc_fsize genrandom_nr_bytes, genzero_nr_bytes;
51 int sfd, kfd = -1, dfd = 1;
52 struct stat s_stat;
53 size_t blksize = TFC_BLKSIZE, xtsblocks = TFC_XTSBLOCKS;
54 char pwdask[512], pwdagain[512];
55
56 size_t lio, lrem, ldone, lblock;
57 size_t maxkeylen = NOSIZE, ctrsz = NOSIZE;
58
59 struct sigaction sigact;
60
61 size_t sksum_turns;
62
63 int do_edcrypt = TFC_DO_ENCRYPT, do_stop, quiet, error_action;
64 int counter_opt, mackey_opt, do_mac, do_outfmt = TFC_OUTFMT_B64, rawkey;
65 int idx, write_flags;
66 tfc_yesno catch_all_errors, password, overwrite_source, do_fsync, do_pad, do_tfcrypt1;
67 tfc_yesno do_preserve_time, do_stats_in_gibs, do_statline_dynamic = YES, do_less_stats;
68 tfc_yesno no_repeat, do_full_hexdump = YES, verbose, statline_was_shown;
69 char *srcfname = TFC_STDIN_NAME, *dstfname = TFC_STDOUT_NAME, *do_mac_file, *counter_file, *sksum_hashlist_file;
70 char *genkeyf, *mackeyf, *tweakf;
71 char *pw_prompt, *mac_pw_prompt;
72 tfc_useconds status_timer, bench_timer;
73 tfc_useconds current_time, delta_time;
74
75 struct getpasswd_state getps;