lift restrictions on partial "window" seeked signature verifying
[tfcrypt.git] / tfc_skein.c
index 7008e48fb5dd541fc18b5ea0785c60262b692753..e2c31f9a2e7d69c35b7f239b2a5057650fed5775 100644 (file)
@@ -47,7 +47,6 @@ tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize of
        tfc_byte *pblk;
        size_t ldone, lblock, lrem, lio;
        tfc_fsize total = 0;
-       tfc_yesno stop;
 
        if (ctr_mode == TFC_MODE_SKSUM) total_processed_src = total_processed_dst = delta_processed = 0;
 
@@ -68,15 +67,15 @@ tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize of
        else skein_init(&sk, bits);
 
        errno = 0;
-       stop = NO;
+       do_stop = NO;
        while (1) {
-               if (stop) break;
+               if (do_stop) break;
                pblk = skblk;
                lblock = lrem = blk_len_adj(readto, total, TFC_BLKSIZE);
                ldone = 0;
                if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(fd);
 _again:                lio = xread(fd, pblk, lrem);
-               if (lio == 0) stop = YES;
+               if (lio == 0) do_stop = YES;
                if (lio != NOSIZE) ldone += lio;
                else {
                        if (errno != EIO && catch_all_errors != YES) goto _fail;
@@ -112,7 +111,10 @@ _again:            lio = xread(fd, pblk, lrem);
 
        skein_final(hash, &sk);
        if (ctr_mode == TFC_MODE_SKSUM) {
-               if (verbose || status_timer) print_crypt_status(-1);
+               if (verbose || status_timer) {
+                       print_crypt_status(-1);
+                       tfc_esay("\n");
+               }
                total_processed_src = total_processed_dst = delta_processed = 0;
        }
        memset(skblk, 0, TFC_BLKSIZE);
@@ -133,6 +135,8 @@ void do_sksum(char *spec, char **fargv)
        int x = 0, xx;
        size_t bits;
 
+       xexit_no_nl = YES;
+
        if (macbits < TF_MAX_BITS) {
                bits = macbits;
                goto _dothat;
@@ -170,7 +174,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);
@@ -179,6 +182,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);
@@ -221,7 +226,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;
@@ -251,7 +256,7 @@ _dothat:
                fclose(f);
                if (failed) {
                        tfc_esay("%s: WARNING: %u of %u computed checksums did NOT match",
-                               progname, failed, totaltested);
+                               tfc_format_pid(progname), failed, totaltested);
                        exitcode = 1;
                }
                xexit(exitcode);
@@ -273,7 +278,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;