fix total size indicator when doing -M mac -u.
authorAndrey Rys <rys@lynxlynx.ru>
Sun, 28 Nov 2021 13:51:39 +0000 (14:51 +0100)
committerAndrey Rys <rys@lynxlynx.ru>
Sun, 28 Nov 2021 13:55:09 +0000 (14:55 +0100)
VERSION
tfcrypt.c
tfcrypt.h

diff --git a/VERSION b/VERSION
index fb1e7bc86996a80d4a16529b990adda1d3434c92..c3f407c0955bb5738e40a82664c79b63f04a9adb 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-54
+55
index 054e76899bb5891efb418c3d4941652081d2ea8a..5630a391a6c1798393308d810599512645f9f69b 100644 (file)
--- a/tfcrypt.c
+++ b/tfcrypt.c
@@ -773,7 +773,7 @@ _nokeyfd:
                }
                if (sfd == -1) xerror(NO, NO, YES, "%s", argv[idx]);
 
-               if ((do_mac >= TFC_MAC_VRFY || do_mac == TFC_MAC_DROP) && !do_mac_file) {
+               if ((do_mac >= TFC_MAC_VRFY || do_mac <= TFC_MAC_DROP) && !do_mac_file) {
                        maxlen = tfc_fdsize(sfd);
                        if (maxlen == NOFSIZE)
                                xerror(NO, YES, YES,
@@ -1125,6 +1125,7 @@ _ctrwagain:       lio = xwrite(dfd, pblk, lrem);
                        lrem -= lio;
                        goto _ctrwagain;
                }
+               total_written_dst += ldone;
                total_processed_dst += ldone;
                delta_processed += ldone;
        }
@@ -1330,7 +1331,8 @@ _macragain:               lio = xread(sfd, pblk, lrem);
                        }
                        if (do_mac == TFC_MAC_JUST_VRFY2) {
                                if (verbose) tfc_esay("%s: -u: MAC signature is valid, proceeding with decrypting it again", tfc_format_pid(progname));
-                               do_mac = TFC_MAC_DROP;
+                               maxlen = total_processed_src - SKEIN_DIGEST_SIZE;
+                               do_mac = TFC_MAC_DROP2;
                                goto _decrypt_again_vrfy2;
                        }
                }
@@ -1347,7 +1349,6 @@ _shortmac:        memset(macvrfy, 0, sizeof(macvrfy));
                memset(macresult, 0, sizeof(macresult));
                memset(tmpdata, 0, sizeof(tmpdata));
        }
-
        else if (do_mac == TFC_MAC_SIGN) {
                if (ctr_mode < TFC_MODE_OCB) skein_final(macresult, &sk);
                else skein(macresult, macbits, mackey, macresult, TF_FROM_BITS(macbits));
@@ -1373,6 +1374,7 @@ _macwagain:               lio = xwrite(dfd, pblk, lrem);
                                lrem -= lio;
                                goto _macwagain;
                        }
+                       total_written_dst += ldone;
                        total_processed_dst += ldone;
                        delta_processed += ldone;
                }
@@ -1404,6 +1406,7 @@ _macwagain:               lio = xwrite(dfd, pblk, lrem);
                memset(macresult, 0, sizeof(macresult));
                memset(tmpdata, 0, sizeof(tmpdata));
        }
+       else if (do_mac == TFC_MAC_DROP2) total_processed_src += SKEIN_DIGEST_SIZE;
 
        if (verbose || status_timer || (do_stop == YES && quiet == NO)) print_crypt_status(0);
 
index a571397d5186b9423437ee96803e68b4b37c2ef4..58d77d56f7ccd9aba43c72535ff45a4024ceffe6 100644 (file)
--- a/tfcrypt.h
+++ b/tfcrypt.h
@@ -225,7 +225,7 @@ enum { NO, YES };
 
 enum { TFC_ERRACT_EXIT, TFC_ERRACT_CONT, TFC_ERRACT_SYNC, TFC_ERRACT_LSYNC };
 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, TFC_MAC_JUST_VRFY2 };
+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 };