51 broke -E logic completely, rewise it
[tfcrypt.git] / tfcrypt.h
index a36cc16cfb6cd1d06d10dad53d20acd14ff0951f..acc31df2b4a6e35a7339fb34c9fa9b6b3cbb0c99 100644 (file)
--- a/tfcrypt.h
+++ b/tfcrypt.h
@@ -2,7 +2,7 @@
  * tfcrypt -- high security Threefish encryption tool.
  *
  * tfcrypt is copyrighted:
- * Copyright (C) 2012-2018 Andrey Rys. All rights reserved.
+ * Copyright (C) 2012-2019 Andrey Rys. All rights reserved.
  *
  * tfcrypt is licensed to you under the terms of std. MIT/X11 license:
  *
@@ -61,6 +61,7 @@
 #include <limits.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <time.h>
 #include <sys/time.h>
 #include <stdint.h>
 
@@ -100,7 +101,7 @@ typedef unsigned long long tfc_useconds;
 #define NOFSIZE ((tfc_fsize)-1)
 #define TFC_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
-#define TFC_KEY_BITS (do_tfcrypt1 == YES ? TF_MAX_BITS : TF_NR_KEY_BITS)
+#define TFC_KEY_BITS (do_full_key == NO ? TF_MAX_BITS : TF_NR_KEY_BITS)
 
 #define TFC_ASCII_TFC_MAC_FOURCC "%TF"
 #define TFC_ASCII_TFC_MAC_FOURCC_LEN (sizeof(TFC_ASCII_TFC_MAC_FOURCC)-1)
@@ -127,9 +128,11 @@ extern int ctr_mode;
 extern size_t macbits;
 extern size_t tfc_saltsz;
 extern tfc_byte tfc_salt[TFC_MAX_SALT];
+extern tfc_yesno do_full_key;
 
 extern char *progname;
 extern int exitcode;
+extern pid_t progpid;
 extern 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];
 extern struct skein sk;
 extern struct tfe_stream tfe;
@@ -137,8 +140,8 @@ extern tfc_byte srcblk[TFC_BLKSIZE], dstblk[TFC_BLKSIZE], *pblk;
 extern tfc_byte macvrfy[SKEIN_DIGEST_SIZE], macresult[SKEIN_DIGEST_SIZE];
 extern tfc_byte tmpdata[TFC_TMPSIZE];
 extern char *randsource;
-extern tfc_fsize iseek_blocks, iseek, oseek, maxlen;
-extern tfc_fsize total_processed_src, total_processed_dst;
+extern tfc_fsize iseek_blocks, iseek, oseek, maxlen, ftrunc_dfd;
+extern tfc_fsize total_processed_src, total_processed_dst, total_written_dst;
 extern tfc_fsize delta_processed;
 extern tfc_fsize genrandom_nr_bytes, genzero_nr_bytes;
 extern tfc_fsize rdpos;
@@ -154,14 +157,14 @@ extern size_t sksum_turns;
 extern int do_edcrypt, do_stop, quiet, error_action;
 extern int counter_opt, mackey_opt, do_mac, do_outfmt, rawkey;
 extern int idx, write_flags;
-extern tfc_yesno catch_all_errors, ignore_seek_errors, password, overwrite_source, do_fsync, do_pad, do_tfcrypt1;
-extern tfc_yesno do_preserve_time, do_stats_in_gibs, do_statline_dynamic, do_less_stats;
-extern tfc_yesno no_repeat, do_full_hexdump, verbose, statline_was_shown;
+extern tfc_yesno catch_all_errors, ignore_seek_errors, password, overwrite_source, do_fsync, do_pad, do_ftrunc;
+extern tfc_yesno do_preserve_time, do_stats_in_gibs, do_statline_dynamic, do_less_stats, show_pid, read_only;
+extern tfc_yesno no_repeat, do_full_hexdump, verbose, statline_was_shown, show_secrets, show_when_done;
 extern char *srcfname, *dstfname, *do_mac_file, *counter_file, *sksum_hashlist_file;
 extern char *saltf, *genkeyf, *mackeyf, *tweakf;
 extern char *pw_prompt, *mac_pw_prompt;
 extern tfc_useconds status_timer, bench_timer;
-extern tfc_useconds current_time, delta_time;
+extern tfc_useconds total_time, current_time, delta_time;
 extern struct getpasswd_state getps;
 
 size_t xread(int fd, void *data, size_t szdata);
