-o: accept "-" as name, do nothing (leave stderr as is)
[tfcrypt.git] / tfc_skein.c
index 5d457deac828513156db13ced328d11feb6ef9e7..8102f70af122cff0cbeb7055150ea83267238494 100644 (file)
@@ -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:
  *
@@ -39,16 +39,6 @@ void skein(void *hash, size_t bits, const void *key, const void *data, size_t sz
        skein_final(hash, &sk);
 }
 
-void tf_key_tweak_compat(void *key)
-{
-       TF_UNIT_TYPE *ukey = key, c = THREEFISH_CONST;
-       size_t x;
-
-       for (x = 0; x < TF_NR_BLOCK_UNITS; x++) c ^= ukey[x];
-       ukey[x] = c;
-       ukey[TF_TWEAK_WORD3] = ukey[TF_TWEAK_WORD1] ^ ukey[TF_TWEAK_WORD2];
-}
-
 tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize offset, tfc_fsize readto)
 {
        static tfc_byte skblk[TFC_BLKSIZE];
@@ -180,7 +170,6 @@ _dothat:
        sigact.sa_flags = SA_RESTART;
        sigact.sa_handler = print_crypt_status;
        sigaction(SIGUSR1, &sigact, NULL);
-       sigaction(SIGTSTP, &sigact, NULL);
        sigaction(SIGALRM, &sigact, NULL);
        sigact.sa_handler = change_status_width;
        sigaction(SIGQUIT, &sigact, NULL);
@@ -189,6 +178,8 @@ _dothat:
        sigact.sa_handler = exit_sigterm;
        sigaction(SIGINT, &sigact, NULL);
        sigaction(SIGTERM, &sigact, NULL);
+       sigact.sa_handler = handle_sigtstp;
+       sigaction(SIGTSTP, &sigact, NULL);
        memset(&sigact, 0, sizeof(struct sigaction));
 
        tfc_getcurtime(&delta_time);
@@ -204,8 +195,7 @@ _dothat:
 
                while (1) {
                        memset(sksblk, 0, sizeof(sksblk));
-                       x = xfgets(sksblk, sizeof(sksblk), f);
-                       if (x == 0) break;
+                       if (xfgets(sksblk, sizeof(sksblk), f) != YES) break;
 
                        s = d = sksblk; t = NULL;
                        shash = fname = NULL;
@@ -232,7 +222,7 @@ _dothat:
                                continue;
                        }
 
-                       if (status_timer) setup_next_alarm(status_timer);
+                       if (status_timer) setup_next_alarm(status_timer > 1000000 ? 1000000 : status_timer);
                        if (skeinfd(hash, bits, mackey_opt ? mackey : NULL, fd, iseek, maxlen) != YES) {
                                xerror(YES, NO, YES, "%s", fname);
                                exitcode = 1;
@@ -284,7 +274,7 @@ _dothat:
                        continue;
                }
 
-_dohash:       if (status_timer) setup_next_alarm(status_timer);
+_dohash:       if (status_timer) setup_next_alarm(status_timer > 1000000 ? 1000000 : status_timer);
                if (skeinfd(hash, bits, mackey_opt ? mackey : NULL, fd, iseek, maxlen) != YES) {
                        xerror(YES, NO, YES, "%s", fargv[x]);
                        exitcode = 1;