@@ -184,9 +187,14 @@ void tfc_describescale(tfc_fsize num, double *w, int *scale);
 size_t blk_len_adj(tfc_fsize filelen, tfc_fsize read_already, size_t blklen);
 tfc_yesno xor_shrink(void *dst, size_t szdst, const void *src, size_t szsrc);
 tfc_yesno str_empty(const char *str);
+int xxopen(tfc_yesno noerr, const char *pathname, int flags);
+int xopen(const char *pathname, int flags);
 void xclose(int fd);
 const char *tfc_modename(int mode);
+tfc_yesno tfc_is_freestream(int mode);
 void tfc_getcurtime(tfc_useconds *tx);
+char *tfc_format_time(tfc_useconds t);
+char *tfc_format_pid(const char *str);
 tfc_fsize tfc_fdsize(int fd);
 tfc_fsize tfc_fdgetpos(int fd);
 tfc_fsize tfc_fnamesize(char *fname, tfc_yesno noexit);
@@ -198,6 +206,7 @@ void hex2bin(void *d, const char *s);
 void tfc_finirandom(void);
 void tfc_getrandom(void *buf, size_t sz);
 void exit_sigterm(int signal);
+void handle_sigtstp(int signal);
 void print_crypt_status(int signal);
 void change_status_width(int signal);
 void change_status_timer(int signal);
@@ -206,6 +215,7 @@ void skein(void *hash, size_t bits, const void *key, const void *data, size_t sz
 tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize offset, tfc_fsize readto);
 
 void read_defaults(const char *path, tfc_yesno noerr);
+void hash_defaults(char *uhash, size_t szuhash);
 
 void gen_write_bytes(const char *foutname, tfc_fsize offset, tfc_fsize nrbytes);
 void do_edbase64(char **fargv);
@@ -215,16 +225,17 @@ void do_benchmark(tfc_useconds useconds, double dseconds);
 enum { NO, YES };
 
 enum { TFC_ERRACT_EXIT, TFC_ERRACT_CONT, TFC_ERRACT_SYNC, TFC_ERRACT_LSYNC };
-enum { TFC_STOP_BEGAN = 1, TFC_STOP_FULL };
 enum { TFC_DO_PLAIN, TFC_DO_ENCRYPT, TFC_DO_DECRYPT };
-enum { TFC_MAC_DROP = -1, TFC_MAC_SIGN = 1, TFC_MAC_VRFY, TFC_MAC_JUST_VRFY };
+enum { TFC_MAC_DROP2 = -2, TFC_MAC_DROP = -1, TFC_MAC_SIGN = 1, TFC_MAC_VRFY, TFC_MAC_JUST_VRFY, TFC_MAC_JUST_VRFY2 };
 enum { TFC_MACKEY_RAWKEY = 1, TFC_MACKEY_PASSWORD, TFC_MACKEY_FILE };
 enum { TFC_RAWKEY_KEYFILE = 1, TFC_RAWKEY_ASKSTR, TFC_RAWKEY_ASKHEX };
 enum { TFC_OUTFMT_HEX = 1, TFC_OUTFMT_B64, TFC_OUTFMT_RAW };
 enum {
-       TFC_MODE_SKSUM = -2, TFC_MODE_PLAIN = -1, TFC_MODE_CTR = 1,
-       TFC_MODE_STREAM, TFC_MODE_XTS, TFC_MODE_ECB, TFC_MODE_CBC, TFC_MODE_OCB
+       TFC_MODE_SKSUM = -3, TFC_MODE_XOR = -2, TFC_MODE_PLAIN = -1, TFC_MODE_CTR = 1,
+       TFC_MODE_STREAM, TFC_MODE_XTS, TFC_MODE_ECB, TFC_MODE_CBC, TFC_MODE_PCBC
 };
-enum { TFC_CTR_SHOW = 1, TFC_CTR_HEAD, TFC_CTR_RAND, TFC_CTR_ZERO };
+enum { TFC_CTR_SHOW = 1, TFC_CTR_HEAD, TFC_CTR_RAND, TFC_CTR_ZERO, TFC_CTR_SSET };
+enum { TFC_NO_FTRUNC, TFC_DO_FTRUNC, TFC_FTRUNC_TAIL };
+enum { TFC_SIGLAST = -2, TFC_SIGERR = -1, TFC_SIGSTAT = 0 };
 
 #endif